mirror of
https://github.com/0x1d/esp8266-laser.git
synced 2025-12-16 10:44:30 +01:00
added /readwifi and /readvalues
changed holding values in ram after sending to laserspiro
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1 @@
|
||||
/data-dev/maincontrols.txt
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ Wifi Host for the Arduino-Laser-Spirograph
|
||||
/pwd/{password}
|
||||
/apmode/1 -> SofAP (default), 0 -> client
|
||||
/saveconf -> write wificonfig to file
|
||||
/resetwifi -> reconnect wifi with the new settings (this will work)
|
||||
/resetwifi -> reconnect wifi with the new settings
|
||||
/readwifi -> returns wifi settings
|
||||
/readvalues -> return laser and motor values
|
||||
|
||||
#install
|
||||
- install arduino ide (1.8.5)
|
||||
|
||||
@@ -20,6 +20,11 @@ int apMode = 1; // 0: client, 1: AP (default) // will be overwriten
|
||||
int apModeRuntime = 0;
|
||||
int wifiTimeout = 10000; //ms
|
||||
|
||||
|
||||
// [0] laser[1] m1 [2] m2 [3] m3
|
||||
byte lmValues[4] = {0,0,0,0};
|
||||
|
||||
|
||||
/* Soft AP network parameters */
|
||||
char *ssidAP = "laserAp";
|
||||
IPAddress apIP(192, 168, 4, 1); // note: update metaRefreshStr string if ip change!
|
||||
@@ -114,6 +119,7 @@ void handleFileList() {
|
||||
void handleLaser(String uri)
|
||||
{
|
||||
String laserValue = uri.substring(7);
|
||||
lmValues[0] = laserValue.toInt();
|
||||
|
||||
String msg = "AT SLV ";
|
||||
msg += laserValue;
|
||||
@@ -133,6 +139,7 @@ void handleMotor(String uri)
|
||||
{
|
||||
String motorNr = uri.substring(7, 8);
|
||||
String motorValue = uri.substring(9);
|
||||
lmValues[motorNr.toInt()] = motorValue.toInt();
|
||||
|
||||
String msg = "AT SMS ";
|
||||
msg += motorNr;
|
||||
@@ -151,6 +158,27 @@ void handleMotor(String uri)
|
||||
json = String();
|
||||
}
|
||||
|
||||
void handleReadValues()
|
||||
{
|
||||
String json = "{ \"handledReadValues\":";
|
||||
json += "{\"laser\":\"" + (String)lmValues[0] + "\",";
|
||||
json += "\"motors\": {\"1\":\"" + (String)lmValues[1] + "\",";
|
||||
json += "\"2\":\"" + (String)lmValues[2] + "\",";
|
||||
json += "\"3\":\"" + (String)lmValues[3] + "\"}}}";
|
||||
server.send(200, "text/json", json);
|
||||
json = String();
|
||||
}
|
||||
|
||||
void handleReadWifi()
|
||||
{
|
||||
String json = "{ \"handledReadWifi\":";
|
||||
json += "{\"apMode\":\"" + (String)apMode + "\",";
|
||||
json += "\"ssid\":\"" + (String)ssid + "\",";
|
||||
json += "\"password\":\"***\"}}"; //(String)password
|
||||
server.send(200, "text/json", json);
|
||||
json = String();
|
||||
}
|
||||
|
||||
void handleSsid(String uri)
|
||||
{
|
||||
ssid = uri.substring(6);
|
||||
@@ -160,6 +188,7 @@ void handleSsid(String uri)
|
||||
server.send(200, "text/json", json);
|
||||
json = String();
|
||||
}
|
||||
|
||||
void handlePwd(String uri)
|
||||
{
|
||||
password = uri.substring(5);
|
||||
@@ -328,6 +357,8 @@ void setup(void) {
|
||||
server.on("/listFiles", HTTP_GET, handleFileList);
|
||||
server.on("/saveconf", HTTP_GET, handleSaveConf);
|
||||
server.on("/resetwifi", HTTP_GET, setupWifi);
|
||||
server.on("/readwifi", HTTP_GET, handleReadWifi);
|
||||
server.on("/readvalues", HTTP_GET, handleReadValues);
|
||||
server.on("/heap", HTTP_GET, []() {
|
||||
String json = "{";
|
||||
json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||
|
||||
Reference in New Issue
Block a user