This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Modifying wifi basic application to send TCP packets not working

Hi ,

I downloaded the basic wifi application from TI website http://processors.wiki.ti.com/index.php/CC3000_Basic_Wi-Fi_example_application_for_MSP430.

With this sample application I am able to send/receive the UDP packets. But I need to use the TCP/IP for my app for which I modified the basic wifi application

by changing the basic_wifi_application.c in the following way,

For opening the TCP socket,

-  ulSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

+ ulSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

For sending the TCP packet,

 - sendto(ulSocket, pcData, ulDataLength, 0, &tSocketAddr, sizeof(sockaddr));

+ send(ulSocket, pcData, ulDataLength, 0);

But with the above changes I am not receiving any data at the laptop's wireshark.

Please let me know if the modification for sending the tcp packets is correct .

Thanks in advance.

  • Hi 

    Before you send data using TCP, you need to connect (http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide#Client_TCP_socket_connection

    1. Open the socket: socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)
    2. Connect to the destination server: connect (ulSocket,  &tSocketAddr, sizeof(sockaddr))
    3. Send data: send(ulSocket, pcData, ulDataLenght,0)
    Pedro
  • Hi pedro,

    Thanks for d solution,

    I could establish the tcp connection and send the data.

  • Hi chethu gowda,

    I'm using udp connection too.

    Did you establish the tcp connection?

    I want to modify the "home automation" code from udp to tcp.

    Can you suggest me how to do?

    Thank You

    Nicola

  • Hi Nicola,

    If you have done the udp connection and the data transaction successfully, the TCP should work for you too,

    Only difference between TCP and UDP communication protocols is TCP is connection oriented so in addition to creating the socket you must establish the TCP connection prior to sending any TCP packets.

    Following are the steps involved in sending the TCP packets,

    1. Open the socket: socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)
    2. Connect to the destination server: connect (ulSocket,  &tSocketAddr, sizeof(sockaddr))
    3. Send data: send(ulSocket, pcData, ulDataLenght,0)
  • Hi Chethu,

    thank you for your answer.

    Actually I'm using a udp application (msp430 & pc application) working correctly.

    I can modify the program as your 3 steps. But how can I do to read packets?

    I think i will try the new 3 step in next days.

    Other question: Did you use the function (socket, connect, send) from the existing files of your application (CC3000 API)?

    Thank you

    Regards

    Nicola

  • Nicola Mazzucato said:
    I can modify the program as your 3 steps. But how can I do to read packets?

    u can use the software "wireshark" at the receiving receiving computer using which you can track the TCP packets.

    Nicola Mazzucato said:
    Did you use the function (socket, connect, send) from the existing files of your application (CC3000 API)?

    Yes, I did not find any issues with these APIs..

  • Hi pedro,

    chethu gowda said:
    I could establish the tcp connection and send the data.

    On that day I just had to verify the TCP communication and was totally involved in UDP operation so checked sending only one TCP packet.

    However now when I am trying to send multiple TCP packets but only the first TCP packet is being received at the TCP server end.

    what could be the reason for this?

  • Are you able to check with Wireshark on the receiving end, to see if you are getting the packets. You should be able to send multiple TCP packets.  Could you post the code you are using.  

    Pedro

  • Pedro5084 said:
    Are you able to check with Wireshark on the receiving end, to see if you are getting the packets

    There seems to be a problem in the windows TCP socket (). I wrote a TCP server application on linux machine which will be listening constantly . Using this I am able to receive all the TCP packets sent from CC3000.

  • Hi Chethu,

    I Follow the steps involved in sending the TCP packets,

    1. Open the socket: socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)
    2. Connect to the destination server: connect (ulSocket,  &tSocketAddr, sizeof(sockaddr))
    3. Send data: send(ulSocket, pcData, ulDataLenght,0)

      It is no data in Wireshark.
      UDP is ok to send.
      Can you give me some suggest?