Library for handling subset of coap functionality by radio transmitter.

Dependencies:   nRF24L01P cantcoap

Dependents:   server2

Committer:
Ka_myk
Date:
Sun Jan 20 23:27:10 2019 +0000
Revision:
2:c3ca8b8526e0
Parent:
1:1d936c763440
Child:
4:9f635ab44d8e
should work somehow;

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 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 2:c3ca8b8526e0 18 UNKNOWN_URI = -5,
Ka_myk 2:c3ca8b8526e0 19 COAP_ERROR = -5
Ka_myk 0:6a6f97ca5572 20 };
Ka_myk 0:6a6f97ca5572 21
Ka_myk 0:6a6f97ca5572 22 enum METHOD {
Ka_myk 0:6a6f97ca5572 23 GET = 1,
Ka_myk 0:6a6f97ca5572 24 POST = 2
Ka_myk 0:6a6f97ca5572 25 };
Ka_myk 0:6a6f97ca5572 26
Ka_myk 0:6a6f97ca5572 27 private:
Ka_myk 0:6a6f97ca5572 28 uint16_t lastMessageId;
Ka_myk 2:c3ca8b8526e0 29 uint8_t lastMessageToken[1];
Ka_myk 0:6a6f97ca5572 30 int listeningTimeout;
Ka_myk 1:1d936c763440 31 RadioWrapper radioWrapper;
Ka_myk 1:1d936c763440 32 int urisNumber;
Ka_myk 2:c3ca8b8526e0 33 std::string* uris;
Ka_myk 0:6a6f97ca5572 34
Ka_myk 0:6a6f97ca5572 35
Ka_myk 0:6a6f97ca5572 36 public:
Ka_myk 2:c3ca8b8526e0 37 CoapServer(int timeout, std::string* uris, int urisNumber, int channel, unsigned long long rx_address,
Ka_myk 2:c3ca8b8526e0 38 unsigned long long tx_address);
Ka_myk 1:1d936c763440 39
Ka_myk 0:6a6f97ca5572 40 int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber);
Ka_myk 1:1d936c763440 41
Ka_myk 0:6a6f97ca5572 42 int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode);
Ka_myk 0:6a6f97ca5572 43
Ka_myk 0:6a6f97ca5572 44 void prepareAckPDU(CoapPDU& coapPDU);
Ka_myk 0:6a6f97ca5572 45
Ka_myk 0:6a6f97ca5572 46
Ka_myk 0:6a6f97ca5572 47 };
Ka_myk 0:6a6f97ca5572 48
Ka_myk 1:1d936c763440 49 #endif //SLAVE_COAPSERVER_H