|
|
@@ -15,9 +15,6 @@
|
|
|
#define CMUX_PPP_NAME "cmux_ppp"
|
|
|
#define CMUX_AT_NAME "cmux_at"
|
|
|
|
|
|
-#define CMUX_PPP_PORT 1
|
|
|
-#define CMUX_AT_PORT 2
|
|
|
-
|
|
|
#define DBG_TAG "cmux.sample"
|
|
|
|
|
|
#ifdef CMUX_DEBUG
|
|
|
@@ -29,10 +26,11 @@
|
|
|
#include <rtdbg.h>
|
|
|
|
|
|
struct cmux *sample = RT_NULL;
|
|
|
-
|
|
|
+#define
|
|
|
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)
|
|
|
{
|
|
|
@@ -40,6 +38,7 @@ int cmux_sample(void)
|
|
|
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)
|
|
|
{
|
|
|
@@ -47,8 +46,8 @@ int cmux_sample(void)
|
|
|
goto end;
|
|
|
}
|
|
|
LOG_I("cmux sample (%s) start successful.", CMUX_DEPEND_NAME);
|
|
|
-#ifdef CMUX_AT_NAME
|
|
|
- result = cmux_attach(sample, CMUX_AT_PORT, CMUX_AT_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
|
|
|
+#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)
|
|
|
{
|
|
|
LOG_E("cmux attach (%s) failed.", CMUX_AT_NAME);
|
|
|
@@ -56,8 +55,8 @@ int cmux_sample(void)
|
|
|
}
|
|
|
LOG_I("cmux object channel (%s) attach successful.", CMUX_AT_NAME);
|
|
|
#endif
|
|
|
-#ifdef CMUX_PPP_NAME
|
|
|
- result = cmux_attach(sample, CMUX_PPP_PORT, CMUX_PPP_NAME, RT_DEVICE_FLAG_DMA_RX, RT_NULL);
|
|
|
+#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)
|
|
|
{
|
|
|
LOG_E("cmux attach %s failed.", CMUX_PPP_NAME);
|