MarcoMartines / GSM-GPRS-GPS-Shield

GSM/GPRS & GPS Shield Library for modules using SIM900/SIM908
GNU General Public License v2.0
208 stars 152 forks source link

How to receive/send data from/to TCP connection #19

Open rupakraj opened 9 years ago

rupakraj commented 9 years ago

Hi, I am trying to send/get data from the to my tcp server powered by NodeJS. I found connectTCP, and connected to the server. But did not found any useful method to send and receive data.

Please suggest me.

vannut commented 9 years ago

After you established a connection with attachGPRS() and you've connected with connectTCP you'll have to write over the gsm-serial connection. Assuming your connection is stored in gsm:

//- at first sent the command to initiate the 'line'
    gsm.SimpleWriteln("AT+CIPSEND");
//- wait for a proper response
   if(gsm.WaitResp(2000,50,">")== RX_FINISHED_STR_RECV){
      //- write your data to the server:
           gsm.SimpleWriteln("Some data here");
      //- end with this end sequence to terminate the session
      //   don't know for sure what it does/means but I found this by trial and 
      // error. So maybe somebody else could enlighten us ;)
          inSerial[0]=0x1a;
          inSerial[1]='\0';
          gsm.SimpleWriteln(inSerial);
   }