Sfoglia il codice sorgente

Merge pull request #2 from xiangxistu/master

【修改】对 PPP DEVICE 软件包使用的描述
朱天龙 (Armink) 6 anni fa
parent
commit
8f9e70eda4
3 ha cambiato i file con 23 aggiunte e 21 eliminazioni
  1. 9 8
      README.md
  2. 6 5
      samples/ppp_sample_air720.c
  3. 8 8
      src/ppp_device.c

+ 9 - 8
README.md

@@ -22,13 +22,12 @@ ppp_device 软件包遵循 Apache-2.0 许可,详见 LICENSE 文件。
 
 ### 1.3 依赖 ###
 
-- RT_Thread 3.0+
+- RT_Thread 3.1.x+
 - lwIP 组件( ppp 功能)
-- AT 组件 (AT Client功能)
 
 ## 2. 获取方式 ##
 
-**PPP 组件相关配置选项介绍**
+**PPP 软件包相关配置选项介绍**
 
 
 ```c
@@ -58,17 +57,17 @@ ppp_device 软件包遵循 Apache-2.0 许可,详见 LICENSE 文件。
 
 ppp device 软件包初始化函数如下所示:
 
-模块启动函数,该函数自动调用;没有调用停止函数前,不可再次调用。
+PPP 功能启动函数,该函数自动调用;没有调用停止函数前,不可再次调用。
 
 ```c
-int air720_start(void);
+int ppp_air720_start(void);
 ```
 
 * 初始化模块,获取模块基础信息;
 * 模块拨号,模块进入 PPP 模式;
 * 注册 netdev 设备,接入标准网络框架;
 
-模块停止函数,该函数可以退出 PPP 模式。
+PPP 功能停止函数,该函数可以退出 PPP 模式。
 
 ```c
 int ppp_air720_stop(void);
@@ -98,7 +97,7 @@ msh />[I/ppp.dev] ppp connect successful.
 msh />ifconfig
 network interface device: a0 (Default)           ## 设备名称
 MTU: 1500                                        ## 网络最大传输单元
-MAC: 56 3e 3e 04 03 05                           ## 设备 MAC 地址
+MAC: 95 45 68 39 68 52                           ## 设备 MAC 地址
 FLAGS: UP LINK_UP INTERNET_DOWN DHCP_DISABLE     ## 设备标志
 ip address: 10.32.76.151                         ## 设备 IP 地址
 gw address: 10.64.64.64                          ## 设备网关地址
@@ -122,6 +121,8 @@ msh />ping www.baidu.com
 ## 4. 注意事项
 
 * 一般的SIM卡因为只能从运营商网络获取内网地址,所以不能实现服务器相关功能。
+* 现阶段只支持一个设备通过 PPP 连接网络。
+* 现阶段只支持使用 UART 方式进行数据传输,后续会添加通过 USB 连接 PPP 的方式。
 
 ## 5. 联系方式
 
@@ -129,4 +130,4 @@ xiangxistu
 
 QQ:1254605504
 
-email: xiangxistu@foxmail.com
+email: liuxianliang@rt-thread.com

+ 6 - 5
samples/ppp_sample_air720.c

@@ -35,7 +35,7 @@ static struct ppp_air720 air720;
  *
  */
 
-int air720_register(void)
+int ppp_air720_register(void)
 {
     int result = RT_EOK;
 
@@ -47,9 +47,9 @@ int air720_register(void)
 
     return result;
 }
-INIT_ENV_EXPORT(air720_register);
+INIT_ENV_EXPORT(ppp_air720_register);
 
-int air720_start(void)
+int ppp_air720_start(void)
 {
     rt_device_t device = RT_NULL;
 
@@ -68,8 +68,8 @@ int air720_start(void)
 
     return RT_EOK;
 }
-INIT_APP_EXPORT(air720_start);
-MSH_CMD_EXPORT(air720_start, a sample create air720 for dail to network);
+INIT_APP_EXPORT(ppp_air720_start);
+MSH_CMD_EXPORT(ppp_air720_start, a sample create air720 for dail to network);
 /*
  * close air720 ppp mode, hang up from network
  *
@@ -99,3 +99,4 @@ int ppp_air720_stop(void)
     return RT_EOK;
 }
 MSH_CMD_EXPORT(ppp_air720_stop, a sample stop air720 for dail to network);
+

+ 8 - 8
src/ppp_device.c

@@ -28,7 +28,7 @@
 #endif
 
 
-static struct ppp_device *_g_ppp_device = NULL;
+static struct ppp_device *_g_ppp_device = RT_NULL;
 
 /*
  * Receive callback function , release rx_notice when uart acquire data
@@ -393,8 +393,6 @@ static rt_err_t ppp_device_open(struct rt_device *device, rt_uint16_t oflag)
     RT_ASSERT(ppp_device != RT_NULL);
     static rt_device_t serial;
 
-    ppp_device->parent.ref_count++;
-
     ppp_device->ppp_link_status = 1;
     /* Creat a thread to creat ppp recieve function */
     result = ppp_recv_entry_creat(ppp_device);
@@ -582,13 +580,15 @@ int ppp_device_register(struct ppp_device *ppp_device, const char *dev_name, con
 
     rt_strncpy((char *)ppp_device->rely_name, rely_name, rt_strlen(rely_name));
 
+    /* now we supprot only one device */
+    if (_g_ppp_device != RT_NULL)
+    {
+        LOG_E("Only one device support.");
+        RT_ASSERT(_g_ppp_device == RT_NULL);
+    }
+
     /* attention: you can't use ppp_device as a server in you network, unless
      sim of the modem module used supprots getting public IP address. */
-     if(_g_ppp_device != RT_NULL)
-     {
-         RT_ASSERT("Only one device support.");
-     }
-
     /* register ppp device into rt_device frame */
     result = rt_device_register(&ppp_device->parent, dev_name, RT_Device_Class_NetIf);
     if( result == RT_EOK)