Преглед изворни кода

delete useless update; code formate

shao7936626 пре 5 година
родитељ
комит
1e6b01f5e2
3 измењених фајлова са 152 додато и 160 уклоњено
  1. 22 22
      class/air720/at_device_air720.c
  2. 0 4
      class/air720/at_socket_air720.c
  3. 130 134
      class/bc26/at_device_bc26.c

+ 22 - 22
class/air720/at_device_air720.c

@@ -491,18 +491,18 @@ static int air720_netdev_ping(struct netdev *netdev, const char *host,
         return -RT_ERROR;
     }
 
-    // for (i = 0; i < rt_strlen(host) && !isalpha(host[i]); i++)
-    //     ;
-
-    // if (i < strlen(host))
-    // {
-    //     /* check domain name is usable */
-    //     if (air720_ping_domain_resolve(device, host, ip_addr) < 0)
-    //     {
-    //         return -RT_ERROR;
-    //     }
-    //     rt_memset(ip_addr, 0x00, air720_PING_IP_SIZE);
-    // }
+    for (i = 0; i < rt_strlen(host) && !isalpha(host[i]); i++)
+        ;
+
+    if (i < strlen(host))
+    {
+        /* check domain name is usable */
+        if (air720_ping_domain_resolve(device, host, ip_addr) < 0)
+        {
+            return -RT_ERROR;
+        }
+        rt_memset(ip_addr, 0x00, air720_PING_IP_SIZE);
+    }
 
     resp = at_create_resp(air720_PING_RESP_SIZE, 0, air720_PING_TIMEO);
     if (resp == RT_NULL)
@@ -512,16 +512,16 @@ static int air720_netdev_ping(struct netdev *netdev, const char *host,
         goto __exit;
     }
 
