EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
GatewayAPI.h
Go to the documentation of this file.
1 
9 #ifndef GATEWAY_API_h
10 #define GATEWAY_API_h
11 
12 #include <EnigmaIOTGateway.h>
13 #include <ESPAsyncWebServer.h>
14 
15 #if defined(ARDUINO) && ARDUINO >= 100
16 #include "Arduino.h"
17 #else
18 #include "WProgram.h"
19 #endif
20 
21 const size_t RESPONSE_SIZE = 250;
22 
23 String methodToString (WebRequestMethodComposite method);
24 
25 class GatewayAPI {
26 protected:
27  AsyncWebServer* server;
28  //EnigmaIOTGatewayClass* gateway;
29 
34  void getNodeNumber (AsyncWebServerRequest* request);
35 
40  void getMaxNodes (AsyncWebServerRequest* request);
41 
46  void getNodes (AsyncWebServerRequest* request);
47 
52  void nodeOp (AsyncWebServerRequest* request);
53 
58  void getGwInfo (AsyncWebServerRequest* request);
59 
64  void restartGw (AsyncWebServerRequest* request);
65 
70  void resetGw (AsyncWebServerRequest* request);
71 
72 
77  void restartNode (AsyncWebServerRequest* request);
78  // TODO: Reset node
79  // TODO: Reset Gw
80 
85  void onNotFound (AsyncWebServerRequest* request);
86 
91  Node* getNodeFromParam (AsyncWebServerRequest* request);
92 
98  const char* deleteNode (Node* node, int& resultCode);
99 
107  char* getNodeInfo (Node* node, int& resultCode, char* nodeInfo, size_t len);
108 
114  char* buildGwInfo (char* gwInfo, size_t len);
115 
120  bool restartNodeRequest (Node* node);
121 
122 public:
123 
127  void begin ();
128 };
129 
130 extern GatewayAPI GwAPI;
131 
132 #endif // GATEWAY_API_h
GatewayAPI::onNotFound
void onNotFound(AsyncWebServerRequest *request)
Processes unknown entry points or methods.
Definition: GatewayAPI.cpp:378
GatewayAPI::getMaxNodes
void getMaxNodes(AsyncWebServerRequest *request)
Processes max node number request.
Definition: GatewayAPI.cpp:251
GatewayAPI
Definition: GatewayAPI.h:25
GwAPI
GatewayAPI GwAPI
API instance.
Definition: GatewayAPI.cpp:391
GatewayAPI::getNodeFromParam
Node * getNodeFromParam(AsyncWebServerRequest *request)
Gets node reference from request parameters.
Definition: GatewayAPI.cpp:92
GatewayAPI::resetGw
void resetGw(AsyncWebServerRequest *request)
Processes gateway configuration reset request.
Definition: GatewayAPI.cpp:292
GatewayAPI::restartNodeRequest
bool restartNodeRequest(Node *node)
Sends restart node message.
Definition: GatewayAPI.cpp:194
GatewayAPI::getNodes
void getNodes(AsyncWebServerRequest *request)
Processes node list request.
Definition: GatewayAPI.cpp:325
GatewayAPI::nodeOp
void nodeOp(AsyncWebServerRequest *request)
Processes node information request.
Definition: GatewayAPI.cpp:219
RESPONSE_SIZE
const size_t RESPONSE_SIZE
Maximum API response size.
Definition: GatewayAPI.h:21
GatewayAPI::begin
void begin()
Starts REST API web server.
Definition: GatewayAPI.cpp:28
GatewayAPI::getNodeNumber
void getNodeNumber(AsyncWebServerRequest *request)
Processes node number request.
Definition: GatewayAPI.cpp:46
GatewayAPI::getNodeInfo
char * getNodeInfo(Node *node, int &resultCode, char *nodeInfo, size_t len)
Builds node info.
Definition: GatewayAPI.cpp:155
GatewayAPI::restartNode
void restartNode(AsyncWebServerRequest *request)
Processes node information request.
Definition: GatewayAPI.cpp:198
GatewayAPI::deleteNode
const char * deleteNode(Node *node, int &resultCode)
Processes node deletion request.
Definition: GatewayAPI.cpp:140
Node
Class definition for a single sensor Node.
Definition: NodeList.h:109
methodToString
String methodToString(WebRequestMethodComposite method)
Definition: GatewayAPI.cpp:358
GatewayAPI::buildGwInfo
char * buildGwInfo(char *gwInfo, size_t len)
Builds gateway info.
Definition: GatewayAPI.cpp:54
GatewayAPI::getGwInfo
void getGwInfo(AsyncWebServerRequest *request)
Processes gateway information request.
Definition: GatewayAPI.cpp:78
EnigmaIOTGateway.h
Library to build a gateway for EnigmaIoT system.
GatewayAPI::restartGw
void restartGw(AsyncWebServerRequest *request)
Processes gateway restart request.
Definition: GatewayAPI.cpp:259
GatewayAPI::server
AsyncWebServer * server
Web server instance.
Definition: GatewayAPI.h:27