![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
xDotBridge/inc/CommProtocolPeerBrute.h
- Committer:
- Matt Briggs
- Date:
- 2017-01-26
- Revision:
- 40:2ec4be320961
- Child:
- 41:9ef4c4d77711
File content as of revision 40:2ec4be320961:
/** * Library for LoRa Peer to Peer Brute Force Protocol */ #ifndef PEERBRUTECOMMPROTOCOL_H_ #define PEERBRUTECOMMPROTOCOL_H_ #include "../config.h" // TODO make base class to allow different protocols to be used with easy static uint8_t pair_network_address[] = { 0x01, 0x02, 0x03, 0x04 }; static uint8_t pair_network_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; static uint8_t pair_data_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; /** * @class PeerBruteCommProtocol * @brief This class implements a peer brute force protocol. The protocol * consists of at a minimum one transmitter (TX) and one receiver (RX) which * communicate via the 900MHz LoRa modulation. The concept is that the RX is * cycling on and off thus only listening for a small period of time. Since * we are not relying on a common time-base or other synchronization mechanism * the TX simply transmits for a duration long enough guarantee that the RX will * have at least one receive window during that time period. Hence the name * brute since the TX is just transmitting plenty for the RX to hear it. */ class PeerBruteCommProtocol { public: PeerBruteCommProtocol(bool isTx); void init(); bool isTx(); bool isRx() {return !isTx();} uint32_t getDLC(); uint32_t getULC(); CmdResult clearPair(); // TX focused CmdResult send (const std::vector<uint8_t> &msg); CmdResult sendPairReq(); // RX focused CmdResult listen (bool &msgPending); CmdResult recv (std::vector<uint8_t> &msg); CmdResult waitForPairing(float waitTime); private: uint8_t mNetworkAddr[4]; uint8_t pair_network_session_key[16]; uint8_t pair_data_session_key[16]; bool mIsTx; /** * @brief Reads baseboard information from non-volatile memory (NVM) * * @details This data is read from the xDot's internal EEPROM. This * method is called from init(). The following * is stored: * 1. Peer Brute Storage code word * 2. 8-bit protocol version * 3. 16-bit Baseboard serial number * 4. 4 Byte network address * 5. 16 Byte network session key * 6. 16 Byte data session key * 7. 4 Byte DLC * 8. 4 Byte ULC * * TODO add memory map information * * @return CmdResult */ CmdResult readInfoFromNVM(); /** * @brief Stores baseboard information to non-volatile memory (NVM) * * @details This method is called during special configuration events like first time boot or factory reset. * * TODO add memory map information * * @return CmdResult */ CmdResult writeInfoToNVM(); CmdResult resetCounters(); CmdResult genEncypKeys(); }; #endif