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.

[参考译文] CC3235S:CC3235S:HttpClient_sendRequest ()从函数返回最多5分钟

Guru**** 2482105 points
Other Parts Discussed in Thread: CC3235S

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1326484/cc3235s-cc3235s-httpclient_sendrequest-takes-up-to-5-minutes-to-return-from-the-function

器件型号:CC3235S

我们正在运行 simplelink_cc32xx_sdk_5_20_00_06。我们通过 Wi-Fi 热点将数据发送到服务器。

发送数据时断开无线热点。
大约30秒后、打开 Wi-Fi 热点。

根据 Log 信息、调用系统函数来发送数据大约需要5分钟。

日志信息如下:

[ 2024年02月20日12:45:29.443] HttpClient_sendRequest Begin
[ 2024年02月20日12:45:29.809][Event] STA 已从 AP 断开连接(原因代码= 1)

[ 2024年02月20日12:45:59.383]正在连接到: xxx

[ 2024年02月20日12:46:05.322][事件] STA 已连接至 AP - BSSID:96:A2:43:32:09:15、SSID:xxx
[NetApp 12:46:06.092] 2024年02月20日 event] IP acquired:IP=192.168.74.144,Gateway=192.168.74.171

[ 2024年02月20日12:50:39.899] HttpClient_sendRequest 停止
[ 2024年02月20日12:50:39.899]发送成功201

系统功能调用参考如下所示、

    UART_PRINT("HTTPClient_sendRequest  begin \n\r");
    ret = HTTPClient_sendRequest(httpHandle,HTTP_METHOD_PUT,s_PutRequestUrl,
										(const char*)cloudData,strlen(cloudData),
										0);
    UART_PRINT("HTTPClient_sendRequest  stop \n\r");

    if(ret < 0){
        UART_PRINT("%s: send failed: %d\n\r", serverName,ret);
        PutRequestUrl();
    }else{
        UART_PRINT("%s: send success %d\n\r", serverName,ret);
    }
    memset(errorCode,0,50);

    HTTPClient_readResponseBody(httpHandle,errorCode,50,&flag);


如果想要使用 HttpClient_sendRequest ()函数发送数据,是否可以立即返回回复结果?
或者有一种方法可以  在 Wi-Fi 热点断开时停止通过 HttpClient_sendRequest ()向服务器发送数据。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我需要查看空气嗅探器日志和/或 NWP 日志、从而更好地了解长时间延迟的根本原因。

    HttpClient 代码可供使用(在 source/ti/net/http/下)、您可以修改它以便在 Wi-Fi 未连接时停止(例如、您可以使用基于 SimplelinkWlanEventHandler 保存该值的全局变量)。  

    但是、通常不建议混合处理不同网络层。

    我们更好地找出造成长延迟的根本原因(例如基于监听器日志)并进行修复。   

    您还可以将 httpClient.c 添加到工程中(因此它将使用应用程序进行编译、从而覆盖库实现)、并添加调试消息以查找它等待的位置。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    抱歉、NWP 日志不能立即提供。
    无法将 HttpClient.c 添加到项目中,因为 falsh 空间不足。

    在 HttpClient_sendRequest ()函数标题中有以下描述:

    /*!
        \brief  Make an HTTP request to the HTTP server
    
        Sends an HTTP request-line, header fields and body to the requested URI.
        After sending the request, the request function waits for the response Status
        and Header-Fields.
        According to the response status, the request function determines whether to
        return to user or to call a redirect/callback pre-defined function.
    
    
        \param[in]  client     Instance of an HTTP client.
    
        \param[in]  method     HTTP method.
    
        \param[in]  requestURI The path on the server to open.
    
        \param[in]  body       The body the user wishes to send in in the request,
                               The body can be chunked or one body buffer.
    
        \param[in]  bodyLen    Length of the body sent in the request.
    
        \param[in]  flags      Special flags when the user wishes not to use the
                               default settings.
                               - #HTTPClient_CHUNK_START - First request body chunk.
                               - #HTTPClient_CHUNK_END - Last request body chunk.
                               - #HTTPClient_DROP_BODY - only keep the status code
                                 and response headers, the response body will be
                                 dropped.
    
        \note       - If user wishes to use TLS connection then before calling
                      HTTPClient_sendRequest(), HTTPClient_connect() should be
                      called.
                    - If disconnection happened prior to HTTPClient_sendRequest(),
                      HTTPClient_sendRequest() will reconnect internally.
                    - When sending a body in a request, the "Content-length: " and
                      "Transfer-Encoding: Chunked" headers will be added
                      automatically.
    
        \return     Response status code on success or error code on failure.
     */
    int16_t HTTPClient_sendRequest(HTTPClient_Handle client, const char *method,const char *requestURI, const char *body, uint32_t bodyLen, uint32_t flags);
    

    -如果断开连接发生在 HttpClient_sendRequest ()之前,
    HttpClient_sendRequest()将在内部重新连接。

    关于上面红色部分中的内容、
    如果您 在调用 HttpClient_sendRequest ()之前关闭 Wi-Fi 热点,然后  在20秒后打开 Wi-Fi 热点,重新连接是否会 继续?

    重新连接需要多长时间?


    在什么情况下,HttpClient_sendRequest()将退出执行。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    在功能标题注释上有关于重新连接的注释,请回复我的问题,谢谢。
    注释如下所示

    标识
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    CC32xx  在 连接扫描之间的间隔方面使用了回退算法-因此 重新连接可能会有延迟(但可能约为10秒或更短)。 在日志中可以看到该信息。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    如何在 CC3235S 中捕获 NWP 日志? 是否有一些指南?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    对于这种问题、最好检查空气嗅探器日志。

    但是、NWP 日志可能会有所帮助、相关说明可参见 程序员指南的第20章