Reworked updating LEDState to use sendCommand() instead of transmit()
parent
28fc98c475
commit
a4a42c8704
|
|
@ -103,9 +103,23 @@ bool Encoder::encode(std::vector<uint8_t>& result, const std::shared_ptr<Message
|
||||||
|
|
||||||
bool Encoder::encode(std::vector<uint8_t>& result, Command cmd, std::vector<uint8_t> arguments) {
|
bool Encoder::encode(std::vector<uint8_t>& result, Command cmd, std::vector<uint8_t> arguments) {
|
||||||
auto msg = std::make_shared<Message>();
|
auto msg = std::make_shared<Message>();
|
||||||
msg->network = Network::NetID::Main51;
|
if(cmd == Command::UpdateLEDState) {
|
||||||
msg->data.reserve(arguments.size() + 1);
|
/* NetID::Device is a super old command type.
|
||||||
msg->data.push_back((uint8_t)cmd);
|
* It has a leading 0x00 byte, a byte for command, and a byte for an argument.
|
||||||
msg->data.insert(msg->data.end(), std::make_move_iterator(arguments.begin()), std::make_move_iterator(arguments.end()));
|
* In this case, command 0x06 is SetLEDState.
|
||||||
|
* This old command type is not really used anywhere else.
|
||||||
|
*/
|
||||||
|
msg->network = Network::NetID::Device;
|
||||||
|
msg->data.reserve(3);
|
||||||
|
msg->data.push_back(0x00);
|
||||||
|
msg->data.push_back(0x06);
|
||||||
|
msg->data.push_back(arguments.at(0));
|
||||||
|
} else {
|
||||||
|
msg->network = Network::NetID::Main51;
|
||||||
|
msg->data.reserve(arguments.size() + 1);
|
||||||
|
msg->data.push_back((uint8_t)cmd);
|
||||||
|
msg->data.insert(msg->data.end(), std::make_move_iterator(arguments.begin()), std::make_move_iterator(arguments.end()));
|
||||||
|
}
|
||||||
|
|
||||||
return encode(result, msg);
|
return encode(result, msg);
|
||||||
}
|
}
|
||||||
|
|
@ -300,13 +300,6 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::updateLEDState() {
|
void Device::updateLEDState() {
|
||||||
/* NetID::Device is a super old command type.
|
std::vector<uint8_t> args {(uint8_t) ledState};
|
||||||
* It has a leading 0x00 byte, a byte for command, and a byte for an argument.
|
com->sendCommand(Command::UpdateLEDState, args);
|
||||||
* In this case, command 0x06 is SetLEDState.
|
|
||||||
* This old command type is not really used anywhere else.
|
|
||||||
*/
|
|
||||||
auto msg = std::make_shared<Message>();
|
|
||||||
msg->network = Network::NetID::Device;
|
|
||||||
msg->data = {0x00, 0x06, uint8_t(ledState)};
|
|
||||||
transmit(msg);
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,8 @@ enum class Command : uint8_t {
|
||||||
//GetSettings = 0xA5, // Previously known as RED_CMD_READ_BAUD_REQ, now unused
|
//GetSettings = 0xA5, // Previously known as RED_CMD_READ_BAUD_REQ, now unused
|
||||||
SaveSettings = 0xA6,
|
SaveSettings = 0xA6,
|
||||||
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
||||||
ReadSettings = 0xC7 // Previously known as 3G_READ_SETTINGS_EX
|
ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX
|
||||||
|
UpdateLEDState = 0xA7
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue