mirror of
https://github.com/anklimov/lighthub
synced 2025-12-10 05:39:51 +03:00
esp8266
esp8266 worked esp8266 basic support, DMX now can be disabled
This commit is contained in:
@@ -270,9 +270,13 @@ int lanLoop() {
|
||||
case 0: //Ethernet.begin(mac,ip);
|
||||
{
|
||||
#ifdef __ESP__
|
||||
//WiFi.mode(WIFI_STA);
|
||||
//wifiMulti.addAP("Smartbox", "");
|
||||
if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
WiFi.mode(WIFI_STA);
|
||||
Serial.print(F("WIFI AP/Password:"));
|
||||
Serial.print(QUOTE(ESP_WIFI_AP));
|
||||
Serial.print(F("/"));
|
||||
Serial.println(QUOTE(ESP_WIFI_PWD));
|
||||
wifiMulti.addAP(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||
if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
#else
|
||||
IPAddress ip;
|
||||
IPAddress dns;
|
||||
@@ -858,10 +862,7 @@ return 0;
|
||||
}
|
||||
|
||||
int getConfig(int arg_cnt, char **args)
|
||||
//(char *tokens)
|
||||
{
|
||||
|
||||
|
||||
int responseStatusCode = 0;
|
||||
char ch;
|
||||
char URI[40];
|
||||
@@ -928,9 +929,8 @@ int getConfig(int arg_cnt, char **args)
|
||||
lanCheck = millis() + 5000;
|
||||
return -11;
|
||||
}
|
||||
|
||||
#else
|
||||
//Non AVR code
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)
|
||||
String response;
|
||||
EthernetClient configEthClient;
|
||||
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
|
||||
@@ -976,9 +976,39 @@ int getConfig(int arg_cnt, char **args)
|
||||
//lanCheck=millis()+15000;
|
||||
return -11; //Load from NVRAM
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#if defined(__ESP__)
|
||||
HTTPClient httpClient;
|
||||
String fullURI = "http://";
|
||||
fullURI+=configServer;
|
||||
fullURI+=URI;
|
||||
httpClient.begin(fullURI);
|
||||
int httpResponseCode = httpClient.GET();
|
||||
if (httpResponseCode > 0) {
|
||||
// HTTP header has been send and Server response header has been handled
|
||||
Serial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
|
||||
// file found at server
|
||||
if (httpResponseCode == HTTP_CODE_OK) {
|
||||
String response = httpClient.getString();
|
||||
Serial.println(response);
|
||||
aJson.deleteItem(root);
|
||||
root = aJson.parse((char *) response.c_str());
|
||||
if (!root) {
|
||||
Serial.println(F("Config parsing failed"));
|
||||
return -11; //Load from NVRAM
|
||||
} else {
|
||||
Serial.println(F("Config OK, Applying"));
|
||||
applyConfig();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Serial.printf("[HTTP] GET... failed, error: %s\n", httpClient.errorToString(httpResponseCode).c_str());
|
||||
httpClient.end();
|
||||
return -11; //Load from NVRAM
|
||||
}
|
||||
httpClient.end();
|
||||
#endif
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -1167,7 +1197,9 @@ void loop_main() {
|
||||
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);
|
||||
|
||||
if (items) {
|
||||
#ifndef MODBUS_DISABLE
|
||||
if (lanStatus != 4) pollingLoop();
|
||||
#endif
|
||||
#ifdef _owire
|
||||
thermoLoop();
|
||||
#endif
|
||||
@@ -1241,6 +1273,7 @@ void inputLoop(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MODBUS_DISABLE
|
||||
void pollingLoop(void) {
|
||||
boolean done = false;
|
||||
if (millis() > nextPollingCheck) {
|
||||
@@ -1258,6 +1291,7 @@ void pollingLoop(void) {
|
||||
} //while
|
||||
}//if
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//TODO: refactoring
|
||||
|
||||
Reference in New Issue
Block a user