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.

[参考译文] CC3220S-LAUNCHXL:检查是否已连接到 HTTP 主机

Guru**** 2578945 points


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

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/753098/cc3220s-launchxl-check-if-connected-to-http-host

器件型号:CC3220S-LAUNCHXL

您好!

我在代码开头创建并连接我的 httpClient、如下所示:

int16_t ret = 0;
int16_t statusCode;

HttpClient_extSecParams SecParams;
SecParams.clientCert = 0;
SecParams.privateKey = 0;
SecParams.RootCA ="Amazon.pem";


httpClientHandle = HttpClient_create (&statusCode、0);
if (statusCode < 0)
{
display_printf (display、0、0、"httpTask:创建 http 客户端句柄失败-%d\n"、
状态代码);
}

RET = HttpClient_connect (httpClientHandle、HOSTNAME&SecParams、0);
if (ret < 0)
{
display_printf (display、0、0、"httpTask:connect failed -%d\n"、ret);
}
其他
{
display_printf (display、0、0、"Conacoo!!!!!!!!!!! ");
SEM_post (已连接);
} 

现在、每次我尝试发送 HTTP 请求时、我都不必不断重新创建并重新连接到 HTTP 主机。 但是、为了确保这一点、我希望检查是否每次都实际创建了我的 https 客户端并将其连接到 HTTP 主机。 这种情况下、CC3220会由于各种原因而失去与 HTTP 主机的连接、例如 WiFi 连接、当前不可用的 HTTP 主机、互联网问题等 具体如何实现?

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

    如果 HTTP_Client_create 函数不返回错误(与 HttpClient_connect 相同),您就会知道您的客户端已创建。

    如果您断开互联网连接、SimpleLinkWlanEventHandler 将被触发、您必须检查是否发生 SL_WLAN_EVENT_DISCONNECT 事件。

    有关 HTTP 套接字错误的说明。 当您尝试使用 HttpClient_sendRequest()发送请求时,只需检查函数的返回是否有错误。

    Jesu