IOT_GRZYBKI / coapRadio

Dependencies:   nRF24L01P cantcoap

Dependents:   server2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers coapServer.h Source File

coapServer.h

00001 //
00002 // Created by Kamil Mykitiuk on 2019-01-18.
00003 //
00004 
00005 #ifndef SLAVE_COAPSERVER_H
00006 #define SLAVE_COAPSERVER_H
00007 
00008 #include "cantcoap.h"
00009 #include "radioWrapper.h"
00010 #include <string>
00011 #include <vector>
00012 
00013 class CoapServer {
00014 public:
00015 
00016     enum ERROR {
00017         SMALL_BUFFER = -3,
00018         RADIO_NOT_WORKING = -4,
00019         UNKNOWN_URI = -5,
00020         COAP_ERROR = -6,
00021         SILENT = -7
00022     };
00023 
00024     enum METHOD {
00025         GET = 1,
00026         POST = 2
00027     };
00028 
00029 private:
00030     unsigned queueMax;
00031     int lastMessageIndex;
00032     std::vector<uint16_t> idQ;
00033     std::vector<uint8_t>  tokenQ;
00034     int listeningTimeout;
00035     RadioWrapper radioWrapper;
00036     int urisNumber;
00037     std::string* uris;
00038 
00039 
00040 public:
00041     CoapServer(unsigned queueMax, int timeout, std::string* uris, int urisNumber, int channel,
00042                        unsigned long long tx_address, unsigned long long rx_addresses[]);
00043 
00044 
00045     int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber, int* pipe);
00046 
00047     int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode, int pipe);
00048 
00049 private:
00050     int ackRepeatedPost(CoapPDU& request, int pipe);
00051     int nextIndex();
00052 
00053 };
00054 
00055 #endif //SLAVE_COAPSERVER_H