-    // /* domain name prase error options */
-    // if (at_resp_parse_line_args_by_kw(resp, "+CDNSGIP: 0", "+CDNSGIP: 0,%d", &err_code) > 0)
-    // {
-    //     /* 3 - network error, 8 - dns common error */
-    //     if (err_code == 3 || err_code == 8)
-    //     {
-    //         result = -RT_ERROR;
-    //         goto __exit;
-    //     }
-    // }
+    /* domain name prase error options */
+    if (at_resp_parse_line_args_by_kw(resp, "+CDNSGIP: 0", "+CDNSGIP: 0,%d", &err_code) > 0)
+    {
+        /* 3 - network error, 8 - dns common error */
+        if (err_code == 3 || err_code == 8)
+        {
+            result = -RT_ERROR;
+            goto __exit;
+        }
+    }
 
     /* send "AT+CIPPING=<IP addr>[,<retryNum>[,<dataLen>[,<timeout>[,<ttl>]]]]" commond to send ping request */
     if (at_obj_exec_cmd(device->client, resp, "AT+CIPPING=%s,1,%d,%d,64",

+ 0 - 4
class/air720/at_socket_air720.c

@@ -337,10 +337,6 @@ __exit:
     return result;
 }
 
-static int air720_socket_quick_send(struct at_socket *socket, const char *buff, size_t bfsz, enum at_socket_type type)
-{
-}
-
 /**
  * domain resolve by AT commands.
  *

+ 130 - 134
class/bc26/at_device_bc26.c

@@ -27,136 +27,136 @@
 
 #include <at_device_bc26.h>
 
-#define LOG_TAG                         "at.dev.bc26"
+#define LOG_TAG "at.dev.bc26"
 #include <at_log.h>
 
 #ifdef AT_DEVICE_USING_BC26
 
-#define BC26_WAIT_CONNECT_TIME          5000
-#define BC26_THREAD_STACK_SIZE          2048
-#define BC26_THREAD_PRIORITY            (RT_THREAD_PRIORITY_MAX/2)
+#define BC26_WAIT_CONNECT_TIME 5000
+#define BC26_THREAD_STACK_SIZE 2048
+#define BC26_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX / 2)
 
 static int bc26_power_on(struct at_device *device)
 {
     struct at_device_bc26 *bc26 = RT_NULL;
-    
+
     bc26 = (struct at_device_bc26 *)device->user_data;
     bc26->power_status = RT_TRUE;
 
     /* not nead to set pin configuration for bc26 device power on */
     if (bc26->power_pin == -1)
     {
-        return(RT_EOK);
+        return (RT_EOK);
     }
-    
+
     rt_pin_write(bc26->power_pin, PIN_HIGH);
     rt_thread_mdelay(500);
     rt_pin_write(bc26->power_pin, PIN_LOW);
 
-    return(RT_EOK);
+    return (RT_EOK);
 }
 
 static int bc26_power_off(struct at_device *device)
 {
     at_response_t resp = RT_NULL;
     struct at_device_bc26 *bc26 = RT_NULL;
-    
+
     resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
     if (resp == RT_NULL)
     {
         LOG_D("no memory for resp create.");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     if (at_obj_exec_cmd(device->client, resp, "AT+QPOWD=0") != RT_EOK)
     {
         LOG_D("power off fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     at_delete_resp(resp);
-    
+
     bc26 = (struct at_device_bc26 *)device->user_data;
     bc26->power_status = RT_FALSE;
-    
-    return(RT_EOK);
+
+    return (RT_EOK);
 }
 
 static int bc26_sleep(struct at_device *device)
 {
     at_response_t resp = RT_NULL;
     struct at_device_bc26 *bc26 = RT_NULL;
-    
+
     bc26 = (struct at_device_bc26 *)device->user_data;
-    if ( ! bc26->power_status)//power off
+    if (!bc26->power_status) //power off
     {
-        return(RT_EOK);
+        return (RT_EOK);
     }
-    if (bc26->sleep_status)//is sleep status 
+    if (bc26->sleep_status) //is sleep status
     {
-        return(RT_EOK);
+        return (RT_EOK);
     }
-    
+
     resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
     if (resp == RT_NULL)
     {
         LOG_D("no memory for resp create.");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
 
     /* enable sleep mode */
     if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=1") != RT_EOK)
-        
+
     {
         LOG_D("enable sleep fail.\"AT+QSCLK=1\" execute fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     /* enable PSM mode */
     if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=1,,,\"01000011\",\"00000001\"") != RT_EOK)
-        
+
     {
         LOG_D("enable sleep fail.\"AT+CPSMS=1...\" execute fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
 
     if (at_obj_exec_cmd(device->client, resp, "AT+QRELLOCK") != RT_EOK)
     {
         LOG_D("startup entry into sleep fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     bc26->sleep_status = RT_TRUE;
-    
+
     at_delete_resp(resp);
-    return(RT_EOK);
+    return (RT_EOK);
 }
 
 static int bc26_wakeup(struct at_device *device)
 {
     at_response_t resp = RT_NULL;
     struct at_device_bc26 *bc26 = RT_NULL;
-    
+
     bc26 = (struct at_device_bc26 *)device->user_data;
-    if ( ! bc26->power_status)//power off
+    if (!bc26->power_status) //power off
     {
         LOG_E("the power is off and the wake-up cannot be performed");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    if ( ! bc26->sleep_status)//no sleep status
+    if (!bc26->sleep_status) //no sleep status
     {
-        return(RT_EOK);
+        return (RT_EOK);
     }
-    
+
     resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
     if (resp == RT_NULL)
     {
         LOG_D("no memory for resp create.");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
 
     if (bc26->power_pin != -1)
@@ -165,29 +165,29 @@ static int bc26_wakeup(struct at_device *device)
         rt_thread_mdelay(100);
         rt_pin_write(bc26->power_pin, PIN_LOW);
         rt_thread_mdelay(200);
-		rt_pin_write(bc26->power_pin, PIN_HIGH);
+        rt_pin_write(bc26->power_pin, PIN_HIGH);
     }
-    
+
     /* disable sleep mode */
     if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=0") != RT_EOK)
     {
         LOG_D("wake up fail. \"AT+QSCLK=0\" execute fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     /* disable PSM mode  */
     if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=0") != RT_EOK)
     {
         LOG_D("wake up fail.\"AT+CPSMS=0\" execute fail.");
         at_delete_resp(resp);
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    
+
     bc26->sleep_status = RT_FALSE;
-    
+
     at_delete_resp(resp);
-    return(RT_EOK);
+    return (RT_EOK);
 }
 
 static int bc26_check_link_status(struct at_device *device)
@@ -195,14 +195,14 @@ static int bc26_check_link_status(struct at_device *device)
     at_response_t resp = RT_NULL;
     struct at_device_bc26 *bc26 = RT_NULL;
     int result = -RT_ERROR;
-    
+
     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.");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
-    if (bc26->sleep_status)//is sleep status
+    if (bc26->sleep_status) //is sleep status
     {
         if (bc26->power_pin != -1)
         {
@@ -210,15 +210,15 @@ static int bc26_check_link_status(struct at_device *device)
             rt_thread_mdelay(100);
             rt_pin_write(bc26->power_pin, PIN_LOW);
             rt_thread_mdelay(200);
-			rt_pin_write(bc26->power_pin, PIN_HIGH);
+            rt_pin_write(bc26->power_pin, PIN_HIGH);
         }
     }
-    
+
     resp = at_create_resp(64, 0, rt_tick_from_millisecond(300));
     if (resp == RT_NULL)
     {
         LOG_D("no memory for resp create.");
-        return(-RT_ERROR);
+        return (-RT_ERROR);
     }
 
     result = -RT_ERROR;
@@ -234,26 +234,25 @@ static int bc26_check_link_status(struct at_device *device)
         }
     }
 
-    if (bc26->sleep_status)//is sleep status
+    if (bc26->sleep_status) //is sleep status
     {
         if (at_obj_exec_cmd(device->client, resp, "AT+QRELLOCK") != RT_EOK)
         {
             LOG_D("startup entry into sleep fail.");
         }
     }
-    
+
     at_delete_resp(resp);
-    
-    return(result);
-}
 
+    return (result);
+}
 
 /* =============================  bc26 network interface operations ============================= */
 /* set bc26 network interface device status and address information */
 static int bc26_netdev_set_info(struct netdev *netdev)
 {
-#define BC26_INFO_RESP_SIZE      128
-#define BC26_INFO_RESP_TIMO      rt_tick_from_millisecond(300)
+#define BC26_INFO_RESP_SIZE 128
+#define BC26_INFO_RESP_TIMO rt_tick_from_millisecond(300)
 
     int result = RT_EOK;
     ip_addr_t addr;
@@ -284,8 +283,8 @@ static int bc26_netdev_set_info(struct netdev *netdev)
 
     /* set network interface device hardware address(IMEI) */
     {
-        #define BC26_NETDEV_HWADDR_LEN   8
-        #define BC26_IMEI_LEN            15
+#define BC26_NETDEV_HWADDR_LEN 8
+#define BC26_IMEI_LEN 15
 
         char imei[BC26_IMEI_LEN] = {0};
         int i = 0, j = 0;
@@ -296,19 +295,19 @@ static int bc26_netdev_set_info(struct netdev *netdev)
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         if (at_resp_parse_line_args(resp, 2, "%s", imei) <= 0)
         {
             LOG_E("%s device prase \"AT+GSN\" cmd error.", device->name);
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         LOG_D("%s device IMEI number: %s", device->name, imei);
 
         netdev->hwaddr_len = BC26_NETDEV_HWADDR_LEN;
         /* get hardware address by IMEI */
-        for (i = 0, j = 0; i < BC26_NETDEV_HWADDR_LEN && j < BC26_IMEI_LEN; i++, j+=2)
+        for (i = 0, j = 0; i < BC26_NETDEV_HWADDR_LEN && j < BC26_IMEI_LEN; i++, j += 2)
         {
             if (j != BC26_IMEI_LEN - 1)
             {
@@ -323,9 +322,9 @@ static int bc26_netdev_set_info(struct netdev *netdev)
 
     /* set network interface device IP address */
     {
-        #define IP_ADDR_SIZE_MAX    16
+#define IP_ADDR_SIZE_MAX 16
         char ipaddr[IP_ADDR_SIZE_MAX] = {0};
-        
+
         /* send "AT+CGPADDR=1" commond to get IP address */
         if (at_obj_exec_cmd(device->client, resp, "AT+CGPADDR=1") != RT_EOK)
         {
@@ -350,9 +349,9 @@ static int bc26_netdev_set_info(struct netdev *netdev)
 
     /* set network interface device dns server */
     {
-        #define DNS_ADDR_SIZE_MAX   16
+#define DNS_ADDR_SIZE_MAX 16
         char dns_server1[DNS_ADDR_SIZE_MAX] = {0}, dns_server2[DNS_ADDR_SIZE_MAX] = {0};
-        
+
         /* send "AT+QIDNSCFG=1" commond to get DNS servers address */
         if (at_obj_exec_cmd(device->client, resp, "AT+QIDNSCFG=1") != RT_EOK)
         {
@@ -362,7 +361,7 @@ static int bc26_netdev_set_info(struct netdev *netdev)
 
         /* parse response data "+QIDNSCFG: <contextID>,<pridnsaddr>,<secdnsaddr>" */
         if (at_resp_parse_line_args_by_kw(resp, "+QIDNSCFG:", "+QIDNSCFG: 1,\"%[^\"]\",\"%[^\"]\"",
-                dns_server1, dns_server2) <= 0)
+                                          dns_server1, dns_server2) <= 0)
         {
             LOG_E("%s device prase \"AT+QIDNSCFG=1\" cmd error.", device->name);
             result = -RT_ERROR;
@@ -390,11 +389,11 @@ __exit:
 
 static void bc26_check_link_status_entry(void *parameter)
 {
-#define BC26_LINK_DELAY_TIME    (60 * RT_TICK_PER_SECOND)
+#define BC26_LINK_DELAY_TIME (60 * RT_TICK_PER_SECOND)
 
     rt_bool_t is_link_up;
     struct at_device *device = RT_NULL;
-    struct netdev *netdev = (struct netdev *) parameter;
+    struct netdev *netdev = (struct netdev *)parameter;
 
     device = at_device_get_by_name(AT_DEVICE_NAMETYPE_NETDEV, netdev->name);
     if (device == RT_NULL)
@@ -402,7 +401,7 @@ static void bc26_check_link_status_entry(void *parameter)
         LOG_E("get device(%s) failed.", netdev->name);
         return;
     }
-    
+
     while (1)
     {
         is_link_up = (bc26_check_link_status(device) == RT_EOK);
@@ -415,9 +414,9 @@ static void bc26_check_link_status_entry(void *parameter)
 
 static int bc26_netdev_check_link_status(struct netdev *netdev)
 {
-#define BC26_LINK_THREAD_TICK           20
-#define BC26_LINK_THREAD_STACK_SIZE     (1024 + 512)
-#define BC26_LINK_THREAD_PRIORITY       (RT_THREAD_PRIORITY_MAX - 2)
+#define BC26_LINK_THREAD_TICK 20
+#define BC26_LINK_THREAD_STACK_SIZE (1024 + 512)
+#define BC26_LINK_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX - 2)
 
     rt_thread_t tid;
     char tname[RT_NAME_MAX] = {0};
@@ -487,8 +486,8 @@ static int bc26_netdev_set_down(struct netdev *netdev)
 
 static int bc26_netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, ip_addr_t *dns_server)
 {
-#define BC26_DNS_RESP_LEN    64
-#define BC26_DNS_RESP_TIMEO  rt_tick_from_millisecond(300)
+#define BC26_DNS_RESP_LEN 64
+#define BC26_DNS_RESP_TIMEO rt_tick_from_millisecond(300)
 
     int result = RT_EOK;
     at_response_t resp = RT_NULL;
@@ -513,8 +512,8 @@ static int bc26_netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, ip
     }
 
     /* send "AT+QIDNSCFG=<pri_dns>[,<sec_dns>]" commond to set dns servers */
-    if (at_obj_exec_cmd(device->client, resp, "AT+QIDNSCFG=%d,%s", 
-        dns_num, inet_ntoa(*dns_server)) != RT_EOK)
+    if (at_obj_exec_cmd(device->client, resp, "AT+QIDNSCFG=%d,%s",
+                        dns_num, inet_ntoa(*dns_server)) != RT_EOK)
     {
         result = -RT_ERROR;
         goto __exit;
@@ -533,11 +532,11 @@ __exit:
 
 #ifdef NETDEV_USING_PING
 static int bc26_netdev_ping(struct netdev *netdev, const char *host,
-        size_t data_len, uint32_t timeout, struct netdev_ping_resp *ping_resp)
+                            size_t data_len, uint32_t timeout, struct netdev_ping_resp *ping_resp)
 {
-#define BC26_PING_RESP_SIZE       128
-#define BC26_PING_IP_SIZE         16
-#define BC26_PING_TIMEO           (5 * RT_TICK_PER_SECOND)
+#define BC26_PING_RESP_SIZE 128
+#define BC26_PING_IP_SIZE 16
+#define BC26_PING_TIMEO (5 * RT_TICK_PER_SECOND)
 
     rt_err_t result = RT_EOK;
     int response = -1, recv_data_len, ping_time, ttl;
@@ -610,33 +609,31 @@ __exit:
 }
 #endif /* NETDEV_USING_PING */
 
-
-
 const struct netdev_ops bc26_netdev_ops =
-{
-    bc26_netdev_set_up,
-    bc26_netdev_set_down,
+    {
+        bc26_netdev_set_up,
+        bc26_netdev_set_down,
 
-    RT_NULL,
-    bc26_netdev_set_dns_server,
-    RT_NULL,
+        RT_NULL,
+        bc26_netdev_set_dns_server,
+        RT_NULL,
 
 #ifdef NETDEV_USING_PING
-    bc26_netdev_ping,
+        bc26_netdev_ping,
 #endif
-    RT_NULL,
+        RT_NULL,
 };
 
 static struct netdev *bc26_netdev_add(const char *netdev_name)
 {
-#define ETHERNET_MTU        1500
-#define HWADDR_LEN          8
+#define ETHERNET_MTU 1500
+#define HWADDR_LEN 8
     struct netdev *netdev = RT_NULL;
 
     netdev = netdev_get_by_name(netdev_name);
-    if(netdev != RT_NULL)
+    if (netdev != RT_NULL)
     {
-        return(netdev);
+        return (netdev);
     }
 
     netdev = (struct netdev *)rt_calloc(1, sizeof(struct netdev));
@@ -651,7 +648,7 @@ static struct netdev *bc26_netdev_add(const char *netdev_name)
     netdev->hwaddr_len = HWADDR_LEN;
 
 #ifdef SAL_USING_AT
-    extern int sal_at_netdev_set_pf_info(struct netdev *netdev);
+    extern int sal_at_netdev_set_pf_info(struct netdev * netdev);
     /* set the network interface socket/netdb operations */
     sal_at_netdev_set_pf_info(netdev);
 #endif
@@ -666,17 +663,17 @@ static struct netdev *bc26_netdev_add(const char *netdev_name)
 /* initialize for bc26 */
 static void bc26_init_thread_entry(void *parameter)
 {
-#define INIT_RETRY                     5
-#define CPIN_RETRY                     5
-#define CSQ_RETRY                      20
-#define CGREG_RETRY                    50
-#define IPADDR_RETRY                   10
+#define INIT_RETRY 5
+#define CPIN_RETRY 5
+#define CSQ_RETRY 20
+#define CGREG_RETRY 50
+#define IPADDR_RETRY 10
 
     int i;
     int retry_num = INIT_RETRY;
     rt_err_t result = RT_EOK;
     at_response_t resp = RT_NULL;
-    struct at_device *device = (struct at_device *) parameter;
+    struct at_device *device = (struct at_device *)parameter;
     struct at_client *client = device->client;
 
     resp = at_create_resp(128, 0, rt_tick_from_millisecond(300));
@@ -700,14 +697,14 @@ static void bc26_init_thread_entry(void *parameter)
             result = -RT_ETIMEOUT;
             goto __exit;
         }
-        
+
         /* disable echo */
         if (at_obj_exec_cmd(device->client, resp, "ATE0") != RT_EOK)
         {
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         /* disable sleep mode  */
         if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=0") != RT_EOK)
         {
@@ -721,14 +718,14 @@ static void bc26_init_thread_entry(void *parameter)
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         /* disable PSM mode  */
         if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=0") != RT_EOK)
         {
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         /* Get the baudrate */
         if (at_obj_exec_cmd(device->client, resp, "AT+IPR?") != RT_EOK)
         {
@@ -736,19 +733,19 @@ static void bc26_init_thread_entry(void *parameter)
             goto __exit;
         }
         at_resp_parse_line_args_by_kw(resp, "+IPR:", "+IPR: %d", &i);
-        LOG_D("%s device baudrate %d", device->name, i);     
-        
+        LOG_D("%s device baudrate %d", device->name, i);
+
         /* get module version */
         if (at_obj_exec_cmd(device->client, resp, "ATI") != RT_EOK)
         {
             result = -RT_ERROR;
             goto __exit;
         }
-        for (i = 0; i < (int) resp->line_counts - 1; i++)
+        for (i = 0; i < (int)resp->line_counts - 1; i++)
         {
             LOG_D("%s", at_resp_get_line(resp, i + 1));
         }
-        
+
         /* check SIM card */
         for (i = 0; i < CPIN_RETRY; i++)
         {
@@ -773,13 +770,13 @@ static void bc26_init_thread_entry(void *parameter)
             if (at_obj_exec_cmd(device->client, resp, "AT+CSQ") == RT_EOK)
             {
                 int signal_strength = 0, err_rate = 0;
-                
+
                 if (at_resp_parse_line_args_by_kw(resp, "+CSQ:", "+CSQ: %d,%d", &signal_strength, &err_rate) > 0)
                 {
                     if ((signal_strength != 99) && (signal_strength != 0))
                     {
                         LOG_D("%s device signal strength: %d, channel bit error rate: %d",
-                                device->name, signal_strength, err_rate);
+                              device->name, signal_strength, err_rate);
                         break;
                     }
                 }
@@ -791,7 +788,7 @@ static void bc26_init_thread_entry(void *parameter)
             result = -RT_ERROR;
             goto __exit;
         }
-                
+
         /* check the GPRS network is registered */
         for (i = 0; i < CGREG_RETRY; i++)
         {
@@ -799,7 +796,7 @@ static void bc26_init_thread_entry(void *parameter)
             if (at_obj_exec_cmd(device->client, resp, "AT+CGREG?") == RT_EOK)
             {
                 int link_stat = 0;
-                
+
                 if (at_resp_parse_line_args_by_kw(resp, "+CGREG:", "+CGREG: %*d,%d", &link_stat) > 0)
                 {
                     if ((link_stat == 1) || (link_stat == 5))
@@ -816,16 +813,16 @@ static void bc26_init_thread_entry(void *parameter)
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         /* check the GPRS network IP address */
         for (i = 0; i < IPADDR_RETRY; i++)
         {
             rt_thread_mdelay(1000);
             if (at_obj_exec_cmd(device->client, resp, "AT+CGPADDR=1") == RT_EOK)
             {
-                #define IP_ADDR_SIZE_MAX    16
+#define IP_ADDR_SIZE_MAX 16
                 char ipaddr[IP_ADDR_SIZE_MAX] = {0};
-                
+
                 /* parse response data "+CGPADDR: 1,<IP_address>" */
                 if (at_resp_parse_line_args_by_kw(resp, "+CGPADDR:", "+CGPADDR: %*d,%s", ipaddr) > 0)
                 {
@@ -840,7 +837,7 @@ static void bc26_init_thread_entry(void *parameter)
             result = -RT_ERROR;
             goto __exit;
         }
-        
+
         /* initialize successfully  */
         result = RT_EOK;
         break;
@@ -906,12 +903,12 @@ static int bc26_net_init(struct at_device *device)
 static int bc26_init(struct at_device *device)
 {
     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->sleep_status = RT_FALSE;//default sleep is disabled.
+
+    bc26 = (struct at_device_bc26 *)device->user_data;
+    bc26->power_status = RT_FALSE; //default power is off.
+    bc26->sleep_status = RT_FALSE; //default sleep is disabled.
 
     /* initialize AT client */
     at_client_init(bc26->client_name, bc26->recv_line_num);
@@ -950,7 +947,7 @@ static int bc26_init(struct at_device *device)
 static int bc26_deinit(struct at_device *device)
 {
     RT_ASSERT(device);
-    
+
     return bc26_netdev_set_down(device->netdev);
 }
 
@@ -989,17 +986,17 @@ static int bc26_control(struct at_device *device, int cmd, void *arg)
 }
 
 const struct at_device_ops bc26_device_ops =
-{
-    bc26_init,
-    bc26_deinit,
-    bc26_control,
+    {
+        bc26_init,
+        bc26_deinit,
+        bc26_control,
 };
 
 static int bc26_device_class_register(void)
 {
     struct at_device_class *class = RT_NULL;
 
-    class = (struct at_device_class *) rt_calloc(1, sizeof(struct at_device_class));
+    class = (struct at_device_class *)rt_calloc(1, sizeof(struct at_device_class));
     if (class == RT_NULL)
     {
         LOG_E("no memory for device class create.");
@@ -1017,4 +1014,3 @@ static int bc26_device_class_register(void)
 INIT_DEVICE_EXPORT(bc26_device_class_register);
 
 #endif /* AT_DEVICE_USING_BC26 */
-