pfodParser  3.61.0
The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections
pfodRadioMsg.h
Go to the documentation of this file.
1 
2 #ifndef pfodRadioMsg_h
3 #define pfodRadioMsg_h
8 /*
9  (c)2014-2018 Forward Computing and Control Pty. Ltd.
10  NSW Australia, www.forward.com.au
11  This code is not warranted to be fit for any purpose. You may only use it at your own risk.
12  This code may be freely used for both private and commercial use
13  Provide this copyright is maintained.
14 */
15 
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <string.h>
19 #include "pfodStream.h"
20 
21 
22 class pfodRadioMsg {
23  public:
25  void init(size_t _maxMsgLen); // actual datasize i.e. excludes header
26  size_t saveMsg(uint8_t *_buf, uint8_t _len, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo);
27  size_t saveMsg(Stream* _txBufPtr, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo);
28  uint8_t getLen();
29  uint8_t* getBuf();
30  uint8_t getAddressedTo();
31  uint8_t getReceivedFrom();
32  uint8_t getMsgSeqNo();
33  uint8_t getAckedMsgSeqNo();
34  void setAckedMsgSeqNo(uint8_t _ackedMsgSeqNo);
36  bool isPureAck();
37  bool isAckFor(pfodRadioMsg* lastRadioMsg); // i.e. ackedMsgSeqNo == msgSeqNoAwaitinAck
38  bool isResendRequest(pfodRadioMsg* lastRadioMsg); // i.e. is msgSeqNo < _expectedMsgSeqNo i.e. ((_expectedMsgSeqNo - msgSeqNo) > 128)
39  bool isNewMsg(uint8_t _thisAddress, uint8_t _targetAddress, uint8_t _expectedMsgSeqNo, bool isServer); // i.e. (msgSeqNo = _expectedMsgSeqNo) && (!( (len =1) && (buf[0] == '\0') && (msgSeqNo == 0))) (note pure acks have msgSeqNo == 0)
40  // OR (msgSeqNo == 0) && (! ((len =1) && buf[0] == '\0'))) => new connect request
41  bool isNewConnectionRequest(uint8_t ourAddress); //
42  protected:
43 
44  static const size_t BUFFER_SIZE = 255;
45  size_t maxMsgLen; // set by driver and limited to BUFFER_SIZE above
46  size_t msgLen; // includes null if any
47  uint8_t msgBuf[BUFFER_SIZE];
48  uint8_t addressedTo;
49  uint8_t receivedFrom;
50  uint8_t ackedMsgSeqNo;
51  uint8_t msgSeqNo;
52 
53  bool isPureAckFor(uint8_t msgSeqNoWaitingForAck);
54 };
55 
56 #endif // pfodRadioMsg_h
pfodRadioMsg for Arduino Holds a radio msg
Definition: pfodRadioMsg.h:22
uint8_t getReceivedFrom()
bool isNewMsg(uint8_t _thisAddress, uint8_t _targetAddress, uint8_t _expectedMsgSeqNo, bool isServer)
bool isNewConnectionRequest(uint8_t ourAddress)
bool isAckFor(pfodRadioMsg *lastRadioMsg)
uint8_t ackedMsgSeqNo
Definition: pfodRadioMsg.h:50
uint8_t getLen()
uint8_t receivedFrom
Definition: pfodRadioMsg.h:49
size_t saveMsg(uint8_t *_buf, uint8_t _len, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo)
void setAckedMsgSeqNo(uint8_t _ackedMsgSeqNo)
uint8_t addressedTo
Definition: pfodRadioMsg.h:48
static const size_t BUFFER_SIZE
Definition: pfodRadioMsg.h:44
bool isPureAckFor(uint8_t msgSeqNoWaitingForAck)
bool isPureAck()
uint8_t getAddressedTo()
uint8_t getAckedMsgSeqNo()
bool isResendRequest(pfodRadioMsg *lastRadioMsg)
size_t getMaxMsgBufferSize()
uint8_t * getBuf()
uint8_t getMsgSeqNo()
uint8_t msgBuf[BUFFER_SIZE]
Definition: pfodRadioMsg.h:47
size_t maxMsgLen
Definition: pfodRadioMsg.h:45
size_t saveMsg(Stream *_txBufPtr, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo)
uint8_t msgSeqNo
Definition: pfodRadioMsg.h:51
void init(size_t _maxMsgLen)
size_t msgLen
Definition: pfodRadioMsg.h:46