commit 7c68bcc70143ca2bd72bff13142e1295904a3b36 Author: Alexis Drai Date: Thu Jun 8 10:31:38 2023 +0200 :tada: diff --git a/sketch_jun08b/sketch_jun08b.ino b/sketch_jun08b/sketch_jun08b.ino new file mode 100644 index 0000000..95c2b6e --- /dev/null +++ b/sketch_jun08b/sketch_jun08b.ino @@ -0,0 +1,9 @@ +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +} diff --git a/sketch_may16a/sketch_may16a.ino b/sketch_may16a/sketch_may16a.ino new file mode 100644 index 0000000..a50c95f --- /dev/null +++ b/sketch_may16a/sketch_may16a.ino @@ -0,0 +1,88 @@ +// see https://github.com/kbeaugrand-org/ESP8266-AT-WIFI-MQTT + +char c; + +void setup() { + Serial.begin(115200); + delay(3000); + do_connect(); + read_AT_response(); + create_tcp_server(); + read_AT_response(); +} + +bool AT_thingy(String thingy) { + Serial.println(thingy); + return true; +} + +void read_AT_response() { + while(Serial.available() > 0) + { + c = Serial.read(); + Serial.print(c); + } + Serial.print('\n'); +} + + +void do_connect() { + while(!AT_thingy("AT+CWJAP=[\"Alexis\"],[\"M3rciAlexis!\"]")) + { + // wait + } + read_AT_response(); +} + +void is_connected() { + while(!AT_thingy("AT+CWJAP?")) + { + // wait + } + read_AT_response(); +} + +void check_networks() { + while(!AT_thingy("AT+CWLAP")) + { + //wait + } + read_AT_response(); +} + +void do_reconnect() { + AT_thingy("AT+CWRECONNCFG=1"); + read_AT_response(); +} + +void create_tcp_server() { + while(!AT_thingy("AT+CIPSERVER=1,8080")) + { + // wait + } + read_AT_response(); +} + +void is_tcp_server() { + while(!AT_thingy("AT+CIPSERVER?")) + { + // wait + } + read_AT_response(); +} + +void about_tcp_connection() { + while(!AT_thingy("AT+CIPSTATE?")) + { + // wait + } + read_AT_response(); +} + + +void loop() { + is_tcp_server(); + delay(1000); + about_tcp_connection(); + delay(1000); +}