Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF24L01P cantcoap
Diff: coapServer.h
- Revision:
- 0:6a6f97ca5572
- Child:
- 1:1d936c763440
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/coapServer.h Fri Jan 18 14:12:24 2019 +0000
@@ -0,0 +1,47 @@
+//
+// 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