You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
67 lines
1.2 KiB
// Import required libraries
|
|
#include <Arduino.h>
|
|
#include <ESP8266WiFi.h>
|
|
#include <Hash.h>
|
|
#include <ESPAsyncTCP.h>
|
|
#include <ESPAsyncWebServer.h>
|
|
|
|
const char* ssid = "Bytetools Technologies Inc.";
|
|
const char* password = "Fuck commies #69420!";
|
|
String a = "";
|
|
int i = 0;
|
|
|
|
//define jspn string for sensors
|
|
String jsonLocation ="";
|
|
|
|
// Create AsyncWebServer object on port 80
|
|
AsyncWebServer server(80);
|
|
|
|
|
|
void setup(){
|
|
Serial.begin(9600);
|
|
|
|
// Connect to Wi-Fi
|
|
WiFi.begin(ssid, password);
|
|
Serial.println("Connecting to wifi");
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
delay(1000);
|
|
Serial.println(".");
|
|
}
|
|
|
|
// Print ESP8266 Local IP Address
|
|
Serial.println(WiFi.localIP());
|
|
|
|
server.on("/location", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
request->send_P(200, "text/plain", jsonLocation.c_str());
|
|
});
|
|
|
|
// Start server
|
|
server.begin();
|
|
}
|
|
|
|
|
|
void loop(){
|
|
|
|
|
|
jsonLocation = readLocation();
|
|
//Serial.println("jsonLocation: " + jsonLocation);
|
|
delay(3500);
|
|
|
|
}
|
|
|
|
|
|
String readLocation()
|
|
{
|
|
//i=i+1;
|
|
Serial.println("jsonData");
|
|
while(Serial.available())
|
|
{
|
|
a = Serial.readString();
|
|
a.trim();
|
|
return a; //"location " + String(i);
|
|
}
|
|
}
|
|
//© 2022 GitHub, Inc.
|
|
//Terms
|
|
//Privacy
|