Skip to content

Commit 115417d

Browse files
authored
Merge pull request #159 from qiyongzhong0/master
fix n720 bug and warning
2 parents 398efbc + b618631 commit 115417d

File tree

2 files changed

+22
-41
lines changed

2 files changed

+22
-41
lines changed

class/n720/at_device_n720.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int n720_power_off(struct at_device *device)
130130

131131
static int n720_sleep(struct at_device *device)
132132
{
133-
at_response_t resp = RT_NULL;
133+
//at_response_t resp = RT_NULL;
134134
struct at_device_n720 *n720 = RT_NULL;
135135

136136
n720 = (struct at_device_n720 *)device->user_data;
@@ -175,7 +175,7 @@ static int n720_sleep(struct at_device *device)
175175

176176
static int n720_wakeup(struct at_device *device)
177177
{
178-
at_response_t resp = RT_NULL;
178+
//at_response_t resp = RT_NULL;
179179
struct at_device_n720 *n720 = RT_NULL;
180180

181181
n720 = (struct at_device_n720 *)device->user_data;

class/n720/at_socket_n720.c

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,6 @@ static at_evt_cb_t at_evt_cb_set[] = {
5151
[AT_SOCKET_EVT_CLOSED] = NULL,
5252
};
5353

54-
static int n720_socket_event_send(struct at_device *device, uint32_t event)
55-
{
56-
return (int) rt_event_send(device->socket_event, event);
57-
}
58-
59-
static int n720_socket_event_recv(struct at_device *device, uint32_t event, uint32_t timeout, rt_uint8_t option)
60-
{
61-
int result = RT_EOK;
62-
rt_uint32_t recved;
63-
64-
result = rt_event_recv(device->socket_event, event, option | RT_EVENT_FLAG_CLEAR, timeout, &recved);
65-
if (result != RT_EOK)
66-
{
67-
return -RT_ETIMEOUT;
68-
}
69-
70-
return recved;
71-
}
72-
7354
/**
7455
* close socket by AT commands.
7556
*
@@ -118,7 +99,6 @@ static int n720_socket_close(struct at_socket *socket)
11899
static int n720_socket_connect(struct at_socket *socket, char *ip, int32_t port,
119100
enum at_socket_type type, rt_bool_t is_client)
120101
{
121-
int result = 0;
122102
int type_val = 0;
123103
at_response_t resp = RT_NULL;
124104
int device_socket = (int) socket->user_data;
@@ -163,7 +143,7 @@ static int n720_socket_connect(struct at_socket *socket, char *ip, int32_t port,
163143
{
164144
at_delete_resp(resp);
165145
LOG_E("%s device socket(%d) connect failed.", device->name, device_socket);
166-
result = -RT_ERROR;
146+
return -RT_ERROR;
167147
}
168148

169149
at_delete_resp(resp);
@@ -240,8 +220,7 @@ static int at_wait_send_finish(struct at_socket *socket, size_t settings_size)
240220
*/
241221
static int n720_socket_send(struct at_socket *socket, const char *buff, size_t bfsz, enum at_socket_type type)
242222
{
243-
uint32_t event = 0;
244-
int result = 0, event_result = 0;
223+
int result = 0;
245224
size_t cur_pkt_size = 0, sent_size = 0;
246225
at_response_t resp = RT_NULL;
247226
int device_socket = (int) socket->user_data;
@@ -355,8 +334,6 @@ static int n720_domain_resolve(const char *name, char ip[16])
355334

356335
for (i = 0; i < RESOLVE_RETRY; i++)
357336
{
358-
int err_code = 0;
359-
360337
if (at_obj_exec_cmd(device->client, resp, "AT+DNS=%s", name) < 0)
361338
{
362339
result = -RT_ERROR;
@@ -437,14 +414,25 @@ static void urc_close_func(struct at_client *client, const char *data, rt_size_t
437414
}
438415
}
439416

417+
static void send_net_read(struct at_client *client, int device_socket)
418+
{
419+
char *send_buf = (char *) rt_malloc(128);
420+
if (send_buf == RT_NULL)
421+
{
422+
return;
423+
}
424+
425+
rt_sprintf(send_buf, "AT$MYNETREAD=%d,%d\r\n", device_socket, N720_MODULE_SEND_MAX_SIZE);
426+
at_client_obj_send(client, send_buf, strlen(send_buf));
427+
428+
rt_free(send_buf);
429+
}
430+
440431
static void urc_recv_func(struct at_client *client, const char *data, rt_size_t size)
441432
{
442433
int device_socket = 0;
443-
struct at_socket *socket = RT_NULL;
444434
struct at_device *device = RT_NULL;
445435
char *client_name = client->device->parent.name;
446-
char *send_buf = RT_NULL;
447-
int len;
448436

449437
RT_ASSERT(data && size);
450438

@@ -459,23 +447,15 @@ static void urc_recv_func(struct at_client *client, const char *data, rt_size_t
459447
{
460448
return;
461449
}
462-
send_buf = (char *) rt_malloc(128);
463-
if (send_buf == RT_NULL)
464-
{
465-
return;
466-
}
467450

468-
rt_sprintf(send_buf, "AT$MYNETREAD=%d,%d\r\n", device_socket, N720_MODULE_SEND_MAX_SIZE);
469-
at_client_obj_send(client, send_buf, strlen(send_buf));
470-
471-
rt_free(send_buf);
451+
send_net_read(client, device_socket);
472452
}
473453

474454
static void read_ack_func(struct at_client *client, const char *data, rt_size_t size)
475455
{
476456
int device_socket = 0;
477457
rt_int32_t timeout;
478-
rt_size_t bfsz = 0, temp_size = 0;
458+
int bfsz = 0, temp_size = 0;
479459
char *recv_buf = RT_NULL, temp[8] = {0};
480460
struct at_socket *socket = RT_NULL;
481461
struct at_device *device = RT_NULL;
@@ -536,7 +516,8 @@ static void read_ack_func(struct at_client *client, const char *data, rt_size_t
536516
{
537517
at_evt_cb_set[AT_SOCKET_EVT_RECV](socket, AT_SOCKET_EVT_RECV, recv_buf, bfsz);
538518
}
539-
519+
520+
send_net_read(client, device_socket);
540521
}
541522

542523
static const struct at_urc urc_table[] =

0 commit comments

Comments
 (0)