-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathRestServer.h
More file actions
45 lines (35 loc) · 920 Bytes
/
RestServer.h
File metadata and controls
45 lines (35 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef restserver_h
#define restserver_h
// Include Arduino header
#include "Arduino.h"
#include "Log.h"
#include <UIPEthernet.h>
#include "RestSettings.h"
struct Routes {
char * method;
char * name;
void (*callback)(char * params);
};
class RestServer {
public:
RestServer(EthernetServer& client);
void run();
void addRoute(char * method, char * route, void (*f)(char *));
void addData(char* name, String& value);
void addData(char* name, uint16_t value);
void addData(char* name, int value);
void addData(char* name, float value);
void addData(char* name, char* value);
private:
Routes routes_[ROUTES_TOTAL];
uint8_t routesIndex_;
char buffer_[OUTPUT_BUFFER_SIZE];
uint16_t bufferIndex_;
EthernetServer& server_;
EthernetClient client_;
void check();
void reset();
void addToBuffer(char * value);
void send(uint8_t chunkSize, uint8_t delayTime);
};
#endif