BLOCKS API: Added extra support for clustering, pitchbend messages and firmware update error handlingtags/2021-05-28
| @@ -389,7 +389,7 @@ public: | |||||
| /** Sends a firmware update packet to a block, and waits for a reply. Returns an error code. */ | /** Sends a firmware update packet to a block, and waits for a reply. Returns an error code. */ | ||||
| virtual bool sendFirmwareUpdatePacket (const uint8* data, uint8 size, | virtual bool sendFirmwareUpdatePacket (const uint8* data, uint8 size, | ||||
| std::function<void (uint8)> packetAckCallback) = 0; | |||||
| std::function<void (uint8, uint32)> packetAckCallback) = 0; | |||||
| /** Provides a callback that will be called when a config changes. */ | /** Provides a callback that will be called when a config changes. */ | ||||
| virtual void setConfigChangedCallback (std::function<void(Block&, const ConfigMetaData&, uint32)>) = 0; | virtual void setConfigChangedCallback (std::function<void(Block&, const ConfigMetaData&, uint32)>) = 0; | ||||
| @@ -321,7 +321,8 @@ enum ConfigCommands | |||||
| updateConfig = 0x04, // Set value, min and max | updateConfig = 0x04, // Set value, min and max | ||||
| updateUserConfig = 0x05, // As above but contains user config metadata | updateUserConfig = 0x05, // As above but contains user config metadata | ||||
| setConfigState = 0x06, // Set config activation state and whether it is saved in flash | setConfigState = 0x06, // Set config activation state and whether it is saved in flash | ||||
| factorySyncEnd = 0x07 | |||||
| factorySyncEnd = 0x07, | |||||
| clusterConfigSync = 0x08 | |||||
| }; | }; | ||||
| using ConfigCommand = IntegerWithBitSize<4>; | using ConfigCommand = IntegerWithBitSize<4>; | ||||
| @@ -358,6 +359,7 @@ using ByteValue = IntegerWithBitSize<8>; | |||||
| using ByteSequenceContinues = IntegerWithBitSize<1>; | using ByteSequenceContinues = IntegerWithBitSize<1>; | ||||
| using FirmwareUpdateACKCode = IntegerWithBitSize<7>; | using FirmwareUpdateACKCode = IntegerWithBitSize<7>; | ||||
| using FirmwareUpdateACKDetail = IntegerWithBitSize<32>; | |||||
| using FirmwareUpdatePacketSize = IntegerWithBitSize<7>; | using FirmwareUpdatePacketSize = IntegerWithBitSize<7>; | ||||
| static constexpr uint32 numProgramMessageInts = 3; | static constexpr uint32 numProgramMessageInts = 3; | ||||
| @@ -387,7 +389,7 @@ enum BitSizes | |||||
| programEventMessage = MessageType::bits + 32 * numProgramMessageInts, | programEventMessage = MessageType::bits + 32 * numProgramMessageInts, | ||||
| packetACK = MessageType::bits + PacketCounter::bits, | packetACK = MessageType::bits + PacketCounter::bits, | ||||
| firmwareUpdateACK = MessageType::bits + FirmwareUpdateACKCode::bits, | |||||
| firmwareUpdateACK = MessageType::bits + FirmwareUpdateACKCode::bits + FirmwareUpdateACKDetail::bits, | |||||
| controlButtonMessage = typeDeviceAndTime + ControlButtonID::bits, | controlButtonMessage = typeDeviceAndTime + ControlButtonID::bits, | ||||
| @@ -466,6 +468,7 @@ static constexpr const char* ledProgramLittleFootFunctions[] = | |||||
| "sendAftertouch/viii", | "sendAftertouch/viii", | ||||
| "sendCC/viii", | "sendCC/viii", | ||||
| "sendPitchBend/vii", | "sendPitchBend/vii", | ||||
| "sendPitchBend/viii", | |||||
| "sendChannelPressure/vii", | "sendChannelPressure/vii", | ||||
| "setChannelRange/vbii", | "setChannelRange/vbii", | ||||
| "assignChannel/ii", | "assignChannel/ii", | ||||
| @@ -302,7 +302,7 @@ struct HostPacketDecoder | |||||
| return false; | return false; | ||||
| } | } | ||||
| handler.handleFirmwareUpdateACK (deviceIndex, reader.read<FirmwareUpdateACKCode>()); | |||||
| handler.handleFirmwareUpdateACK (deviceIndex, reader.read<FirmwareUpdateACKCode>(), reader.read<FirmwareUpdateACKDetail>()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -625,10 +625,10 @@ struct PhysicalTopologySource::Internal | |||||
| detector.handleSharedDataACK (deviceID, counter); | detector.handleSharedDataACK (deviceID, counter); | ||||
| } | } | ||||
| void handleFirmwareUpdateACK (BlocksProtocol::TopologyIndex deviceIndex, BlocksProtocol::FirmwareUpdateACKCode resultCode) | |||||
| void handleFirmwareUpdateACK (BlocksProtocol::TopologyIndex deviceIndex, BlocksProtocol::FirmwareUpdateACKCode resultCode, BlocksProtocol::FirmwareUpdateACKDetail resultDetail) | |||||
| { | { | ||||
| if (auto deviceID = getDeviceIDFromMessageIndex (deviceIndex)) | if (auto deviceID = getDeviceIDFromMessageIndex (deviceIndex)) | ||||
| detector.handleFirmwareUpdateACK (deviceID, (uint8) resultCode.get()); | |||||
| detector.handleFirmwareUpdateACK (deviceID, (uint8) resultCode.get(), (uint32) resultDetail.get()); | |||||
| } | } | ||||
| void handleConfigUpdateMessage (BlocksProtocol::TopologyIndex deviceIndex, int32 item, int32 value, int32 min, int32 max) | void handleConfigUpdateMessage (BlocksProtocol::TopologyIndex deviceIndex, int32 item, int32 value, int32 min, int32 max) | ||||
| @@ -958,12 +958,12 @@ struct PhysicalTopologySource::Internal | |||||
| bi->handleSharedDataACK (packetCounter); | bi->handleSharedDataACK (packetCounter); | ||||
| } | } | ||||
| void handleFirmwareUpdateACK (Block::UID deviceID, uint8 resultCode) | |||||
| void handleFirmwareUpdateACK (Block::UID deviceID, uint8 resultCode, uint32 resultDetail) | |||||
| { | { | ||||
| for (auto&& b : currentTopology.blocks) | for (auto&& b : currentTopology.blocks) | ||||
| if (b->uid == deviceID) | if (b->uid == deviceID) | ||||
| if (auto bi = BlockImplementation::getFrom (*b)) | if (auto bi = BlockImplementation::getFrom (*b)) | ||||
| bi->handleFirmwareUpdateACK (resultCode); | |||||
| bi->handleFirmwareUpdateACK (resultCode, resultDetail); | |||||
| } | } | ||||
| void handleConfigUpdateMessage (Block::UID deviceID, int32 item, int32 value, int32 min, int32 max) | void handleConfigUpdateMessage (Block::UID deviceID, int32 item, int32 value, int32 min, int32 max) | ||||
| @@ -1505,7 +1505,7 @@ struct PhysicalTopologySource::Internal | |||||
| remoteHeap.handleACKFromDevice (*this, packetCounter); | remoteHeap.handleACKFromDevice (*this, packetCounter); | ||||
| } | } | ||||
| bool sendFirmwareUpdatePacket (const uint8* data, uint8 size, std::function<void (uint8)> callback) override | |||||
| bool sendFirmwareUpdatePacket (const uint8* data, uint8 size, std::function<void (uint8, uint32)> callback) override | |||||
| { | { | ||||
| firmwarePacketAckCallback = {}; | firmwarePacketAckCallback = {}; | ||||
| @@ -1535,11 +1535,11 @@ struct PhysicalTopologySource::Internal | |||||
| return false; | return false; | ||||
| } | } | ||||
| void handleFirmwareUpdateACK (uint8 resultCode) | |||||
| void handleFirmwareUpdateACK (uint8 resultCode, uint32 resultDetail) | |||||
| { | { | ||||
| if (firmwarePacketAckCallback != nullptr) | if (firmwarePacketAckCallback != nullptr) | ||||
| { | { | ||||
| firmwarePacketAckCallback (resultCode); | |||||
| firmwarePacketAckCallback (resultCode, resultDetail); | |||||
| firmwarePacketAckCallback = {}; | firmwarePacketAckCallback = {}; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1752,7 +1752,7 @@ struct PhysicalTopologySource::Internal | |||||
| std::unique_ptr<Program> program; | std::unique_ptr<Program> program; | ||||
| uint32 programSize = 0; | uint32 programSize = 0; | ||||
| std::function<void(uint8)> firmwarePacketAckCallback; | |||||
| std::function<void(uint8, uint32)> firmwarePacketAckCallback; | |||||
| uint32 resetMessagesSent = 0; | uint32 resetMessagesSent = 0; | ||||
| bool isStillConnected = true; | bool isStillConnected = true; | ||||