feat: add readMemoryLocation method and update GatewayController for memory identity reads
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -167,6 +167,7 @@ constexpr uint16_t kBridgeOperationSetColourRGB = 23;
|
||||
constexpr uint16_t kBridgeOperationSetColourRGBW = 80;
|
||||
constexpr uint16_t kBridgeOperationSetColourRGBCW = 81;
|
||||
constexpr uint16_t kBridgeOperationSetColourRGBWAF = 82;
|
||||
constexpr uint16_t kBridgeOperationReadMemoryIdentity = 84;
|
||||
constexpr uint16_t kDaliCmdQueryStatus = 0x90;
|
||||
constexpr uint16_t kDaliCmdQueryBallast = 0x91;
|
||||
constexpr const char* kBridgeTransportInvalidFrameResponse =
|
||||
@@ -2993,6 +2994,51 @@ void GatewayController::runOperationTask(GatewayOperationTaskContext* context) {
|
||||
progress = 100;
|
||||
break;
|
||||
}
|
||||
case kBridgeOperationReadMemoryIdentity: {
|
||||
if (target < 0 || target > 63) {
|
||||
fail(kOperationStatusInvalid);
|
||||
break;
|
||||
}
|
||||
struct MemoryLocation {
|
||||
uint8_t bank;
|
||||
uint8_t location;
|
||||
};
|
||||
std::vector<MemoryLocation> locations;
|
||||
locations.reserve(38);
|
||||
for (uint8_t location = 0x00; location <= 0x05; ++location) {
|
||||
locations.push_back(MemoryLocation{0, location});
|
||||
}
|
||||
const bool extended = TlvIntOr(fields, kTlvFieldKind, 0) != 0;
|
||||
const uint8_t bank1_end = extended ? 0x1F : 0x06;
|
||||
for (uint8_t location = 0x00; location <= bank1_end; ++location) {
|
||||
locations.push_back(MemoryLocation{1, location});
|
||||
}
|
||||
const int total = std::max<int>(1, locations.size());
|
||||
for (size_t index = 0; index < locations.size(); ++index) {
|
||||
if (canceled()) {
|
||||
fail(kOperationStatusAborted);
|
||||
break;
|
||||
}
|
||||
const auto location = locations[index];
|
||||
const auto value = dali_domain_.readMemoryLocation(gateway_id, target, location.bank,
|
||||
location.location);
|
||||
if (value.has_value()) {
|
||||
const uint8_t entry[] = {location.bank, location.location, value.value()};
|
||||
AppendTlvBytes(result_tlvs, kTlvFieldEntry, kTlvTypeBytes, entry, sizeof(entry));
|
||||
++count;
|
||||
}
|
||||
update_progress(kOperationEventItemResult,
|
||||
static_cast<uint8_t>((index + 1) * 100 / total),
|
||||
location.location, count,
|
||||
value.has_value() ? kOperationStatusOk : kOperationStatusNoResponse);
|
||||
}
|
||||
if (status == kOperationStatusOk && count == 0) {
|
||||
fail(kOperationStatusNoResponse);
|
||||
} else {
|
||||
progress = 100;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kBridgeOperationAllocateAllShortAddresses:
|
||||
case kBridgeOperationResetAndAllocateShortAddresses:
|
||||
case kBridgeOperationStopAddressAllocation: {
|
||||
|
||||
Reference in New Issue
Block a user