Merge pull request #89 from qiyongzhong0/fix_bug_bc26

fix bug and remove useless code
This commit is contained in:
朱天龙 (Armink) 2019-12-23 06:17:24 -06:00 committed by GitHub
commit aba95ea380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 24 deletions

View File

@ -40,8 +40,6 @@ static int bc26_power_on(struct at_device *device)
{ {
struct at_device_bc26 *bc26 = RT_NULL; struct at_device_bc26 *bc26 = RT_NULL;
RT_ASSERT(device);
bc26 = (struct at_device_bc26 *)device->user_data; bc26 = (struct at_device_bc26 *)device->user_data;
bc26->power_status = RT_TRUE; bc26->power_status = RT_TRUE;
@ -63,8 +61,6 @@ static int bc26_power_off(struct at_device *device)
at_response_t resp = RT_NULL; at_response_t resp = RT_NULL;
struct at_device_bc26 *bc26 = RT_NULL; struct at_device_bc26 *bc26 = RT_NULL;
RT_ASSERT(device);
resp = at_create_resp(64, 0, rt_tick_from_millisecond(300)); resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
if (resp == RT_NULL) if (resp == RT_NULL)
{ {
@ -91,8 +87,6 @@ static int bc26_sleep(struct at_device *device)
{ {
at_response_t resp = RT_NULL; at_response_t resp = RT_NULL;
struct at_device_bc26 *bc26 = RT_NULL; struct at_device_bc26 *bc26 = RT_NULL;
RT_ASSERT(device);
bc26 = (struct at_device_bc26 *)device->user_data; bc26 = (struct at_device_bc26 *)device->user_data;
if ( ! bc26->power_status)//power off if ( ! bc26->power_status)//power off
@ -135,9 +129,7 @@ static int bc26_wakeup(struct at_device *device)
{ {
at_response_t resp = RT_NULL; at_response_t resp = RT_NULL;
struct at_device_bc26 *bc26 = RT_NULL; struct at_device_bc26 *bc26 = RT_NULL;
RT_ASSERT(device);
bc26 = (struct at_device_bc26 *)device->user_data; bc26 = (struct at_device_bc26 *)device->user_data;
if ( ! bc26->power_status)//power off if ( ! bc26->power_status)//power off
{ {
@ -182,16 +174,13 @@ static int bc26_check_link_status(struct at_device *device)
at_response_t resp = RT_NULL; at_response_t resp = RT_NULL;
struct at_device_bc26 *bc26 = RT_NULL; struct at_device_bc26 *bc26 = RT_NULL;
int result = -RT_ERROR; int result = -RT_ERROR;
RT_ASSERT(device); bc26 = (struct at_device_bc26 *)device->user_data;
if ( ! bc26->power_status)//power off if ( ! bc26->power_status)//power off
{ {
LOG_D("the power is off."); LOG_D("the power is off.");
return(-RT_ERROR); return(-RT_ERROR);
} }
bc26 = (struct at_device_bc26 *)device->user_data;
if (bc26->sleep_status)//is sleep status if (bc26->sleep_status)//is sleep status
{ {
if (bc26->power_pin != -1) if (bc26->power_pin != -1)
@ -874,8 +863,11 @@ static int bc26_net_init(struct at_device *device)
static int bc26_init(struct at_device *device) static int bc26_init(struct at_device *device)
{ {
struct at_device_bc26 *bc26 = (struct at_device_bc26 *) device->user_data; struct at_device_bc26 *bc26 = RT_NULL;
RT_ASSERT(device);
bc26 = (struct at_device_bc26 *) device->user_data;
bc26->power_status = RT_FALSE;//default power is off. bc26->power_status = RT_FALSE;//default power is off.
bc26->sleep_status = RT_FALSE;//default sleep is disabled. bc26->sleep_status = RT_FALSE;//default sleep is disabled.
@ -915,6 +907,8 @@ static int bc26_init(struct at_device *device)
static int bc26_deinit(struct at_device *device) static int bc26_deinit(struct at_device *device)
{ {
RT_ASSERT(device);
return bc26_netdev_set_down(device->netdev); return bc26_netdev_set_down(device->netdev);
} }

View File

@ -446,8 +446,7 @@ static int bc26_domain_resolve(const char *name, char ip[16])
int i, result; int i, result;
at_response_t resp = RT_NULL; at_response_t resp = RT_NULL;
struct at_device *device = RT_NULL; struct at_device *device = RT_NULL;
struct at_device_bc26 *bc26 = (struct at_device_bc26 *) device->user_data; struct at_device_bc26 *bc26 = RT_NULL;
char *recv_ip = (char *) bc26->socket_data;
RT_ASSERT(name); RT_ASSERT(name);
RT_ASSERT(ip); RT_ASSERT(ip);
@ -489,10 +488,7 @@ static int bc26_domain_resolve(const char *name, char ip[16])
} }
else else
{ {
//struct at_device_bc26 *bc26 = (struct at_device_bc26 *) device->user_data; if (rt_strlen(ip) < 8)
//char *recv_ip = (char *) bc26->socket_data;
if (rt_strlen(recv_ip) < 8)
{ {
rt_thread_mdelay(100); rt_thread_mdelay(100);
/* resolve failed, maybe receive an URC CRLF */ /* resolve failed, maybe receive an URC CRLF */
@ -501,8 +497,6 @@ static int bc26_domain_resolve(const char *name, char ip[16])
} }
else else
{ {
//rt_strncpy(ip, recv_ip, 15);
//ip[15] = '\0';
result = RT_EOK; result = RT_EOK;
break; break;
} }
@ -510,6 +504,7 @@ static int bc26_domain_resolve(const char *name, char ip[16])
} }
__exit: __exit:
bc26->socket_data = RT_NULL;
if (resp) if (resp)
{ {
at_delete_resp(resp); at_delete_resp(resp);
@ -576,6 +571,7 @@ static void urc_send_func(struct at_client *client, const char *data, rt_size_t
LOG_E("get device(%s) failed.", client_name); LOG_E("get device(%s) failed.", client_name);
return; return;
} }
bc26 = (struct at_device_bc26 *) device->user_data; bc26 = (struct at_device_bc26 *) device->user_data;
device_socket = (int) bc26->user_data; device_socket = (int) bc26->user_data;