Implemented crc16 calculation for DevControlCommand
This commit is contained in:
parent
cfdbf5963c
commit
d998271944
@ -1,4 +1,5 @@
|
|||||||
#include "DevControlCommand.h"
|
#include "DevControlCommand.h"
|
||||||
|
#include "crc.h"
|
||||||
|
|
||||||
DevControlCommand::DevControlCommand(uint64_t target_address, uint64_t router_address)
|
DevControlCommand::DevControlCommand(uint64_t target_address, uint64_t router_address)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(target_address, router_address)
|
||||||
@ -6,3 +7,10 @@ DevControlCommand::DevControlCommand(uint64_t target_address, uint64_t router_ad
|
|||||||
_payload[0] = 0x51;
|
_payload[0] = 0x51;
|
||||||
_payload[9] = 0x81;
|
_payload[9] = 0x81;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevControlCommand::udpateCRC(uint8_t len)
|
||||||
|
{
|
||||||
|
uint16_t crc = crc16(&_payload[10], len);
|
||||||
|
_payload[10 + len] = (uint8_t)(crc >> 8);
|
||||||
|
_payload[10 + len + 1] = (uint8_t)(crc);
|
||||||
|
}
|
||||||
@ -5,4 +5,7 @@
|
|||||||
class DevControlCommand : public CommandAbstract {
|
class DevControlCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit DevControlCommand(uint64_t target_address = 0, uint64_t router_address = 0);
|
explicit DevControlCommand(uint64_t target_address = 0, uint64_t router_address = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void udpateCRC(uint8_t len);
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue
Block a user