-->
Page 1 of 2

CIPSEND issue

PostPosted: Wed Mar 02, 2016 9:13 am
by biswar
Hi Guys,
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--------------------------------------------------
Code: Select all               /* 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

Code: Select allAT

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

Re: CIPSEND issue

PostPosted: Wed Mar 02, 2016 11:40 am
by xtal
I'm thinking the AT fw works like the old modems ,,,, cmds and data are sent over serial port,
I think it my take some magic coding to send cmds over the air? But then I may be wrong...
I really think the AT fw is lacking and hard to work with....
I would recommend Arduino IDE [c++] and nodeMCU and ESPbasic

Re: CIPSEND issue

PostPosted: Wed Mar 02, 2016 8:57 pm
by biswar
My problem is that I cant use any custom firmware on the chip. In my production environment, the ESP will be connected with a PSoC processor, which will drive this to send out data.

Now, I dont want any custom firmware to be on the ESP8266 chip, to avoid production issues.

Sending AT commands to connect to the server and send data will suit my requirement perfectly.

Everything works fine for me, till CIPSEND. when I issue CIPSEND I get the '>' prompt, but writing to the same file descriptor gives me "busy s..." prompt and I receive am empty string on the server side.

Re: CIPSEND issue

PostPosted: Wed Mar 02, 2016 9:35 pm
by martinayotte
biswar wrote:to avoid production issues.

AT firmware is some kind of some kind of toy !
Why should you stick with AT Firmware because of that.
Business as well as EE side, I wouldn't rely on that.
You are better writing your own firmware with all toolchains/sources backed up with history.