reset device PID
This commit is contained in:
parent
de435d5021
commit
75b4b13997
|
@ -176,6 +176,13 @@ Device::Device(Device* parent)
|
|||
&Device::actionSetIdentifyDevice,
|
||||
this, std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
/// 10.11.2 Reset Device (RESET_DEVICE)
|
||||
/// This parameter is used to instruct the responder to reset itself.
|
||||
parameters_.try_emplace(RESET_DEVICE, new Parameter());
|
||||
parameters_.at(RESET_DEVICE)->setAction(std::bind(
|
||||
&Device::actionSetResetDevice,
|
||||
this, std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
}
|
||||
|
||||
|
||||
|
@ -679,4 +686,30 @@ void Device::actionSetIdentifyDevice(const Message *message, Message *response)
|
|||
identify(message->data()->front());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Device::actionSetResetDevice
|
||||
* @param message
|
||||
* @param response
|
||||
*/
|
||||
void Device::actionSetResetDevice(const Message *message, Message *response)
|
||||
{
|
||||
if (!message->requiredLength(1, response))
|
||||
return;
|
||||
|
||||
switch (message->data()->front()) {
|
||||
case 0x01:
|
||||
reset(false);
|
||||
break;
|
||||
case 0xff:
|
||||
reset(true);
|
||||
break;
|
||||
default:
|
||||
response->nak(NR_FORMAT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
response->responseType = RESPONSE_TYPE_ACK;
|
||||
}
|
||||
|
||||
} // namespace RDM
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
void set(const Message* message, Message* response);
|
||||
|
||||
virtual void identify(bool state) { identifying_ = state; }
|
||||
virtual void reset(bool hard) { (void)hard; }
|
||||
|
||||
UID id;
|
||||
uint16_t deviceModelID;
|
||||
|
@ -81,6 +82,7 @@ protected:
|
|||
void actionSensorDispatch (const Message *message, Message *response);
|
||||
void actionGetIdentifyDevice (const Message *message, Message *response);
|
||||
void actionSetIdentifyDevice (const Message *message, Message *response);
|
||||
void actionSetResetDevice (const Message *message, Message *response);
|
||||
|
||||
private:
|
||||
Device* parent_;
|
||||
|
|
|
@ -176,6 +176,19 @@ void Responder::receive(const Message *message)
|
|||
|
||||
if (response)
|
||||
queued_messages_.push(response);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Responder::reset
|
||||
* @param hard
|
||||
*/
|
||||
void Responder::reset(bool hard)
|
||||
{
|
||||
(void)hard;
|
||||
|
||||
/// 10.11.2 Reset Device (RESET_DEVICE)
|
||||
/// This parameter shall also clear the Discovery Mute flag.
|
||||
discovery_mute_flag_ = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
virtual ~Responder();
|
||||
|
||||
void receive(const std::vector<uint8_t>& data);
|
||||
virtual void reset(bool hard) override;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void send(const std::vector<uint8_t>& data);
|
||||
|
@ -53,6 +55,7 @@ protected:
|
|||
std::queue<Message*> queued_messages_;
|
||||
|
||||
private:
|
||||
bool discovery_mute_flag_ = false;
|
||||
uint16_t short_message_counter_ = 0;
|
||||
uint16_t length_mismatch_counter_ = 0;
|
||||
uint16_t checksum_fail_counter_ = 0;
|
||||
|
|
Loading…
Reference in New Issue