Library for handling subset of coap functionality by radio transmitter.
Dependencies: nRF24L01P cantcoap
coapServer.h@1:1d936c763440, 2019-01-20 (annotated)
- Committer:
- Ka_myk
- Date:
- Sun Jan 20 13:48:02 2019 +0000
- Revision:
- 1:1d936c763440
- Parent:
- 0:6a6f97ca5572
- Child:
- 2:c3ca8b8526e0
try to make it work;
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 | 0:6a6f97ca5572 | 11 | |
Ka_myk | 0:6a6f97ca5572 | 12 | class CoapServer { |
Ka_myk | 0:6a6f97ca5572 | 13 | public: |
Ka_myk | 0:6a6f97ca5572 | 14 | |
Ka_myk | 0:6a6f97ca5572 | 15 | enum ERROR { |
Ka_myk | 0:6a6f97ca5572 | 16 | SMALL_BUFFER = -3, |
Ka_myk | 0:6a6f97ca5572 | 17 | RADIO_NOT_WORKING = -4, |
Ka_myk | 0:6a6f97ca5572 | 18 | UNKNOWN_URI = -5 |
Ka_myk | 0:6a6f97ca5572 | 19 | }; |
Ka_myk | 0:6a6f97ca5572 | 20 | |
Ka_myk | 0:6a6f97ca5572 | 21 | enum METHOD { |
Ka_myk | 0:6a6f97ca5572 | 22 | GET = 1, |
Ka_myk | 0:6a6f97ca5572 | 23 | POST = 2 |
Ka_myk | 0:6a6f97ca5572 | 24 | }; |
Ka_myk | 0:6a6f97ca5572 | 25 | |
Ka_myk | 0:6a6f97ca5572 | 26 | private: |
Ka_myk | 0:6a6f97ca5572 | 27 | uint16_t lastMessageId; |
Ka_myk | 0:6a6f97ca5572 | 28 | uint8_t lastMessageToken[4]; |
Ka_myk | 0:6a6f97ca5572 | 29 | int listeningTimeout; |
Ka_myk | 1:1d936c763440 | 30 | RadioWrapper radioWrapper; |
Ka_myk | 1:1d936c763440 | 31 | int urisNumber; |
Ka_myk | 1:1d936c763440 | 32 | std::string *uris; |
Ka_myk | 0:6a6f97ca5572 | 33 | |
Ka_myk | 0:6a6f97ca5572 | 34 | |
Ka_myk | 0:6a6f97ca5572 | 35 | public: |
Ka_myk | 1:1d936c763440 | 36 | CoapServer(int timeout, std::string* uris, int urisNumber, int channel, unsigned long long rx_address, unsigned long long tx_address); |
Ka_myk | 1:1d936c763440 | 37 | |
Ka_myk | 0:6a6f97ca5572 | 38 | int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber); |
Ka_myk | 1:1d936c763440 | 39 | |
Ka_myk | 0:6a6f97ca5572 | 40 | int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode); |
Ka_myk | 0:6a6f97ca5572 | 41 | |
Ka_myk | 0:6a6f97ca5572 | 42 | void prepareAckPDU(CoapPDU& coapPDU); |
Ka_myk | 0:6a6f97ca5572 | 43 | |
Ka_myk | 0:6a6f97ca5572 | 44 | |
Ka_myk | 0:6a6f97ca5572 | 45 | }; |
Ka_myk | 0:6a6f97ca5572 | 46 | |
Ka_myk | 1:1d936c763440 | 47 | #endif //SLAVE_COAPSERVER_H |