Update HAL_UDP_module.c
This commit is contained in:
@@ -32,31 +32,30 @@
|
|||||||
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) {
|
||||||
Log_i("net connect fail\n\r");
|
Log_i("net connect fail\n\r");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
Log_i("net connect success, fd=%d\n\r", fd);
|
Log_i("net connect success, fd=%d\n\r", fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log_i("net reinit fail\n\r");
|
Log_i("net reinit fail\n\r");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UDP_Disconnect(uintptr_t fd)
|
void HAL_UDP_Disconnect(uintptr_t fd)
|
||||||
@@ -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*/
|
||||||
|
Reference in New Issue
Block a user