Browse Source

Blocks/api (#18)

BLOCKS API:   Added extra support for clustering, pitchbend messages and firmware update error handling
tags/2021-05-28
Tom Waldron Julian Storer 7 years ago
parent
commit
b5e6570a10
4 changed files with 15 additions and 12 deletions
  1. +1
    -1
      modules/juce_blocks_basics/blocks/juce_Block.h
  2. +5
    -2
      modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h
  3. +1
    -1
      modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h
  4. +8
    -8
      modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp

+ 1
- 1
modules/juce_blocks_basics/blocks/juce_Block.h View File

@@ -389,7 +389,7 @@ public:
/** 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,
std::function<void (uint8)> packetAckCallback) = 0;
std::function<void (uint8, uint32)> packetAckCallback) = 0;
/** Provides a callback that will be called when a config changes. */
virtual void setConfigChangedCallback (std::function<void(Block&, const ConfigMetaData&, uint32)>) = 0;


+ 5
- 2
modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h View File

@@ -321,7 +321,8 @@ enum ConfigCommands
updateConfig = 0x04, // Set value, min and max
updateUserConfig = 0x05, // As above but contains user config metadata
setConfigState = 0x06, // Set config activation state and whether it is saved in flash
factorySyncEnd = 0x07
factorySyncEnd = 0x07,
clusterConfigSync = 0x08
};
using ConfigCommand = IntegerWithBitSize<4>;
@@ -358,6 +359,7 @@ using ByteValue = IntegerWithBitSize<8>;
using ByteSequenceContinues = IntegerWithBitSize<1>;
using FirmwareUpdateACKCode = IntegerWithBitSize<7>;
using FirmwareUpdateACKDetail = IntegerWithBitSize<32>;
using FirmwareUpdatePacketSize = IntegerWithBitSize<7>;
static constexpr uint32 numProgramMessageInts = 3;
@@ -387,7 +389,7 @@ enum BitSizes
programEventMessage = MessageType::bits + 32 * numProgramMessageInts,
packetACK = MessageType::bits + PacketCounter::bits,
firmwareUpdateACK = MessageType::bits + FirmwareUpdateACKCode::bits,
firmwareUpdateACK = MessageType::bits + FirmwareUpdateACKCode::bits + FirmwareUpdateACKDetail::bits,
controlButtonMessage = typeDeviceAndTime + ControlButtonID::bits,
@@ -466,6 +468,7 @@ static constexpr const char* ledProgramLittleFootFunctions[] =
"sendAftertouch/viii",
"sendCC/viii",
"sendPitchBend/vii",
"sendPitchBend/viii",
"sendChannelPressure/vii",
"setChannelRange/vbii",
"assignChannel/ii",


+ 1
- 1
modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h View File

@@ -302,7 +302,7 @@ struct HostPacketDecoder
return false;
}
handler.handleFirmwareUpdateACK (deviceIndex, reader.read<FirmwareUpdateACKCode>());
handler.handleFirmwareUpdateACK (deviceIndex, reader.read<FirmwareUpdateACKCode>(), reader.read<FirmwareUpdateACKDetail>());
return true;
}


+ 8
- 8
modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp View File

@@ -625,10 +625,10 @@ struct PhysicalTopologySource::Internal
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))
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)
@@ -958,12 +958,12 @@ struct PhysicalTopologySource::Internal
bi->handleSharedDataACK (packetCounter);
}
void handleFirmwareUpdateACK (Block::UID deviceID, uint8 resultCode)
void handleFirmwareUpdateACK (Block::UID deviceID, uint8 resultCode, uint32 resultDetail)
{
for (auto&& b : currentTopology.blocks)
if (b->uid == deviceID)
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)
@@ -1505,7 +1505,7 @@ struct PhysicalTopologySource::Internal
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 = {};
@@ -1535,11 +1535,11 @@ struct PhysicalTopologySource::Internal
return false;
}
void handleFirmwareUpdateACK (uint8 resultCode)
void handleFirmwareUpdateACK (uint8 resultCode, uint32 resultDetail)
{
if (firmwarePacketAckCallback != nullptr)
{
firmwarePacketAckCallback (resultCode);
firmwarePacketAckCallback (resultCode, resultDetail);
firmwarePacketAckCallback = {};
}
}
@@ -1752,7 +1752,7 @@ struct PhysicalTopologySource::Internal
std::unique_ptr<Program> program;
uint32 programSize = 0;
std::function<void(uint8)> firmwarePacketAckCallback;
std::function<void(uint8, uint32)> firmwarePacketAckCallback;
uint32 resetMessagesSent = 0;
bool isStillConnected = true;


Loading…
Cancel
Save