at close socket error

This commit is contained in:
ethan.du 2020-01-14 14:08:08 +08:00
parent e7d7b9baa8
commit b51cfaea2a
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;
}