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:
24 pfodRadioMsg();
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);
35 size_t getMaxMsgBufferSize();
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
pfodRadioMsg for Arduino Holds a radio msg
Definition: pfodRadioMsg.h:22
pfodRadioMsg::getReceivedFrom
uint8_t getReceivedFrom()
pfodRadioMsg::isNewMsg
bool isNewMsg(uint8_t _thisAddress, uint8_t _targetAddress, uint8_t _expectedMsgSeqNo, bool isServer)
pfodRadioMsg::isNewConnectionRequest
bool isNewConnectionRequest(uint8_t ourAddress)
pfodRadioMsg::isAckFor
bool isAckFor(pfodRadioMsg *lastRadioMsg)
pfodRadioMsg::ackedMsgSeqNo
uint8_t ackedMsgSeqNo
Definition: pfodRadioMsg.h:50
pfodRadioMsg::getLen
uint8_t getLen()
pfodRadioMsg::receivedFrom
uint8_t receivedFrom
Definition: pfodRadioMsg.h:49
pfodRadioMsg::pfodRadioMsg
pfodRadioMsg()
pfodRadioMsg::saveMsg
size_t saveMsg(uint8_t *_buf, uint8_t _len, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo)
pfodRadioMsg::setAckedMsgSeqNo
void setAckedMsgSeqNo(uint8_t _ackedMsgSeqNo)
pfodRadioMsg::addressedTo
uint8_t addressedTo
Definition: pfodRadioMsg.h:48
pfodRadioMsg::BUFFER_SIZE
static const size_t BUFFER_SIZE
Definition: pfodRadioMsg.h:44
pfodRadioMsg::isPureAckFor
bool isPureAckFor(uint8_t msgSeqNoWaitingForAck)
pfodRadioMsg::isPureAck
bool isPureAck()
pfodRadioMsg::getAddressedTo
uint8_t getAddressedTo()
pfodRadioMsg::getAckedMsgSeqNo
uint8_t getAckedMsgSeqNo()
pfodRadioMsg::isResendRequest
bool isResendRequest(pfodRadioMsg *lastRadioMsg)
pfodRadioMsg::getMaxMsgBufferSize
size_t getMaxMsgBufferSize()
pfodRadioMsg::getBuf
uint8_t * getBuf()
pfodRadioMsg::getMsgSeqNo
uint8_t getMsgSeqNo()
pfodRadioMsg::msgBuf
uint8_t msgBuf[BUFFER_SIZE]
Definition: pfodRadioMsg.h:47
pfodRadioMsg::maxMsgLen
size_t maxMsgLen
Definition: pfodRadioMsg.h:45
pfodRadioMsg::saveMsg
size_t saveMsg(Stream *_txBufPtr, uint8_t _addressedTo, uint8_t _receievedFrom, uint8_t _msgSeqNo, uint8_t _ackedMsgSeqNo)
pfodRadioMsg::msgSeqNo
uint8_t msgSeqNo
Definition: pfodRadioMsg.h:51
pfodRadioMsg::init
void init(size_t _maxMsgLen)
pfodRadioMsg::msgLen
size_t msgLen
Definition: pfodRadioMsg.h:46
pfodStream.h