Merge pull request #96 from ethanDu1/bugfix_at_close_socket_error

at close socket error
This commit is contained in:
朱天龙 (Armink) 2020-01-14 00:43:54 -06:00 committed by GitHub
commit 4730f31d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 46 deletions

View File

@ -88,22 +88,14 @@ static int air720_socket_close(struct at_socket *socket)
{
uint32_t event = 0;
int result = RT_EOK;
at_response_t resp = RT_NULL;
int device_socket = (int)socket->user_data;
struct at_device *device = (struct at_device *)socket->device;
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
if (resp == RT_NULL)
{
LOG_E("no memory for air720 device(%s) response structure.", device->name);
return -RT_ENOMEM;
}
/* clear socket close event */
event = SET_EVENT(device_socket, AIR720_EVNET_CLOSE_OK);
air720_socket_event_recv(device, event, 0, RT_EVENT_FLAG_OR);
if (at_obj_exec_cmd(device->client, resp, "AT+CIPCLOSE=%d", device_socket) < 0)
if (at_obj_exec_cmd(device->client, NULL, "AT+CIPCLOSE=%d", device_socket) < 0)
{
result = -RT_ERROR;
goto __exit;
@ -117,11 +109,6 @@ static int air720_socket_close(struct at_socket *socket)
}
__exit:
if (resp)
{
at_delete_resp(resp);
}
return result;
}

View File

@ -84,21 +84,13 @@ static int m26_socket_event_recv(struct at_device *device, uint32_t event, uint3
static int m26_socket_close(struct at_socket *socket)
{
int result = 0;
at_response_t resp = RT_NULL;
int device_socke = (int) socket->user_data;
struct at_device *device = (struct at_device *) socket->device;
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
if (resp == RT_NULL)
{
LOG_E("no memory for resp create.", device->name);
return -RT_ENOMEM;
}
/* clear socket close event */
m26_socket_event_recv(device, SET_EVENT(device_socke, M26_EVNET_CLOSE_OK), 0, RT_EVENT_FLAG_OR);
if (at_obj_exec_cmd(device->client, resp, "AT+QICLOSE=%d", device_socke) < 0)
if (at_obj_exec_cmd(device->client, NULL, "AT+QICLOSE=%d", device_socke) < 0)
{
result = -RT_ERROR;
goto __exit;
@ -113,11 +105,6 @@ static int m26_socket_close(struct at_socket *socket)
}
__exit:
if (resp)
{
at_delete_resp(resp);
}
return result;
}

View File

@ -84,22 +84,14 @@ static int sim800c_socket_close(struct at_socket *socket)
{
uint32_t event = 0;
int result = RT_EOK;
at_response_t resp = RT_NULL;
int device_socket = (int) socket->user_data;
struct at_device *device = (struct at_device *) socket->device;
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
if (resp == RT_NULL)
{
LOG_E("no memory for resp create.");
return -RT_ENOMEM;
}
/* clear socket close event */
event = SET_EVENT(device_socket, SIM800C_EVNET_CLOSE_OK);
sim800c_socket_event_recv(device, event, 0, RT_EVENT_FLAG_OR);
if (at_obj_exec_cmd(device->client, resp, "AT+CIPCLOSE=%d", device_socket) < 0)
if (at_obj_exec_cmd(device->client, NULL, "AT+CIPCLOSE=%d", device_socket) < 0)
{
result = -RT_ERROR;
goto __exit;
@ -112,12 +104,7 @@ static int sim800c_socket_close(struct at_socket *socket)
goto __exit;
}
__exit:
if (resp)
{
at_delete_resp(resp);
}
__exit:
return result;
}