Library for handling subset of coap functionality by radio transmitter.

Dependencies:   nRF24L01P cantcoap

Dependents:   server2

Committer:
Ka_myk
Date:
Fri Jan 18 14:12:24 2019 +0000
Revision:
0:6a6f97ca5572
Child:
1:1d936c763440
initial version

Who changed what in which revision?

UserRevisionLine numberNew 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 0:6a6f97ca5572 5 #ifndef COAPSERVER_H
Ka_myk 0:6a6f97ca5572 6 #define 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 SERVER_RESPONSE_AMBIGOUS = -1,
Ka_myk 0:6a6f97ca5572 17 SERVER_TIMED_OUT = -2,
Ka_myk 0:6a6f97ca5572 18 SMALL_BUFFER = -3,
Ka_myk 0:6a6f97ca5572 19 RADIO_NOT_WORKING = -4,
Ka_myk 0:6a6f97ca5572 20 UNKNOWN_URI = -5
Ka_myk 0:6a6f97ca5572 21 };
Ka_myk 0:6a6f97ca5572 22
Ka_myk 0:6a6f97ca5572 23 enum METHOD {
Ka_myk 0:6a6f97ca5572 24 GET = 1,
Ka_myk 0:6a6f97ca5572 25 POST = 2
Ka_myk 0:6a6f97ca5572 26 };
Ka_myk 0:6a6f97ca5572 27
Ka_myk 0:6a6f97ca5572 28 private:
Ka_myk 0:6a6f97ca5572 29 RadioWrapper radioWrapper;
Ka_myk 0:6a6f97ca5572 30 uint16_t lastMessageId;
Ka_myk 0:6a6f97ca5572 31 uint8_t lastMessageToken[4];
Ka_myk 0:6a6f97ca5572 32 int listeningTimeout;
Ka_myk 0:6a6f97ca5572 33 std::string **uris;
Ka_myk 0:6a6f97ca5572 34
Ka_myk 0:6a6f97ca5572 35
Ka_myk 0:6a6f97ca5572 36 public:
Ka_myk 0:6a6f97ca5572 37 int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber);
Ka_myk 0:6a6f97ca5572 38 int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode);
Ka_myk 0:6a6f97ca5572 39
Ka_myk 0:6a6f97ca5572 40 int urisNumber();
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 0:6a6f97ca5572 47 #endif //COAPSERVER_H