Hello,
Idk what is wrong here please help
code:
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "Test net";
const char* password = "Abc112233Abc";
//OTA_setup
const int OTA_port = 8266;
const char* OTA_password = "admin";
//OTA_setup
//OTA
bool OTA_update = false;
uint16_t OTA_time = 0;
//OTA
//JSON_board
const int BOARD_number = 1;
const String BOARD_hardware = "Gun";
const String BOARD_name = BOARD_hardware + String(BOARD_number,DEC);
const float JSON_software_version = 0.8;
//JSON_board
//COMANDS
int COMAND_list_int = 0; //leave
int COMAND_list_size = 2; //comands number
String test = "test";
String testTwo = "123";
String COMAND_list[] = {test, testTwo}; //comands
int previous_comand_number = 0;
//COMANDS
//OTHER
ESP8266WebServer server;
//OTHER
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WIFI_check();
OTA_setup();
SERVER_web();
}
void loop() {
WIFI_check();
OTA();
server.handleClient();
JSON_comands();
COMANDS();
}
String JSON_board() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root_board = jsonBuffer.createObject();
root_board["Software Version"] = JSON_software_version;
root_board["Name"] = BOARD_name;
root_board["Hardware"] = BOARD_hardware;
root_board["Number"] = BOARD_number;
String JSON_board_json;
root_board.prettyPrintTo(JSON_board_json);
return JSON_board_json;
}
void JSON_comands() {
HTTPClient COMANDS_http;
COMANDS_http.begin("http://");
int COMANDS_json = COMANDS_http.GET();
if (COMANDS_json > 0) {
const size_t capacity = 3*JSON_OBJECT_SIZE(2) + 70;
DynamicJsonBuffer jsonBuffer(capacity);
const char* json = "{\"Gun1\":{\"comand_number\":1,\"comand\":\"\"},\"Gun2\":{\"comand_number\":1,\"comand\":\"\"}}";
JsonObject& root = jsonBuffer.parseObject(json);
int JSON_comand_number = root[BOARD_name]["comand_number"];
char JSON_comand = root[BOARD_name]["comand"];
}
COMANDS_http.end();
}
void COMANDS(){
if (JSON_comand >= 0 || comand_number != previous_comand_number){
previous_comand_number = JSON_comand_number;
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++){
if (JSON_comand == COMAND_list[1]){
Serial.println("test_comand");
}
else if (JSON_comand == COMAND_list[2]){
Serial.println("123_comand");
}
}
}
}
void SERVER_web() {
server.on("/restart", []() {
server.send(200, "text/plain", "Restarting ESP");
ESP.restart();
});
server.on("/update", []() {
server.send(200, "text/plain", "Update Called \n5 seconds left");
OTA_update = true;
OTA_time = 0;
});
server.on("/board", []() {
server.send(200, "text/json", JSON_board());
});
server.begin();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void OTA_setup() {
ArduinoOTA.setPort(OTA_port);
ArduinoOTA.setHostname(BOARD_name.c_str());
ArduinoOTA.setPassword(OTA_password);
ArduinoOTA.onStart([]() {
String OTA_type;
if (ArduinoOTA.getCommand() == U_FLASH) {
OTA_type = "sketch";
} else { // U_SPIFFS
OTA_type = "filesystem";
}
Serial.println("OTA Start updating " + OTA_type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA End");
});
ArduinoOTA.onProgress([](unsigned int OTA_progress, unsigned int OTA_total) {
Serial.printf("OTA Update Progress: %u%%\r", (OTA_progress / (OTA_total / 100)));
});
ArduinoOTA.onError([](ota_error_t OTA_error) {
Serial.printf("OTA Error[%u]: ", OTA_error);
if (OTA_error == OTA_AUTH_ERROR) {
Serial.println("OTA Auth Failed");
} else if (OTA_error == OTA_BEGIN_ERROR) {
Serial.println("OTA Begin Failed");
} else if (OTA_error == OTA_CONNECT_ERROR) {
Serial.println("OTA Connect Failed");
} else if (OTA_error == OTA_RECEIVE_ERROR) {
Serial.println("OTA Receive Failed");
} else if (OTA_error == OTA_END_ERROR) {
Serial.println("OTA End Failed");
}
});
uint16_t OTA_time_start = millis();
while (OTA_time < 1000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
}
void WIFI_check() {
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Connection Failed! Connecting...");
WiFi.begin(ssid, password);
delay(100);
}
}
void OTA() {
if (OTA_update == true) {
uint16_t OTA_time_start = millis();
while (OTA_time < 5000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
delay(500);
ESP.restart();
}
}
error:
'JSON_comand' was not declared in this scope
i dont understand wh if it is in JSON_comands. Thanks!
What happens if you put this line:
void JSON_comands(); // Function prototype
immediately after all of your #include directives? Do you get a similar error on COMMANDS() after the change? You might also look at this post.
char JSON_comand = root[BOARD_name]["comand"];
Is in JSON_comands()
It cannot be seen in COMANDS()
I didn't even notice the missing 's'!
I put it togather
code:
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "Test net";
const char* password = "Abc112233Abc";
//OTA_setup
const int OTA_port = 8266;
const char* OTA_password = "admin";
//OTA_setup
//OTA
bool OTA_update = false;
uint16_t OTA_time = 0;
//OTA
//JSON_board
const int BOARD_number = 1;
const String BOARD_hardware = "Gun";
const String BOARD_name = BOARD_hardware + String(BOARD_number,DEC);
const float JSON_software_version = 0.8;
//JSON_board
//COMANDS
int COMAND_list_int = 0; //leave
int COMAND_list_size = 2; //comands number
String test = "test";
String testTwo = "123";
String COMAND_list[] = {test, testTwo}; //comands
int previous_comand_number = 0;
//COMANDS
//OTHER
ESP8266WebServer server;
//OTHER
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WIFI_check();
OTA_setup();
SERVER_web();
}
void loop() {
WIFI_check();
OTA();
server.handleClient();
JSON_comands();
}
String JSON_board() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root_board = jsonBuffer.createObject();
root_board["Software Version"] = JSON_software_version;
root_board["Name"] = BOARD_name;
root_board["Hardware"] = BOARD_hardware;
root_board["Number"] = BOARD_number;
String JSON_board_json;
root_board.prettyPrintTo(JSON_board_json);
return JSON_board_json;
}
void JSON_comands() {
HTTPClient COMANDS_http;
COMANDS_http.begin("http://");
int COMANDS_json = COMANDS_http.GET();
if (COMANDS_json > 0) {
const size_t capacity = 3*JSON_OBJECT_SIZE(2) + 70;
DynamicJsonBuffer jsonBuffer(capacity);
const char* json = "{\"Gun1\":{\"comand_number\":1,\"comand\":\"\"},\"Gun2\":{\"comand_number\":1,\"comand\":\"\"}}";
JsonObject& root = jsonBuffer.parseObject(json);
int JSON_comand_number = root[BOARD_name]["comand_number"];
char JSON_comand = root[BOARD_name]["comand"];
}
COMANDS_http.end();
if (JSON_comand >= 0 || JSON_comand_number != previous_comand_number){
previous_comand_number = JSON_comand_number;
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++){
if (JSON_comand == COMAND_list[1]){
Serial.println("test_comand");
}
else if (JSON_comand == COMAND_list[2]){
Serial.println("123_comand");
}
}
}
}
void SERVER_web() {
server.on("/restart", []() {
server.send(200, "text/plain", "Restarting ESP");
ESP.restart();
});
server.on("/update", []() {
server.send(200, "text/plain", "Update Called \n5 seconds left");
OTA_update = true;
OTA_time = 0;
});
server.on("/board", []() {
server.send(200, "text/json", JSON_board());
});
server.begin();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void OTA_setup() {
ArduinoOTA.setPort(OTA_port);
ArduinoOTA.setHostname(BOARD_name.c_str());
ArduinoOTA.setPassword(OTA_password);
ArduinoOTA.onStart([]() {
String OTA_type;
if (ArduinoOTA.getCommand() == U_FLASH) {
OTA_type = "sketch";
} else { // U_SPIFFS
OTA_type = "filesystem";
}
Serial.println("OTA Start updating " + OTA_type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA End");
});
ArduinoOTA.onProgress([](unsigned int OTA_progress, unsigned int OTA_total) {
Serial.printf("OTA Update Progress: %u%%\r", (OTA_progress / (OTA_total / 100)));
});
ArduinoOTA.onError([](ota_error_t OTA_error) {
Serial.printf("OTA Error[%u]: ", OTA_error);
if (OTA_error == OTA_AUTH_ERROR) {
Serial.println("OTA Auth Failed");
} else if (OTA_error == OTA_BEGIN_ERROR) {
Serial.println("OTA Begin Failed");
} else if (OTA_error == OTA_CONNECT_ERROR) {
Serial.println("OTA Connect Failed");
} else if (OTA_error == OTA_RECEIVE_ERROR) {
Serial.println("OTA Receive Failed");
} else if (OTA_error == OTA_END_ERROR) {
Serial.println("OTA End Failed");
}
});
uint16_t OTA_time_start = millis();
while (OTA_time < 1000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
}
void WIFI_check() {
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Connection Failed! Connecting...");
WiFi.begin(ssid, password);
delay(100);
}
}
void OTA() {
if (OTA_update == true) {
uint16_t OTA_time_start = millis();
while (OTA_time < 5000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
delay(500);
ESP.restart();
}
}
error:
'JSON_comand' was not declared in this scope
system
July 27, 2019, 7:48pm
6
if (JSON_comand >= 0 || JSON_comand_number != previous_comand_number){
The error is here?
Not surprising - JSON_comand [sic] is inside an earlier conditional code block.
Again error
code:
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "Test net";
const char* password = "Abc112233Abc";
//OTA_setup
const int OTA_port = 8266;
const char* OTA_password = "admin";
//OTA_setup
//OTA
bool OTA_update = false;
uint16_t OTA_time = 0;
//OTA
//JSON_board
const int BOARD_number = 1;
const String BOARD_hardware = "Gun";
const String BOARD_name = BOARD_hardware + String(BOARD_number,DEC);
const float JSON_software_version = 0.8;
//JSON_board
//COMANDS
int COMAND_list_int = 0; //leave
int COMAND_list_size = 2; //comands number
String test = "test";
String testTwo = "123";
String COMAND_list[] = {test, testTwo}; //comands
int previous_comand_number = 0;
//COMANDS
//OTHER
ESP8266WebServer server;
//OTHER
String JSON_board() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root_board = jsonBuffer.createObject();
root_board["Software Version"] = JSON_software_version;
root_board["Name"] = BOARD_name;
root_board["Hardware"] = BOARD_hardware;
root_board["Number"] = BOARD_number;
String JSON_board_json;
root_board.prettyPrintTo(JSON_board_json);
return JSON_board_json;
}
void JSON_comands() {
HTTPClient COMANDS_http;
COMANDS_http.begin("http://192.168.0.100/comands");
int COMANDS_json = COMANDS_http.GET();
if (COMANDS_json > 0) {
const size_t capacity = 3*JSON_OBJECT_SIZE(2) + 70;
DynamicJsonBuffer jsonBuffer(capacity);
const char* json = "{\"Gun1\":{\"comand_number\":1,\"comand\":\"\"},\"Gun2\":{\"comand_number\":1,\"comand\":\"\"}}";
JsonObject& root = jsonBuffer.parseObject(json);
int JSON_comand_number = root[BOARD_name]["comand_number"];
char JSON_comand = root[BOARD_name]["comand"];
COMANDS_http.end();
if (JSON_comand >= 0 || JSON_comand_number != previous_comand_number){
previous_comand_number = JSON_comand_number;
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++){
if (JSON_comand == COMAND_list[1]){
Serial.println("test_comand");
}
else if (JSON_comand == COMAND_list[2]){
Serial.println("123_comand");
}
}
}
COMANDS_http.end();
}
void SERVER_web() {
server.on("/restart", []() {
server.send(200, "text/plain", "Restarting ESP");
ESP.restart();
});
server.on("/update", []() {
server.send(200, "text/plain", "Update Called \n5 seconds left");
OTA_update = true;
OTA_time = 0;
});
server.on("/board", []() {
server.send(200, "text/json", JSON_board());
});
server.begin();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void OTA_setup() {
ArduinoOTA.setPort(OTA_port);
ArduinoOTA.setHostname(BOARD_name.c_str());
ArduinoOTA.setPassword(OTA_password);
ArduinoOTA.onStart([]() {
String OTA_type;
if (ArduinoOTA.getCommand() == U_FLASH) {
OTA_type = "sketch";
} else { // U_SPIFFS
OTA_type = "filesystem";
}
Serial.println("OTA Start updating " + OTA_type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA End");
});
ArduinoOTA.onProgress([](unsigned int OTA_progress, unsigned int OTA_total) {
Serial.printf("OTA Update Progress: %u%%\r", (OTA_progress / (OTA_total / 100)));
});
ArduinoOTA.onError([](ota_error_t OTA_error) {
Serial.printf("OTA Error[%u]: ", OTA_error);
if (OTA_error == OTA_AUTH_ERROR) {
Serial.println("OTA Auth Failed");
} else if (OTA_error == OTA_BEGIN_ERROR) {
Serial.println("OTA Begin Failed");
} else if (OTA_error == OTA_CONNECT_ERROR) {
Serial.println("OTA Connect Failed");
} else if (OTA_error == OTA_RECEIVE_ERROR) {
Serial.println("OTA Receive Failed");
} else if (OTA_error == OTA_END_ERROR) {
Serial.println("OTA End Failed");
}
});
uint16_t OTA_time_start = millis();
while (OTA_time < 1000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
}
void WIFI_check() {
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Connection Failed! Connecting...");
WiFi.begin(ssid, password);
delay(100);
}
}
void OTA() {
if (OTA_update == true) {
uint16_t OTA_time_start = millis();
while (OTA_time < 5000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
delay(500);
ESP.restart();
}
}
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WIFI_check();
OTA_setup();
SERVER_web();
}
void loop() {
WIFI_check();
OTA();
server.handleClient();
JSON_comands();
}
error:
no match for 'operator==' (operand types are 'char' and 'String')
Please post the full error message
Meanwhile can you please explain this for loop ?
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++)
{
if (JSON_comand == COMAND_list[1])
{
Serial.println("test_comand");
}
else if (JSON_comand == COMAND_list[2])
{
Serial.println("123_comand");
}
}
How many times will it run ?
UKHeliBob:
Please post the full error message
Meanwhile can you please explain this for loop ?
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++)
{
if (JSON_comand == COMAND_list[1])
{
Serial.println("test_comand");
}
else if (JSON_comand == COMAND_list[2])
{
Serial.println("123_comand");
}
}
How many times will it run ?
This loop should run once but in the future i want to increase it,
here is the full error:
expected '}' at end of input
}
^
exit status 1
no match for 'operator==' (operand types are 'char' and 'String')
expected '}' at end of input
Auto Format your code in the IDE. Does it end with a } on the left margin as it should ?
This loop should run once but in the future i want to increase it,
Here is a small test program based on your for loop
void setup()
{
Serial.begin(115200);
int COMAND_list_int = 0; //leave
int COMAND_list_size = 2; //comands number
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++)
{
Serial.println(COMAND_list_int);
}
Serial.println("done");
}
void loop()
{
}
What should it print ?
What does it actually print ?
error:
error: no match for 'operator==' (operand types are 'char' and 'String')
if (JSON_comand == COMAND_list[1]) {
^
v0.8:80:25: error: no match for 'operator==' (operand types are 'char' and 'String')
if (JSON_comand == COMAND_list[2]) {
^
v0.8:91:21: error: a function-definition is not allowed here before '{' token
void SERVER_web() {
^
v0.8:188:3: error: expected '}' at end of input
}
^
exit status 1
no match for 'operator==' (operand types are 'char' and 'String')
code:
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "Test net";
const char* password = "Abc112233Abc";
//OTA_setup
const int OTA_port = 8266;
const char* OTA_password = "admin";
//OTA_setup
//OTA
bool OTA_update = false;
uint16_t OTA_time = 0;
//OTA
//JSON_board
const int BOARD_number = 1;
const String BOARD_hardware = "Gun";
const String BOARD_name = BOARD_hardware + String(BOARD_number, DEC);
const float JSON_software_version = 0.8;
//JSON_board
//COMANDS
int COMAND_list_int = 0; //leave
int COMAND_list_size = 2; //comands number
String test = "test";
String testTwo = "123";
String COMAND_list[] = {test, testTwo}; //comands
int previous_comand_number = 0;
//COMANDS
//OTHER
ESP8266WebServer server;
//OTHER
String JSON_board() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root_board = jsonBuffer.createObject();
root_board["Software Version"] = JSON_software_version;
root_board["Name"] = BOARD_name;
root_board["Hardware"] = BOARD_hardware;
root_board["Number"] = BOARD_number;
String JSON_board_json;
root_board.prettyPrintTo(JSON_board_json);
return JSON_board_json;
}
void JSON_comands() {
HTTPClient COMANDS_http;
COMANDS_http.begin("http://192.168.0.100/comands");
int COMANDS_json = COMANDS_http.GET();
if (COMANDS_json > 0) {
const size_t capacity = 3 * JSON_OBJECT_SIZE(2) + 70;
DynamicJsonBuffer jsonBuffer(capacity);
const char* json = "{\"Gun1\":{\"comand_number\":1,\"comand\":\"\"},\"Gun2\":{\"comand_number\":1,\"comand\":\"\"}}";
JsonObject& root = jsonBuffer.parseObject(json);
int JSON_comand_number = root[BOARD_name]["comand_number"];
char JSON_comand = root[BOARD_name]["comand"];
COMANDS_http.end();
if (JSON_comand >= 0 || JSON_comand_number != previous_comand_number) {
previous_comand_number = JSON_comand_number;
for (COMAND_list_int = 0; COMAND_list_int == COMAND_list_size; COMAND_list_int++) {
if (JSON_comand == COMAND_list[1]) {
Serial.println("test_comand");
}
if (JSON_comand == COMAND_list[2]) {
Serial.println("123_comand");
}
}
}
COMANDS_http.end();
}
void SERVER_web() {
server.on("/restart", []() {
server.send(200, "text/plain", "Restarting ESP");
ESP.restart();
});
server.on("/update", []() {
server.send(200, "text/plain", "Update Called \n5 seconds left");
OTA_update = true;
OTA_time = 0;
});
server.on("/board", []() {
server.send(200, "text/json", JSON_board());
});
server.begin();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void OTA_setup() {
ArduinoOTA.setPort(OTA_port);
ArduinoOTA.setHostname(BOARD_name.c_str());
ArduinoOTA.setPassword(OTA_password);
ArduinoOTA.onStart([]() {
String OTA_type;
if (ArduinoOTA.getCommand() == U_FLASH) {
OTA_type = "sketch";
} else { // U_SPIFFS
OTA_type = "filesystem";
}
Serial.println("OTA Start updating " + OTA_type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA End");
});
ArduinoOTA.onProgress([](unsigned int OTA_progress, unsigned int OTA_total) {
Serial.printf("OTA Update Progress: %u%%\r", (OTA_progress / (OTA_total / 100)));
});
ArduinoOTA.onError([](ota_error_t OTA_error) {
Serial.printf("OTA Error[%u]: ", OTA_error);
if (OTA_error == OTA_AUTH_ERROR) {
Serial.println("OTA Auth Failed");
} else if (OTA_error == OTA_BEGIN_ERROR) {
Serial.println("OTA Begin Failed");
} else if (OTA_error == OTA_CONNECT_ERROR) {
Serial.println("OTA Connect Failed");
} else if (OTA_error == OTA_RECEIVE_ERROR) {
Serial.println("OTA Receive Failed");
} else if (OTA_error == OTA_END_ERROR) {
Serial.println("OTA End Failed");
}
});
uint16_t OTA_time_start = millis();
while (OTA_time < 1000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
}
void WIFI_check() {
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Connection Failed! Connecting...");
WiFi.begin(ssid, password);
delay(100);
}
}
void OTA() {
if (OTA_update == true) {
uint16_t OTA_time_start = millis();
while (OTA_time < 5000)
{
ArduinoOTA.handle();
OTA_time = millis() - OTA_time_start;
delay(10);
}
delay(500);
ESP.restart();
}
}
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WIFI_check();
OTA_setup();
SERVER_web();
}
void loop() {
WIFI_check();
OTA();
server.handleClient();
JSON_comands();
}
Here are the last few lines of your code after Auto Format
void loop()
{
WIFI_check();
OTA();
server.handleClient();
JSON_comands();
}
The final } is not on the left margin. You have mismatched { and } somewhere in the program. Check where each function ends. Where does the void JSON_comands() function end ?
If you are having trouble with compilation errors like this, it might be worthwhile starting with something simpler.