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