Update HAL_UDP_module.c

This commit is contained in:
David Lin
2020-04-26 20:56:56 +08:00
committed by GitHub
parent b64c6ee9dd
commit 373527e2c0

View File

@@ -32,16 +32,15 @@
uintptr_t HAL_UDP_Connect(const char *host, unsigned short port) uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
{ {
int fd; int fd;
char port_str[PORT_BUFF_LEN]; char port_str[PORT_BUFF_LEN] = {0};
memset(port_str, 0, PORT_BUFF_LEN);
snprintf(port_str, PORT_BUFF_LEN, "%u", port); snprintf(port_str, PORT_BUFF_LEN, "%u", port);
Log_i("osal_udp_connect entry, host=%s port=%d(%s)", host , port, port_str); Log_i("osal_udp_connect entry, host=%s port=%d(%s)", host , port, port_str);
fd = tos_sal_module_connect("111.230.127.136", "5684", TOS_SAL_PROTO_UDP); fd = tos_sal_module_connect("111.230.127.136", "5684", TOS_SAL_PROTO_UDP);
if (fd < 0) { if (fd < 0) {
Log_i("net connect fail\n\r"); Log_i("net connect fail\n\r");
if (QCLOUD_RET_SUCCESS == tos_sal_module_init()) { /* ÖØÐ³õʼ»¯Ä£×é */ if (QCLOUD_RET_SUCCESS == tos_sal_module_init()) {
Log_i("net reinit success\n\r"); Log_i("net reinit success\n\r");
fd = tos_sal_module_connect(host, port_str, TOS_SAL_PROTO_UDP); fd = tos_sal_module_connect(host, port_str, TOS_SAL_PROTO_UDP);
if (fd < 0) { if (fd < 0) {
@@ -115,4 +114,4 @@ int HAL_UDP_ReadTimeout(uintptr_t fd, unsigned char *p_data, unsigned int datale
return QCLOUD_RET_SUCCESS; return QCLOUD_RET_SUCCESS;
} }
#endif #endif/*COAP_COMM_ENABLED*/