From b8c5ca4b4987a6b0cc701ede4c6ff2f6d0f65c09 Mon Sep 17 00:00:00 2001 From: liuxianliang Date: Fri, 11 Oct 2019 17:58:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E3=80=90=E9=87=8D=E6=9E=84=E3=80=91class?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuxianliang --- class/air720/ppp_device_air720.h | 28 -------------------------- class/m6312/ppp_device_m6312.h | 28 -------------------------- class/{air720 => }/ppp_device_air720.c | 28 ++++++++++++-------------- class/{m6312 => }/ppp_device_m6312.c | 26 +++++++++++------------- class/{sim800 => }/ppp_device_sim800.c | 27 ++++++++++++------------- class/sim800/ppp_device_sim800.h | 28 -------------------------- 6 files changed, 38 insertions(+), 127 deletions(-) delete mode 100644 class/air720/ppp_device_air720.h delete mode 100644 class/m6312/ppp_device_m6312.h rename class/{air720 => }/ppp_device_air720.c (76%) rename class/{m6312 => }/ppp_device_m6312.c (77%) rename class/{sim800 => }/ppp_device_sim800.c (76%) delete mode 100644 class/sim800/ppp_device_sim800.h diff --git a/class/air720/ppp_device_air720.h b/class/air720/ppp_device_air720.h deleted file mode 100644 index d6ec5c1..0000000 --- a/class/air720/ppp_device_air720.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2019, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2019-08-15 xiangxistu the first version - */ - -#ifndef __PPP_AIR720_H__ -#define __PPP_AIR720_H__ - -#include - -#define AIR720_WARTING_TIME_BASE 500 - -/* ppp_device base from ppp_device */ -struct ppp_air720 -{ - struct ppp_device device; /* ppp_device struct in ppp_air720 */ - enum ppp_trans_type type; /* the type is used to establish a ppp connection */ - rt_base_t power_pin; /* power pin, if device need hardware reset */ -}; - -extern int ppp_air720_register(void); - -#endif /* __PPP_AIR720_H__ */ diff --git a/class/m6312/ppp_device_m6312.h b/class/m6312/ppp_device_m6312.h deleted file mode 100644 index b83d6c7..0000000 --- a/class/m6312/ppp_device_m6312.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2019, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2019-09-24 xiaofao the first version - */ - -#ifndef __PPP_M6312_H__ -#define __PPP_M6312_H__ - -#include - -#define M6312_WARTING_TIME_BASE 500 - -/* ppp_device base from ppp_device */ -struct ppp_m6312 -{ - struct ppp_device device; /* ppp_device struct in ppp_m6312 */ - enum ppp_trans_type type; /* the type is used to establish a ppp connection */ - rt_base_t power_pin; /* power pin, if device need hardware reset */ -}; - -extern int ppp_m6312_register(void); - -#endif /* __PPP_M6312_H__ */ diff --git a/class/air720/ppp_device_air720.c b/class/ppp_device_air720.c similarity index 76% rename from class/air720/ppp_device_air720.c rename to class/ppp_device_air720.c index ca1f3e9..af98b75 100644 --- a/class/air720/ppp_device_air720.c +++ b/class/ppp_device_air720.c @@ -8,7 +8,7 @@ * 2019-08-15 xiangxistu the first version */ -#include +#include #include #include @@ -27,6 +27,8 @@ #define AIR720_POWER_PIN -1 #endif +#define AIR720_WARTING_TIME_BASE 500 + static const struct modem_chat_data rst_mcd[] = { {"+++", MODEM_CHAT_RESP_NOT_NEED, 30, 1, RT_TRUE}, @@ -43,12 +45,11 @@ static const struct modem_chat_data mcd[] = static rt_err_t ppp_air720_prepare(struct ppp_device *device) { - struct ppp_air720 *air720 = (struct ppp_air720*)device; - if (air720->power_pin >= 0) + if (device->power_pin >= 0) { - rt_pin_write(air720->power_pin, AIR720_POWER_OFF); + rt_pin_write(device->power_pin, AIR720_POWER_OFF); rt_thread_mdelay(AIR720_WARTING_TIME_BASE); - rt_pin_write(air720->power_pin, AIR720_POWER_ON); + rt_pin_write(device->power_pin, AIR720_POWER_ON); } else { @@ -75,23 +76,20 @@ static struct ppp_device_ops air720_ops = int ppp_air720_register(void) { struct ppp_device *ppp_device = RT_NULL; - struct ppp_air720 *air720 = RT_NULL; - air720 = rt_malloc(sizeof(struct ppp_air720)); - if(air720 == RT_NULL) + ppp_device = rt_malloc(sizeof(struct ppp_device)); + if(ppp_device == RT_NULL) { - LOG_E("No memory for struct air720."); + LOG_E("No memory for air720 ppp_device."); return -RT_ENOMEM; } - air720->power_pin = AIR720_POWER_PIN; - if (air720->power_pin >= 0) + ppp_device->power_pin = AIR720_POWER_PIN; + if (ppp_device->power_pin >= 0) { - rt_pin_mode(air720->power_pin, PIN_MODE_OUTPUT); - rt_pin_write(air720->power_pin, AIR720_POWER_OFF); + rt_pin_mode(ppp_device->power_pin, PIN_MODE_OUTPUT); + rt_pin_write(ppp_device->power_pin, AIR720_POWER_OFF); } - - ppp_device = &(air720->device); ppp_device->ops = &air720_ops; LOG_D("ppp air720 is registering ppp_device"); diff --git a/class/m6312/ppp_device_m6312.c b/class/ppp_device_m6312.c similarity index 77% rename from class/m6312/ppp_device_m6312.c rename to class/ppp_device_m6312.c index 973c266..5c0b98a 100644 --- a/class/m6312/ppp_device_m6312.c +++ b/class/ppp_device_m6312.c @@ -8,7 +8,7 @@ * 2019-09-24 xiaofao the first version */ -#include +#include #include #include @@ -27,6 +27,7 @@ #define M6312_POWER_PIN -1 #endif +#define M6312_WARTING_TIME_BASE 500 static const struct modem_chat_data rst_mcd[] = { @@ -45,12 +46,11 @@ static const struct modem_chat_data mcd[] = static rt_err_t ppp_m6312_prepare(struct ppp_device *device) { - struct ppp_m6312 *m6312 = (struct ppp_m6312*)device; - if (m6312->power_pin >= 0) + if (device->power_pin >= 0) { - rt_pin_write(m6312->power_pin, M6312_POWER_OFF); + rt_pin_write(device->power_pin, M6312_POWER_OFF); rt_thread_mdelay(M6312_WARTING_TIME_BASE); - rt_pin_write(m6312->power_pin, M6312_POWER_ON); + rt_pin_write(device->power_pin, M6312_POWER_ON); } else { @@ -77,23 +77,21 @@ static struct ppp_device_ops m6312_ops = int ppp_m6312_register(void) { struct ppp_device *ppp_device = RT_NULL; - struct ppp_m6312 *m6312 = RT_NULL; - m6312 = rt_malloc(sizeof(struct ppp_m6312)); - if(m6312 == RT_NULL) + ppp_device = rt_malloc(sizeof(struct ppp_device)); + if(ppp_device == RT_NULL) { - LOG_E("No memory for struct m6312."); + LOG_E("No memory for struct m6312 ppp_device."); return -RT_ENOMEM; } - m6312->power_pin = M6312_POWER_PIN; - if (m6312->power_pin >= 0) + ppp_device->power_pin = M6312_POWER_PIN; + if (ppp_device->power_pin >= 0) { - rt_pin_mode(m6312->power_pin, PIN_MODE_OUTPUT); - rt_pin_write(m6312->power_pin, M6312_POWER_OFF); + rt_pin_mode(ppp_device->power_pin, PIN_MODE_OUTPUT); + rt_pin_write(ppp_device->power_pin, M6312_POWER_OFF); } - ppp_device = &(m6312->device); ppp_device->ops = &m6312_ops; LOG_D("ppp m6312 is registering ppp_device"); return ppp_device_register(ppp_device, PPP_DEVICE_NAME, RT_NULL, RT_NULL); diff --git a/class/sim800/ppp_device_sim800.c b/class/ppp_device_sim800.c similarity index 76% rename from class/sim800/ppp_device_sim800.c rename to class/ppp_device_sim800.c index 2907660..8eed35c 100644 --- a/class/sim800/ppp_device_sim800.c +++ b/class/ppp_device_sim800.c @@ -8,7 +8,7 @@ * 2019-08-15 xiangxistu the first version */ -#include +#include #include #include @@ -27,6 +27,8 @@ #define SIM800_POWER_PIN -1 #endif +#define SIM800_WARTING_TIME_BASE 500 + static const struct modem_chat_data rst_mcd[] = { {"+++", MODEM_CHAT_RESP_NOT_NEED, 30, 1, RT_TRUE}, @@ -43,12 +45,11 @@ static const struct modem_chat_data mcd[] = static rt_err_t ppp_sim800_prepare(struct ppp_device *device) { - struct ppp_sim800 *sim800 = (struct ppp_sim800*)device; - if (sim800->power_pin >= 0) + if (device->power_pin >= 0) { - rt_pin_write(sim800->power_pin, SIM800_POWER_OFF); + rt_pin_write(device->power_pin, SIM800_POWER_OFF); rt_thread_mdelay(SIM800_WARTING_TIME_BASE); - rt_pin_write(sim800->power_pin, SIM800_POWER_ON); + rt_pin_write(device->power_pin, SIM800_POWER_ON); } else { @@ -75,23 +76,21 @@ static struct ppp_device_ops sim800_ops = int ppp_sim800_register(void) { struct ppp_device *ppp_device = RT_NULL; - struct ppp_sim800 *sim800 = RT_NULL; - sim800 = rt_malloc(sizeof(struct ppp_sim800)); - if(sim800 == RT_NULL) + ppp_device = rt_malloc(sizeof(struct ppp_device)); + if(ppp_device == RT_NULL) { - LOG_E("No memory for struct sim800."); + LOG_E("No memory for struct sim800 ppp_device."); return -RT_ENOMEM; } - sim800->power_pin = SIM800_POWER_PIN; - if (sim800->power_pin >= 0) + ppp_device->power_pin = SIM800_POWER_PIN; + if (ppp_device->power_pin >= 0) { - rt_pin_mode(sim800->power_pin, PIN_MODE_OUTPUT); - rt_pin_write(sim800->power_pin, SIM800_POWER_OFF); + rt_pin_mode(ppp_device->power_pin, PIN_MODE_OUTPUT); + rt_pin_write(ppp_device->power_pin, SIM800_POWER_OFF); } - ppp_device = &(sim800->device); ppp_device->ops = &sim800_ops; LOG_D("ppp sim800 is registering ppp_device"); diff --git a/class/sim800/ppp_device_sim800.h b/class/sim800/ppp_device_sim800.h deleted file mode 100644 index 027dce5..0000000 --- a/class/sim800/ppp_device_sim800.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2019, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2019-08-15 xiangxistu the first version - */ - -#ifndef __PPP_AIR720_H__ -#define __PPP_AIR720_H__ - -#include - -#define SIM800_WARTING_TIME_BASE 500 - -/* ppp_device base from ppp_device */ -struct ppp_sim800 -{ - struct ppp_device device; /* ppp_device struct in ppp_sim800 */ - enum ppp_trans_type type; /* the type is used to establish a ppp connection */ - rt_base_t power_pin; /* power pin, if device need hardware reset */ -}; - -extern int ppp_sim800_register(void); - -#endif /* __PPP_AIR720_H__ */ From 694387d835b865c43bdc566aa891fd558a074069 Mon Sep 17 00:00:00 2001 From: liuxianliang Date: Fri, 11 Oct 2019 17:59:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E3=80=90=E6=B7=BB=E5=8A=A0=E3=80=91power?= =?UTF-8?q?=5Fpin=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuxianliang --- inc/ppp_device.h | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/ppp_device.h b/inc/ppp_device.h index 93c4ef8..55bafc6 100644 --- a/inc/ppp_device.h +++ b/inc/ppp_device.h @@ -67,6 +67,7 @@ struct ppp_device rt_device_t uart; /* low-level uart device object */ const struct ppp_device_ops *ops; /* ppp device ops interface */ enum ppp_conn_type conn_type; /* using usb or uart */ + rt_base_t power_pin; /* power pin, if device need hardware reset */ ppp_pcb *pcb; /* ppp protocol control block */ struct netif pppif; From 4959d944c767d3a1f5aa1ed620e675e6312eb01b Mon Sep 17 00:00:00 2001 From: liuxianliang Date: Fri, 11 Oct 2019 18:00:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91class?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuxianliang --- SConscript | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/SConscript b/SConscript index 67f3f02..eb76c98 100644 --- a/SConscript +++ b/SConscript @@ -7,18 +7,15 @@ src += Glob('samples/ppp_sample.c') # Air720 if GetDepend(['PPP_DEVICE_USING_AIR720']): - path += [cwd + '/class/air720'] - src += Glob('class/air720/ppp_device_air720.c') + src += Glob('class/ppp_device_air720.c') # M6312 if GetDepend(['PPP_DEVICE_USING_M6312']): - path += [cwd + '/class/m6312'] - src += Glob('class/m6312/ppp_device_m6312.c') + src += Glob('class/ppp_device_m6312.c') # SIM800 if GetDepend(['PPP_DEVICE_USING_SIM800']): - path += [cwd + '/class/sim800'] - src += Glob('class/sim800/ppp_device_sim800.c') + src += Glob('class/ppp_device_sim800.c') group = DefineGroup('ppp_device', src, depend = ['PKG_USING_PPP_DEVICE'], CPPPATH = path) From 28795ce09f97689649adab4e14dceae1128e5741 Mon Sep 17 00:00:00 2001 From: liuxianliang Date: Fri, 11 Oct 2019 18:14:19 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91comment?= =?UTF-8?q?=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuxianliang --- inc/ppp_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/ppp_device.h b/inc/ppp_device.h index 55bafc6..7ef99be 100644 --- a/inc/ppp_device.h +++ b/inc/ppp_device.h @@ -67,7 +67,7 @@ struct ppp_device rt_device_t uart; /* low-level uart device object */ const struct ppp_device_ops *ops; /* ppp device ops interface */ enum ppp_conn_type conn_type; /* using usb or uart */ - rt_base_t power_pin; /* power pin, if device need hardware reset */ + rt_base_t power_pin; /* power pin, if device need hardware reset */ ppp_pcb *pcb; /* ppp protocol control block */ struct netif pppif;