Library for handling subset of coap functionality by radio transmitter.

Dependencies:   nRF24L01P cantcoap

Dependents:   server2

coapServer.h

Committer:
Ka_myk
Date:
2019-01-18
Revision:
0:6a6f97ca5572
Child:
1:1d936c763440

File content as of revision 0:6a6f97ca5572:

//
// Created by Kamil Mykitiuk on 2019-01-18.
//

#ifndef COAPSERVER_H
#define COAPSERVER_H

#include "cantcoap.h"
#include "radioWrapper.h"
#include <string>

class CoapServer {
public:

    enum ERROR {
        SERVER_RESPONSE_AMBIGOUS = -1,
        SERVER_TIMED_OUT = -2,
        SMALL_BUFFER = -3,
        RADIO_NOT_WORKING = -4,
        UNKNOWN_URI = -5
    };

    enum METHOD {
        GET = 1,
        POST = 2
    };

private:
    RadioWrapper radioWrapper;
    uint16_t lastMessageId;
    uint8_t lastMessageToken[4];
    int listeningTimeout;
    std::string **uris;


public:
    int listen(uint8_t* buffer, int len, METHOD* requestMethod, int* uriNumber);
    int respond(int uri, uint8_t* buffer, int len, CoapPDU::Code responseCode);

    int urisNumber();

    void prepareAckPDU(CoapPDU& coapPDU);


};

#endif //COAPSERVER_H