I am testing the SerialESP8266_library_test.ino example, with some modifications for the STM32 Blue pill board. When I send a message to the server, it returns a response.
If I enable the debug by the serial port, the answer is complete, but when using the wifirecived function, the first character disappears, the S of SUCCESS does not reach me.
Code
#include <SerialESP8266wifi.h>
#define esp8266_reset_pin PC13 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)
#define WIFI_SSID "Rayen"
#define WIFI_PASS "87654321"
#define DST_IP "192.168.0.157"
#define DST_Port "9221"
// the last parameter sets the local echo option for the ESP8266 module..
SerialESP8266wifi wifi(Serial2, Serial2, esp8266_reset_pin,Serial); //adding Serial enabled local echo and wifi debug
String inputString;
boolean pasada = 1, stringComplete = false;
unsigned long nextPing = 0;
void setup() {
bool conectado = 0;
inputString.reserve(30);
Serial2.begin(115200);
Serial.begin(9600);
while (!Serial)
;
Serial.println("Starting wifi");
wifi.setTransportToTCP();// this is also default
// wifi.setTransportToUDP();//Will use UDP when connecting to server, default is TCP
wifi.endSendWithNewline(true); // Will end all transmissions with a newline and carrage return
wifi.begin();
//Turn on local ap and server (TCP)
//wifi.startLocalAPAndServer(WIFI_SSID, WIFI_PASS, "5", "2121");
//wifi.startLocalServer("2121");
delay(10);
conectado = wifi.connectToAP(WIFI_SSID, WIFI_PASS);
while (!conectado) {
delay(10);
}
delay(100);
Serial.println("Envio AT+CIPMUX=1");
Serial2.println("AT+CIPMUX=1");
delay(100);
conectado = wifi.connectToServer(DST_IP, "9221");
delay(100);
Serial.println("-----Fin Setup-----");
}
void loop() {
if (pasada) {
Serial.println("-----Enviando datos-----");
Serial2.println("AT+CWJAP_CUR?");
// wifi.writeCommand(SERVER,"AT+CWJAP_CUR?");
delay(1000);
wifi.send(SERVER,"/dev/Medi123/savean0=4.9&u=Medi123&p=12345&d=1421080339&z=p\n");
delay(5000);
pasada = 0;
WifiMessage in = wifi.listenForIncomingMessage(5000);
if (in.hasData) {
Serial.print("Mensaje recibido:");
Serial.print(in.message);
if(in.channel == SERVER)
Serial.println("Del Server");
else{
Serial.print("Por canal:");
Serial.println(in.channel);
}
}
}
}
Answer (serial debug)
JAP_CUR?
+CWJAP_CUR:"Rayen","d4:6e:0e:f3:65:2e",7,-56
OK
TAIP,"192.168.0.106"
+CIFSR:STAMAC,"bc:dd:c2:ed:8f:49"
OK
AT+CIPSEND=4,63
OK
>
Recv 63 bytes
SEND OK
+IPD,4,36:SUCCESS
DATE=1420821139;1554917753
Mensaje recibido:UCCESS
DATE=1420821139;1554917753
Del Server
I am testing the SerialESP8266_library_test.ino example, with some modifications for the STM32 Blue pill board. When I send a message to the server, it returns a response. If I enable the debug by the serial port, the answer is complete, but when using the wifirecived function, the first character disappears, the S of SUCCESS does not reach me.
Code
Answer (serial debug)