I have recently purchased a esp8266 module ( NodeMCU v1.0) and have put in the AT firmware in the same.
I am able to open a UDP connection with my remote server and send data to it, using minicom or teraterm.
Now, I am trying to do the same in my C code, and successful till I get the '>' prompt in the console.
I am writing to the open filedescriptor, but looks like nothing gets sent to the remote but an empty string.
My relevant code snippet is as below
--------------------------------------------------code start--------------------------------------------------
/* Check if AT Interface is woring fine */
snprintf(w_buf,PATH_MAX,"%s","AT\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(1);
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Put the system in station mode */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CWMODE=1\r\n");
write(fd,w_buf,sizeof(w_buf));
usleep(100000);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Connect to the WIFI */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CWJAP=\"vios-dlink24\",\"viosdlink24\"\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(5); /* Sleep for 5 seconds */
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Check the IP */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CIFSR\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(15);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Single connection mode */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CIPMUX=0\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(1);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Open UDP port */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CIPSTART=\"UDP\",\"192.168.1.35\",1112,1112,2\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(1);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
/* Send 5 bytes */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CIPSEND=5\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(5);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
write(fd,"Hello",5);
/* Close the connection */
memset(w_buf,0,sizeof(r_buf));
snprintf(w_buf,PATH_MAX,"%s","AT+CIPCLOSE\r\n");
write(fd,w_buf,sizeof(w_buf));
sleep(1);
memset(r_buf,0,sizeof(r_buf));
read(fd,r_buf,sizeof(r_buf));
printf("%s\n",r_buf);
Now, the console output is as below
AT
OK
AT+CWMODE=1
OK
AT+CWJAP="vios-dlink24","viosdlink24"
WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP
AT+CIFSR
busy p...
OK
AT+CIPMUX=0
OK
AT+CIPSTART="UDP","192.168.1.35",1112,1112,2
CONNECT
OK
AT+CIPSEND=5
OK
>
busy s...
Recv 5 bytes
SEND OK
AT+CIPCLOSE
CLOSED
OK
Now, what am I missing in here? How can i send the data after the '>' prompt comes.
Thanks
Biswa