Update to recent Sming
parent
0310b4fa87
commit
3c790d2c29
|
@ -22,10 +22,7 @@ void SpejsNode::init() {
|
|||
WifiStation.enable(true);
|
||||
WifiStation.config(WIFI_SSID, WIFI_PWD);
|
||||
|
||||
WifiStation.waitConnection(
|
||||
ConnectionDelegate(&SpejsNode::onConnected, this), 20, *[] {
|
||||
Serial.println("Connection failed");
|
||||
});
|
||||
WifiEvents.onStationGotIP(StationGotIPDelegate(&SpejsNode::gotIP, this));
|
||||
|
||||
registerEndpoint("$implementation", new ImplementationEndpoint());
|
||||
|
||||
|
@ -92,6 +89,10 @@ void SpejsNode::httpIndex(HttpRequest &request, HttpResponse &response)
|
|||
/*
|
||||
* Successful network connection handler
|
||||
*/
|
||||
void SpejsNode::gotIP(IPAddress ip, IPAddress netmask, IPAddress gateway) {
|
||||
onConnected();
|
||||
}
|
||||
|
||||
void SpejsNode::onConnected() {
|
||||
Serial.println("Connection successful");
|
||||
|
||||
|
@ -144,7 +145,7 @@ void SpejsNode::httpFile(HttpRequest &request, HttpResponse &response)
|
|||
String value = req.substring(req.indexOf("/") + 1);
|
||||
|
||||
if(key.length() == 0 || value.length() == 0 || !endpoints.contains(key)) {
|
||||
response.badRequest();
|
||||
response.code = 400;
|
||||
} else {
|
||||
EndpointResult result = endpoints[key]->onValue(key, value);
|
||||
JsonObjectStream* stream = new JsonObjectStream();
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
deviceType(_deviceType) {};
|
||||
|
||||
void onConnected();
|
||||
void gotIP(IPAddress ip, IPAddress netmask, IPAddress gateway);
|
||||
|
||||
void init();
|
||||
|
||||
|
|
Loading…
Reference in New Issue