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.

TM4C1294NCPDT: Websocket Client Library/Example For TM4C1294NCPDT

Part Number: TM4C1294NCPDT

I need to connect my board to Websocket server which is working.I am able to handshake but when i send data to server using tcp with all websocket flags in it.It is not upgrading to Websocket and payload is working as tcp request. Please suggest a way so that i can Send data to server on websocket after handshake.Handshake is already done.I am sharing the wireshark logs.

  • int32_t
    WeatherForecast(tWeatherSource eWeatherSource, const char *pcQuery,
    tWeatherReport *psWeatherReport, tEventFunction pfnEvent)
    {
    int32_t i32Idx;
    // const char pcCount[] = "&cnt=1";

    //
    // If the requested source is not valid or there is no call back then
    // just fail.
    //
    // if((eWeatherSource != iWSrcOpenWeatherMap) || (g_sWeather.pfnEvent))
    // {
    // return (-1);
    // }
    if(eWeatherSource != iWSrcOpenWeatherMap)
    {
    if(g_sWeather.pfnEvent)
    {
    return (-1);
    }
    }
    g_sWeather.pfnEvent = pfnEvent;
    g_sWeather.psWeatherReport = psWeatherReport;

    // if(g_sEnet.eState == iEthNoConnection) return(0);
    //
    // Connect or reconnect to port 80.
    //
    // g_sEnet.eState = iEthTCPConnectWait;

    //
    // Copy the base forecast request to the buffer.
    //
    // i32Idx = MergeRequest1(0, g_cWeatherRequestForecast,
    // sizeof(g_cWeatherRequestForecast));

    //
    // Append the request.
    //
    //i32Idx = MergeRequest1(i32Idx, pcQuery, sizeof(g_sWeather.pcRequest));

    //
    // Append the request mode.
    //
    // i32Idx = MergeRequest1(i32Idx, g_cMode, sizeof(g_cMode));

    //
    // Append the count.
    //
    //i32Idx = MergeRequest1(i32Idx, pcCount, sizeof(pcCount));

    //
    // Append the App ID.
    //
    // i32Idx = MergeRequest1(i32Idx, g_cAPPIDOpenWeather,
    // sizeof(g_cAPPIDOpenWeather));

    //
    // Append the "HTTP:/1.1" string.
    //
    // i32Idx = MergeRequest1(i32Idx, g_cHTTP11, sizeof(g_cHTTP11));
    // UARTprintf("\n\t%s",g_sWeather.pcRequest);
    //
    // Forcast weather report request.
    //
    // g_sEnet.ulRequest = WEATHER_FORECAST;
    // i32Idx = MergeRequest1(0,Get,sizeof(Get));
    i32Idx = MergeRequest1(0,Webpack,sizeof(Webpack));
    ProcessTransmit.TransmitLength = ReqFunctions[ProcessTransmit.TransmitIndex[e_IdCallResult]]();
    i32Idx = MergeRequest1(i32Idx, Response, ProcessTransmit.TransmitLength);

    if(WebSocket.HandshakeInprogress==1)
    {
    i32Idx = MergeRequest1(0, cmd_1, sizeof(cmd_1));
    i32Idx = MergeRequest1(i32Idx, cmd_2, sizeof(cmd_2));
    i32Idx = MergeRequest1(i32Idx, cmd_3, sizeof(cmd_3));
    i32Idx = MergeRequest1(i32Idx, cmd_4, sizeof(cmd_4));
    i32Idx = MergeRequest1(i32Idx, cmd_5, sizeof(cmd_5));
    i32Idx = MergeRequest1(i32Idx, cmd_6, sizeof(cmd_6));

    /*
    i32Idx = MergeRequest1(i32Idx,Webpack,sizeof(Webpack));
    ProcessTransmit.TransmitLength = ReqFunctions[ProcessTransmit.TransmitIndex[e_IdCallResult]]();
    i32Idx = MergeRequest1(i32Idx, Response, ProcessTransmit.TransmitLength);
    */
    }
    if(EthClientTCPConnect(3002) != ERR_OK)
    {
    return(-1);
    }
    //
    // Save the size of the request.
    //
    g_sWeather.ui32RequestSize = i32Idx;

    return(0);
    }

  • This is the code i used, This code is Modified from enet_weather example code.

    I need to implement Websocket in my existing project where TCP and HTTP are working Fine.

  • Hi Pradeep,

      Sorry, we have no experience with Websocket protocol at all. I will suggest you use the wireshark to capture the network traffic to understand what is going one compared to the HTTP protocol.

  • Ok Charles than im closing the issue.