Senet Packet API
Dependents: MTDOT-UDKDemo_Senet Senet NAMote mDot-IKS01A1 unh-hackathon-example ... more
Diff: senet_packet.h
- Revision:
- 2:9c971be7692b
- Parent:
- 0:cc9f4010bba6
- Child:
- 3:b6823438e893
--- a/senet_packet.h Tue Mar 08 09:08:44 2016 -0500 +++ b/senet_packet.h Mon May 23 14:09:52 2016 -0400 @@ -56,6 +56,15 @@ */ int32_t serialize(); + /* + *-------------------------------------------------------------------------------------- + * Class: SenetPacket + * Method: deserialize + * Description: Packet deserializer + *-------------------------------------------------------------------------------------- + */ + int32_t deserialize(uint8_t *frame, int32_t len); + inline const uint8_t* payload() { return buffer;} uint8_t length () { return pktLen; } @@ -75,7 +84,7 @@ } int32_t serialize (uint8_t *frame, int32_t len); - bool deserialize(uint8_t *frame, int32_t len); + int32_t deserialize(uint8_t *frame, int32_t len); } header; uint8_t pktLen; @@ -95,6 +104,15 @@ */ virtual int32_t serializePayload(uint8_t *frame, int32_t len) = 0; + /* + *-------------------------------------------------------------------------------------- + * Class: SenetPacket + * Method: deserializePayload + * Description: Derived packet types can implement this to deserialize + *-------------------------------------------------------------------------------------- + */ + virtual int32_t deserializePayload(uint8_t *frame, int32_t len) {return 0;} + }; @@ -106,11 +124,12 @@ */ struct BootInfoPacket : public SenetPacket { - static const uint8_t BOOT_PAYLOAD_LENGTH = 8; + static const uint8_t BOOT_PAYLOAD_LENGTH = 9; uint16_t bootCount; // number of device boots uint16_t resetCount; // number of device resets uint32_t lastBootReason; // last boot reason + uint8_t authKey; BootInfoPacket(uint8_t *_buffer=NULL, uint8_t _buflen=0) : SenetPacket(BOOT_INFO_PACKET, _buffer, _buflen) @@ -118,6 +137,7 @@ bootCount = 0; resetCount = 0; lastBootReason = 0; + authKey = 0; } protected: @@ -129,12 +149,21 @@ *-------------------------------------------------------------------------------------- */ virtual int32_t serializePayload(uint8_t *frame, int32_t len); + + /* + *-------------------------------------------------------------------------------------- + * Class: BootInfoPacket + * Method: deserializePayload + * Description: Deserialize packet data + *-------------------------------------------------------------------------------------- + */ + virtual int32_t deserializePayload(uint8_t *frame, int32_t len); }; /* * ===================================================================================== - * Class: ControlWordPacket + * Class: ConfigWordPacket * Description: Packet to configure device * ===================================================================================== */ @@ -157,6 +186,15 @@ *-------------------------------------------------------------------------------------- */ virtual int32_t serializePayload(uint8_t *frame, int32_t len); + + /* + *-------------------------------------------------------------------------------------- + * Class: ConfigWordPacket + * Method: deserializePayload + * Description: Deserialize packet data + *-------------------------------------------------------------------------------------- + */ + virtual int32_t deserializePayload(uint8_t *frame, int32_t len); }; @@ -170,7 +208,7 @@ { static const uint8_t GPS_PAYLOAD_LENGTH = 9; - bool setCoordinates(uint32_t latitude, uint32_t longitude, uint16_t elevation); + bool setCoordinates(int32_t latitude, int32_t longitude, uint16_t elevation); inline void setTxPower(uint8_t dBm) { txPower = dBm; } @@ -227,7 +265,7 @@ */ struct RFDataPacket : public SenetPacket { - static const uint8_t RFDATA_PAYLOAD_LEN = 8; + static const uint8_t RFDATA_PAYLOAD_LEN = 9; uint8_t channel; // The channel the device sent on uint8_t txpower; // The transmit power in dBm used by the device @@ -270,7 +308,7 @@ const static uint8_t EXT_POWER_SUPPLY_1 = 1; const static uint8_t EXT_POWER_SUPPLY_2 = 2; const static uint8_t BATTERY_LEVEL_MAX = 7; - const static uint8_t SELFID_PAYLOAD_LEN = 8; + const static uint8_t SELFID_PAYLOAD_LEN = 9; bool setDeviceType (uint32_t model, uint8_t revision); bool setSwVersion (uint8_t major, uint8_t minor, uint8_t point, uint16_t build, uint8_t developer);