Library for handling subset of coap functionality by radio transmitter.
Dependencies: nRF24L01P cantcoap
Diff: coapServer.h
- Revision:
- 4:9f635ab44d8e
- Parent:
- 2:c3ca8b8526e0
--- a/coapServer.h Sun Jan 20 23:28:23 2019 +0000 +++ b/coapServer.h Mon Jan 21 18:52:22 2019 +0000 @@ -8,6 +8,7 @@ #include "cantcoap.h" #include "radioWrapper.h" #include <string> +#include <vector> class CoapServer { public: @@ -16,7 +17,8 @@ SMALL_BUFFER = -3, RADIO_NOT_WORKING = -4, UNKNOWN_URI = -5, - COAP_ERROR = -5 + COAP_ERROR = -6, + SILENT = -7 }; enum METHOD { @@ -25,8 +27,10 @@ }; private: - uint16_t lastMessageId; - uint8_t lastMessageToken[1]; + unsigned queueMax; + int lastMessageIndex; + std::vector<uint16_t> idQ; + std::vector<uint8_t> tokenQ; int listeningTimeout; RadioWrapper radioWrapper; int urisNumber; @@ -34,15 +38,17 @@ public: - CoapServer(int timeout, std::string* uris, int urisNumber, int channel, unsigned long long rx_address, - unsigned long long tx_address); + CoapServer(unsigned queueMax, int timeout, std::string* uris, int urisNumber, int channel, + unsigned long long tx_address, unsigned long long rx_addresses[]); - int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber); + + int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber, int* pipe); - int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode); + int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode, int pipe); - void prepareAckPDU(CoapPDU& coapPDU); - +private: + int ackRepeatedPost(CoapPDU& request, int pipe); + int nextIndex(); };