diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..8bdaa4a --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "compilerPath": "C:\\TDM-GCC-64\\bin\\gcc.exe", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/ipch/40f34ea280040acc/mmap_address.bin b/.vscode/ipch/40f34ea280040acc/mmap_address.bin new file mode 100644 index 0000000..862b842 Binary files /dev/null and b/.vscode/ipch/40f34ea280040acc/mmap_address.bin differ diff --git a/.vscode/ipch/e09fdb15e30baed9/mmap_address.bin b/.vscode/ipch/e09fdb15e30baed9/mmap_address.bin new file mode 100644 index 0000000..862b842 Binary files /dev/null and b/.vscode/ipch/e09fdb15e30baed9/mmap_address.bin differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..691a8f6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "Disabled" +} \ No newline at end of file diff --git a/client/wemos_D1_mini/wemos_D1_mini.ino b/client/wemos_D1_mini/wemos_D1_mini.ino new file mode 100644 index 0000000..c66a4f6 --- /dev/null +++ b/client/wemos_D1_mini/wemos_D1_mini.ino @@ -0,0 +1,16 @@ + +#define WIFI_STA_SSID "yimian-iot" +#define WIFI_STA_PSK "1234567890." + + +#include "wiot.h" + + +// Create an instance of the server +// specify the port to listen on as an argument +//WiFiServer server(80); + + + + + diff --git a/client/wemos_D1_mini/wiot.h b/client/wemos_D1_mini/wiot.h new file mode 100644 index 0000000..b955495 --- /dev/null +++ b/client/wemos_D1_mini/wiot.h @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include + + +#ifndef WIFI_STA_SSID +#define WIFI_STA_SSID "wiot" +#define WIFI_STA_PSK "1234567890" +#endif + +const char* ssid = WIFI_STA_SSID; +const char* password = WIFI_STA_PSK; + +enum ModeType{AP, STA} +ModeType Mode; + + +/********** Web Server ***********/ +ESP8266WebServer httpServer(80); +ESP8266HTTPUpdateServer httpUpdater; + + + + +void serial_setup(){ + + Serial.begin(115200); + Serial.setTimeout(12); +} + + +void eeprom_setup(){ + + EEPROM.begin(5000); +} + + +void wifi_setup(){ + + //check the mode + if(!EEPROM.read(64)){ + //set wifi mode as AP + WiFi.mode(WIFI_AP); + WiFi.softAP(("wiot-" + WiFi.macAddress()).c_str(),password,1); + WiFi.begin(); + Mode = AP; + }else{ + //set wifi mode as AP_STA + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + Mode = STA; + } + + //Disconnected + while (WiFi.status() != WL_CONNECTED) { + Serial.println("Disconnected!"); + delay(500); + } +} + + +void http_setup(){ + + if(Mode == STA){ + //OTA setup + httpUpdater.setup(&httpServer); + //httpserver begin + httpServer.begin(); + } +} + + + + + + + + +void setup() { + + serial_setup(); + wifi_setup(); + http_setup(); +} + + + + +void loop() { +httpServer.handleClient();/* + EEPROM.write(0x01, 0x02); + static String res = ""; + static String to = ""; + static unsigned long t= millis(); + + if(millis() > t + 25){ + if(Serial.available() > 0) to = Serial.readStringUntil('\n'); + Serial.println(res); + t = millis(); + } + + + + // Check if a client has connected + WiFiClient client = server.available(); + if (!client) { + return; + } + + + client.setTimeout(5000); // default is 1000 + + // Read the first line of the request + String req = client.readStringUntil('\r'); + + char res_char[8]; + + if (req.indexOf(F("/cmd/")) != -1){ + + const char *t_req = req.c_str(); + res = ""; + for(int i = 0; i < 8; i++) res_char[i] = t_req[10+i]; + res = res_char; + } + + + while (client.available()) { + + client.read(); + } + + client.print(F("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n\r\n" )); + client.print(EEPROM.read(0x01)); +*/ +} diff --git a/server/getData.js b/server/getData.js index 6bace2b..ac6165a 100644 --- a/server/getData.js +++ b/server/getData.js @@ -837,7 +837,7 @@ function l_hal(obj) function l_din(obj) { - if(/*obj.R8||*/obj.R13||obj.R14||obj.R15||obj.R16||obj.R17||obj.R18) return 1; + if(/*obj.R8||*/obj.R13||obj.R14||/*obj.R15||*/obj.R16||obj.R17||obj.R18) return 1; else return 0; }