Open LuizHAP opened 8 years ago
I change my code like below:
wifi.send((const uint8_t*)ComandoGET, strlen(ComandoGET));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
char *resposta = buffer;
for (i = 0; i < len; i++)
{
if (strncmp(resposta++, "\r\n\r\n", 4) == 0) break;
}
resposta += 3;
Its really works for me, but when i apply a decision with the variable "resposta", just get stucked. Code:
String tratado = resposta;
if (tratado="OFF")
{
Serial.print("OFF");
}
else
{
Serial.print("ON");
}
tratado = "";
My response for GET Request its only a OFF now, even sending a string "ON" to a "/teste". Its a Buffer stuck?
Hi Guys,
I need help with my project. Here is my code:
`#include
//DADOS DO WIFI
define WIFI_SSID "SSID"
define WIFI_PSK "123456"
define HOST_NAME "HOST"
define HOST_PORT (80)
ESP8266 wifi(Serial1);
//OUTPUT const int LED_RESPOSTA = 13;
//ENDEREÇO NODE.JS const char http_site[] = "HOST"; const int http_port = 80;
//TRATANDO O BUFFER char recebido; char tratado; char c;
void setup() { //Inicializando serial do Arduino e do ESP82266 para conexão ao WebPage Serial.begin(9600); Serial1.begin(9600); //BaudRate padrão do ESP8266 Serial.print("Iniciando Setup\r\n");
//LED para Debug pinMode(LED_RESPOSTA, OUTPUT);
//CONECTAR WIFI CONFORME CONFIGURAÇÕES conectarWifi(); }
void loop() { ConexaoServer(); }
void conectarWifi() { Serial.println(wifi.getVersion().c_str()); if (wifi.setOprToStationSoftAP()) { Serial.print("Configuracao StationSoft OK!\r\n"); } else { Serial.print("Configuracao StationSoft ERRO\r\n"); } if (wifi.joinAP(WIFI_SSID, WIFI_PSK)) { Serial.print("Conectado ao WIFI com sucesso!\r\n"); Serial.print("IP:"); Serial.println( wifi.getLocalIP().c_str());
} else { Serial.print("Não conectou ao WIFI, refazer as configuracoes\r\n"); }
}
void ConexaoServer(){ uint8_t buffer[1024] = {0};
}`
And i receive from Node.js
`Received:[HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 4 ETag: W/"4-wArb1VtkpsN6In8g50pGNw" Date: Wed, 31 Aug 2016 01:26:41 GMT Connection: close
Luiz]`
But i want to receive just "Received:[Luiz]". How i can do this?
Thanx!