Ola pessoal. Preciso receber um pacote via wifi STA, mas preciso tratar como int, pois preciso tratar o pacote byte a byte. Como string não funciona, pois posso receber qualquer dado, como por exemplo o caracter CR (0x0d) e isso bagunça quando é string. Fiz um sketch de teste, se ele funcionar para mim está resolvido. Preciso receber o pacote e gerar seu eco. A grande questão nesse sketch está na linha dado = client.read(); que não funciona.
#include <lwip/priv/tcp_priv.h>
void tcpCleanup()
{
while (tcp_tw_pcbs != NULL)
{
tcp_abort(tcp_tw_pcbs);
}
}
#include <ESP8266WiFi.h>
const char* ssid = "2.4Gviviane";
const char* password = "24151965";
int dado[20]={0};
WiFiServer server(80);
void setup() {
Serial.begin(74880);
IPAddress staticIP(192, 168, 0, 191);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(staticIP, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.begin();
Serial.println("Conected");
Serial.println(WiFi.localIP());
tcpCleanup();
}
void loop() {
// put your main code here, to run repeatedly:
WiFiClient client = server.available();
if (!client) {
return;
}
while (!client.available()) {
delay(1);
}
// String dado = client.readStringUntil('\r');
dado = client.read();
//req.toCharArray(dado,17);
client.flush();
// Serial.println(req);
Serial.print(dado);
for (char i=0; i<17;i++)
{
client.write(dado[i]);
}
}