Communication: Support extended commands
parent
67c8e6a952
commit
38f0022bb6
|
|
@ -79,6 +79,21 @@ bool Communication::sendCommand(Command cmd, std::vector<uint8_t> arguments) {
|
||||||
return sendPacket(packet);
|
return sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Communication::sendCommand(ExtendedCommand cmd, std::vector<uint8_t> arguments) {
|
||||||
|
const auto size = arguments.size();
|
||||||
|
if (size > std::numeric_limits<uint16_t>::max())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
arguments.insert(arguments.begin(), {
|
||||||
|
uint8_t(uint16_t(cmd) & 0xff),
|
||||||
|
uint8_t((uint16_t(cmd) >> 8) & 0xff),
|
||||||
|
uint8_t(size & 0xff),
|
||||||
|
uint8_t((size >> 8) & 0xff)
|
||||||
|
});
|
||||||
|
|
||||||
|
return sendCommand(Command::Extended, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
bool Communication::redirectRead(std::function<void(std::vector<uint8_t>&&)> redirectTo) {
|
bool Communication::redirectRead(std::function<void(std::vector<uint8_t>&&)> redirectTo) {
|
||||||
if(redirectingRead)
|
if(redirectingRead)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,21 @@ enum class Command : uint8_t {
|
||||||
RequestBitSmash = 0xDC, // Previously known as RED_CMD_CM_BITSMASH
|
RequestBitSmash = 0xDC, // Previously known as RED_CMD_CM_BITSMASH
|
||||||
GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST
|
GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST
|
||||||
MiscControl = 0xE7,
|
MiscControl = 0xE7,
|
||||||
|
Extended = 0xF0,
|
||||||
FlexRayControl = 0xF3
|
FlexRayControl = 0xF3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ExtendedCommand : uint16_t {
|
||||||
|
GetDiskDetails = 0x0010,
|
||||||
|
DiskFormatStart = 0x0011,
|
||||||
|
DiskFormatCancel = 0x0012,
|
||||||
|
DiskFormatProgress = 0x0013,
|
||||||
|
DiskFormatUpdate = 0x0014,
|
||||||
|
Extract = 0x0015,
|
||||||
|
StartDHCPServer = 0x0016,
|
||||||
|
StopDHCPServer = 0x0017,
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public:
|
||||||
|
|
||||||
virtual bool sendCommand(Command cmd, bool boolean) { return sendCommand(cmd, std::vector<uint8_t>({ (uint8_t)boolean })); }
|
virtual bool sendCommand(Command cmd, bool boolean) { return sendCommand(cmd, std::vector<uint8_t>({ (uint8_t)boolean })); }
|
||||||
virtual bool sendCommand(Command cmd, std::vector<uint8_t> arguments = {});
|
virtual bool sendCommand(Command cmd, std::vector<uint8_t> arguments = {});
|
||||||
|
bool sendCommand(ExtendedCommand cmd, std::vector<uint8_t> arguments = {});
|
||||||
bool getSettingsSync(std::vector<uint8_t>& data, std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
bool getSettingsSync(std::vector<uint8_t>& data, std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
std::shared_ptr<SerialNumberMessage> getSerialNumberSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
std::shared_ptr<SerialNumberMessage> getSerialNumberSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
optional< std::vector< optional<DeviceAppVersion> > > getVersionsSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
optional< std::vector< optional<DeviceAppVersion> > > getVersionsSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue