Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
CommProtocolPeerBrute Class Reference
This class implements a peer-to-peer (P2P) brute force protocol. More...
#include <CommProtocolPeerBrute.h>
Public Member Functions | |
CommProtocolPeerBrute () | |
CommProtocolPeerBrute constructor. | |
CmdResult | init () |
Attempts to read values from NVM (xDot's eeprom) if failure saves defaults. | |
CmdResult | configForSavedNetwork () |
Initialize radio with stored network network settings. | |
void | setTx (bool isTx) |
Sets weather this object is configured as a TX or RX. | |
bool | isTx () |
Returns weather this object is configured as a TX or RX. | |
bool | isRx () |
Returns weather this object is configured as a TX or RX. | |
CmdResult | clearPair () |
This will clear the security pairs and channel info for pair. | |
uint32_t | getSeqNum () |
Accessor sequence number. | |
CmdResult | send (const std::vector< uint8_t > &msg) |
Transmit the msg attached. | |
CmdResult | sendAlert (uint16_t data) |
Transmit an alert per documentation. | |
CmdResult | sendPairReq () |
This function sends a request to pair with a RX. | |
CmdResult | listen (bool &msgPending) |
This function enables the RX hardware of a radio. | |
CmdResult | recv (std::vector< uint8_t > &msg) |
Returns the last message received via listening. | |
CmdResult | recvAlert (std::vector< uint8_t > &eui, uint16_t &data, uint32_t &seqNum) |
Attempts to parse and return the last message received. | |
CmdResult | waitForPairing (float waitTime) |
This function enables the radio to listen for pair requests. | |
CmdResult | sendPairAccepted () |
Send a pair accept message. | |
CmdResult | waitForAccept (float waitTime) |
uint32_t | getDLC () |
Convenience function to get the internal downlink count from radio. | |
uint32_t | getULC () |
Convenience function to get the internal uplink count from radio. | |
CmdResult | resetCounters () |
Resets both uplink and downlink counters (1 and 0 respectively). |
Detailed Description
This class implements a peer-to-peer (P2P) 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.
The following should be implemented outside of the class:
- Power settings?
- What to do with the msgs which are received
- When to send messages
- When to sleep
Definition at line 173 of file CommProtocolPeerBrute.h.
Constructor & Destructor Documentation
CommProtocolPeerBrute constructor.
Just initialized internal variables does not configure devices. Should call init before other functions are called.
On Entry:
On Exit: Internal variables are set to a known state but further initialization is required
- Returns:
Definition at line 22 of file CommProtocolPeerBrute.cpp.
Member Function Documentation
CmdResult clearPair | ( | ) |
This will clear the security pairs and channel info for pair.
This will clear both the value in RAM as well as the value stored in EEPROM for security and clarity purposes. If RX this command will automatically trigger the generation of new security keys and pair specific parameters.
- Returns:
- Returns status of all commands completed
Definition at line 199 of file CommProtocolPeerBrute.cpp.
CmdResult configForSavedNetwork | ( | ) |
Initialize radio with stored network network settings.
- Returns:
- Returns the result of all the radio commands
Definition at line 52 of file CommProtocolPeerBrute.cpp.
uint32_t getDLC | ( | ) |
Convenience function to get the internal downlink count from radio.
- Returns:
- Number of downlink msgs
Definition at line 470 of file CommProtocolPeerBrute.cpp.
uint32_t getSeqNum | ( | ) |
Accessor sequence number.
- Returns:
- Integer value
Definition at line 235 of file CommProtocolPeerBrute.cpp.
uint32_t getULC | ( | ) |
Convenience function to get the internal uplink count from radio.
- Returns:
- Number of uplink msgs
Definition at line 475 of file CommProtocolPeerBrute.cpp.
CmdResult init | ( | ) |
Attempts to read values from NVM (xDot's eeprom) if failure saves defaults.
Then configures radio with settings.
- Returns:
- Success unless radio configuration error
Definition at line 29 of file CommProtocolPeerBrute.cpp.
bool isRx | ( | ) |
Returns weather this object is configured as a TX or RX.
- Returns:
- Returns true if RX
Definition at line 222 of file CommProtocolPeerBrute.h.
bool isTx | ( | ) |
Returns weather this object is configured as a TX or RX.
- Returns:
- Returns true if TX
Definition at line 195 of file CommProtocolPeerBrute.cpp.
CmdResult listen | ( | bool & | msgPending ) |
This function enables the RX hardware of a radio.
Note the listen time is defined internally by the protocol
- Parameters:
-
msgPending This boolean is return by reference. If true then during the listen window a msg was received.
- Returns:
- Returns status of all commands completed
Definition at line 297 of file CommProtocolPeerBrute.cpp.
CmdResult recv | ( | std::vector< uint8_t > & | msg ) |
Returns the last message received via listening.
- Parameters:
-
msg This STL vector of uint8_t is returned by reference with msg contents.
- Returns:
- Returns status of all commands completed
Definition at line 318 of file CommProtocolPeerBrute.cpp.
CmdResult recvAlert | ( | std::vector< uint8_t > & | eui, |
uint16_t & | data, | ||
uint32_t & | seqNum | ||
) |
Attempts to parse and return the last message received.
If the message is too short or if the flag is not correct will return an error.
- Parameters:
-
eui 4 byte value returned data Data field from alert message seqNum Transmitter's sequence number
- Returns:
- Returns status of all commands completed
Definition at line 324 of file CommProtocolPeerBrute.cpp.
CmdResult resetCounters | ( | ) |
Resets both uplink and downlink counters (1 and 0 respectively).
- Returns:
Definition at line 518 of file CommProtocolPeerBrute.cpp.
CmdResult send | ( | const std::vector< uint8_t > & | msg ) |
Transmit the msg attached.
TODO figure out what information is wrapped by the LoRaWAN stuff implemented by Multitech Systems
- Parameters:
-
msg A STL vector of uint8_t
- Returns:
- Returns status of all commands completed
Definition at line 239 of file CommProtocolPeerBrute.cpp.
CmdResult sendAlert | ( | uint16_t | data ) |
Transmit an alert per documentation.
Sends EUI, uint16 data, alert seqNum
- Parameters:
-
data Input data to send
- Returns:
- if transmission is successful (note no ACK checked)
Definition at line 252 of file CommProtocolPeerBrute.cpp.
CmdResult sendPairAccepted | ( | ) |
Send a pair accept message.
This message contains all the information for TX to properly send msgs to RX in P2P mode.
- Returns:
- Returns status of all commands completed
Definition at line 379 of file CommProtocolPeerBrute.cpp.
CmdResult sendPairReq | ( | ) |
This function sends a request to pair with a RX.
If successful a pair accept message is received.
- Returns:
- Returns status of all commands completed
Definition at line 274 of file CommProtocolPeerBrute.cpp.
void setTx | ( | bool | isTx ) |
Sets weather this object is configured as a TX or RX.
- Parameters:
-
isTx if true then configured as transmitter if false then configured as receiver.
Definition at line 191 of file CommProtocolPeerBrute.cpp.
CmdResult waitForAccept | ( | float | waitTime ) |
CmdResult waitForPairing | ( | float | waitTime ) |
This function enables the radio to listen for pair requests.
- Parameters:
-
waitTime The maximum time which radio waits for pair requests
TODO determine if it is important to know who is paired
- Returns:
- If pair message received then cmdSucess is returned otherwise timeout is returned.
Definition at line 349 of file CommProtocolPeerBrute.cpp.
Generated on Fri Jul 15 2022 14:36:45 by 1.7.2