Library for handling subset of coap functionality by radio transmitter.
Dependencies: nRF24L01P cantcoap
coapServer.h@4:9f635ab44d8e, 2019-01-21 (annotated)
- Committer:
- Ka_myk
- Date:
- Mon Jan 21 18:52:22 2019 +0000
- Revision:
- 4:9f635ab44d8e
- Parent:
- 2:c3ca8b8526e0
hope it works;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ka_myk | 0:6a6f97ca5572 | 1 | // |
Ka_myk | 0:6a6f97ca5572 | 2 | // Created by Kamil Mykitiuk on 2019-01-18. |
Ka_myk | 0:6a6f97ca5572 | 3 | // |
Ka_myk | 0:6a6f97ca5572 | 4 | |
Ka_myk | 1:1d936c763440 | 5 | #ifndef SLAVE_COAPSERVER_H |
Ka_myk | 1:1d936c763440 | 6 | #define SLAVE_COAPSERVER_H |
Ka_myk | 0:6a6f97ca5572 | 7 | |
Ka_myk | 0:6a6f97ca5572 | 8 | #include "cantcoap.h" |
Ka_myk | 0:6a6f97ca5572 | 9 | #include "radioWrapper.h" |
Ka_myk | 0:6a6f97ca5572 | 10 | #include <string> |
Ka_myk | 4:9f635ab44d8e | 11 | #include <vector> |
Ka_myk | 0:6a6f97ca5572 | 12 | |
Ka_myk | 0:6a6f97ca5572 | 13 | class CoapServer { |
Ka_myk | 0:6a6f97ca5572 | 14 | public: |
Ka_myk | 0:6a6f97ca5572 | 15 | |
Ka_myk | 0:6a6f97ca5572 | 16 | enum ERROR { |
Ka_myk | 0:6a6f97ca5572 | 17 | SMALL_BUFFER = -3, |
Ka_myk | 0:6a6f97ca5572 | 18 | RADIO_NOT_WORKING = -4, |
Ka_myk | 2:c3ca8b8526e0 | 19 | UNKNOWN_URI = -5, |
Ka_myk | 4:9f635ab44d8e | 20 | COAP_ERROR = -6, |
Ka_myk | 4:9f635ab44d8e | 21 | SILENT = -7 |
Ka_myk | 0:6a6f97ca5572 | 22 | }; |
Ka_myk | 0:6a6f97ca5572 | 23 | |
Ka_myk | 0:6a6f97ca5572 | 24 | enum METHOD { |
Ka_myk | 0:6a6f97ca5572 | 25 | GET = 1, |
Ka_myk | 0:6a6f97ca5572 | 26 | POST = 2 |
Ka_myk | 0:6a6f97ca5572 | 27 | }; |
Ka_myk | 0:6a6f97ca5572 | 28 | |
Ka_myk | 0:6a6f97ca5572 | 29 | private: |
Ka_myk | 4:9f635ab44d8e | 30 | unsigned queueMax; |
Ka_myk | 4:9f635ab44d8e | 31 | int lastMessageIndex; |
Ka_myk | 4:9f635ab44d8e | 32 | std::vector<uint16_t> idQ; |
Ka_myk | 4:9f635ab44d8e | 33 | std::vector<uint8_t> tokenQ; |
Ka_myk | 0:6a6f97ca5572 | 34 | int listeningTimeout; |
Ka_myk | 1:1d936c763440 | 35 | RadioWrapper radioWrapper; |
Ka_myk | 1:1d936c763440 | 36 | int urisNumber; |
Ka_myk | 2:c3ca8b8526e0 | 37 | std::string* uris; |
Ka_myk | 0:6a6f97ca5572 | 38 | |
Ka_myk | 0:6a6f97ca5572 | 39 | |
Ka_myk | 0:6a6f97ca5572 | 40 | public: |
Ka_myk | 4:9f635ab44d8e | 41 | CoapServer(unsigned queueMax, int timeout, std::string* uris, int urisNumber, int channel, |
Ka_myk | 4:9f635ab44d8e | 42 | unsigned long long tx_address, unsigned long long rx_addresses[]); |
Ka_myk | 1:1d936c763440 | 43 | |
Ka_myk | 4:9f635ab44d8e | 44 | |
Ka_myk | 4:9f635ab44d8e | 45 | int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber, int* pipe); |
Ka_myk | 1:1d936c763440 | 46 | |
Ka_myk | 4:9f635ab44d8e | 47 | int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode, int pipe); |
Ka_myk | 0:6a6f97ca5572 | 48 | |
Ka_myk | 4:9f635ab44d8e | 49 | private: |
Ka_myk | 4:9f635ab44d8e | 50 | int ackRepeatedPost(CoapPDU& request, int pipe); |
Ka_myk | 4:9f635ab44d8e | 51 | int nextIndex(); |
Ka_myk | 0:6a6f97ca5572 | 52 | |
Ka_myk | 0:6a6f97ca5572 | 53 | }; |
Ka_myk | 0:6a6f97ca5572 | 54 | |
Ka_myk | 1:1d936c763440 | 55 | #endif //SLAVE_COAPSERVER_H |