Ver código fonte

[update] reduce optional configuration

Signed-off-by: liuxinaliang <liuxianliang@rt-thread.com>
liuxinaliang 5 anos atrás
pai
commit
31e559a148
1 arquivos alterados com 19 adições e 18 exclusões
  1. 19 18
      sample/cmux_sample_gsm.c

+ 19 - 18
sample/cmux_sample_gsm.c

@@ -11,16 +11,18 @@
 #include <cmux.h>
 #include <rtthread.h>
 
-
 #define CMUX_PPP_NAME "cmux_ppp"
-#define  CMUX_AT_NAME "cmux_at"
+#define CMUX_PPP_PORT 1
+
+#define CMUX_AT_NAME "cmux_at"
+#define CMUX_AT_PORT 2
 
-#define DBG_TAG    "cmux.sample"
+#define DBG_TAG "cmux.sample"
 
 #ifdef CMUX_DEBUG
-#define DBG_LVL   DBG_LOG
+#define DBG_LVL DBG_LOG
 #else
-#define DBG_LVL   DBG_INFO
+#define DBG_LVL DBG_INFO
 #endif
 
 #include <rtdbg.h>
@@ -30,41 +32,41 @@ struct cmux *sample = RT_NULL;
 int cmux_sample(void)
 {
     rt_err_t result;
+
     /* find cmux object through the actual serial name < the actual serial has been related in the cmux.c file > */
     sample = cmux_object_find(CMUX_DEPEND_NAME);
-    if(sample == RT_NULL)
+    if (sample == RT_NULL)
     {
         result = -RT_ERROR;
         LOG_E("Can't find %s", CMUX_DEPEND_NAME);
         goto end;
     }
     /* startup the cmux receive thread, attach control chananel and open it */
-    result =cmux_start(sample);
-    if(result != RT_EOK)
+    result = cmux_start(sample);
+    if (result != RT_EOK)
     {
         LOG_E("cmux sample start error. Can't find %s", CMUX_DEPEND_NAME);
         goto end;
     }
     LOG_I("cmux sample (%s) start successful.", CMUX_DEPEND_NAME);
-#ifdef CMUX_AT_NAME     /* if defined CMUX_AT_NAME, you can attach AT function into cmux */
-    result = cmux_attach(sample, 2,  CMUX_AT_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
-    if(result != RT_EOK)
+
+    /* attach AT function into cmux */
+    result = cmux_attach(sample, CMUX_AT_PORT, CMUX_AT_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
+    if (result != RT_EOK)
     {
         LOG_E("cmux attach (%s) failed.", CMUX_AT_NAME);
         goto end;
     }
     LOG_I("cmux object channel (%s) attach successful.", CMUX_AT_NAME);
-#endif
-#ifdef CMUX_PPP_NAME    /* if defined CMUX_PPP_NAME, you can attach PPP function into cmux */
-    result = cmux_attach(sample, 1, CMUX_PPP_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
-    if(result != RT_EOK)
+
+    /* attach PPP function into cmux */
+    result = cmux_attach(sample, CMUX_PPP_PORT, CMUX_PPP_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
+    if (result != RT_EOK)
     {
         LOG_E("cmux attach %s failed.", CMUX_PPP_NAME);
         goto end;
     }
     LOG_I("cmux object channel (%s) attach successful.", CMUX_PPP_NAME);
-#endif
-
 end:
     return RT_EOK;
 }
@@ -72,4 +74,3 @@ end:
 INIT_APP_EXPORT(cmux_sample_start);
 #endif
 MSH_CMD_EXPORT_ALIAS(cmux_sample, cmux_start, a sample of cmux function);
-