Exportable version of WizziLab's modem driver.

Dependents:   modem_ref_helper

Revision:
63:544a488a06d3
Parent:
62:75d819d68e5f
Child:
65:c7749f9b6009
--- a/src/modem_ref.cpp	Tue Sep 21 08:47:52 2021 +0000
+++ b/src/modem_ref.cpp	Tue Sep 21 16:33:36 2021 +0000
@@ -22,7 +22,6 @@
 typedef struct {
     fx_serial_send_t*       send;
     modem_ref_callbacks_t*  cb;
-    modem_lwan_callbacks_t* lwan_cb;
     modem_ref_user_t        user[MAX_USER_NB];
     u8                      state;
 } modem_ref_ctx_t;
@@ -57,8 +56,8 @@
 {
     u8 buf[PKT_MAX_SIZE];
     
-    PRINT("<--\n");
-    alp_payload_print(alp);
+    //PRINT("<--\n");
+    //alp_payload_print(alp);
     
     u32 len = alp_payload_to_buf(alp, buf, 0, PKT_MAX_SIZE);
     
@@ -134,6 +133,7 @@
     }
 }
 
+#if 0
 static void call_urc_user_cb(alp_payload_t* alp)
 {
     alp_parsed_chunk_t r;
@@ -231,6 +231,7 @@
         alp = alp->next;
     }
 }
+#endif
 
 void modem_ref_input(u8 flowid, u8* payload, u8 size)
 {
@@ -241,7 +242,7 @@
     s8 err = ALP_ERR_NONE;
     u8 eop;
     u32 parsed;
-    alp_payload_t* alp;    
+    alp_payload_t* alp;
 
     REF_PRINT("input 0x%x/%d Bytes\n", flowid, size);
     switch (flowid)
@@ -252,21 +253,30 @@
             // pre-parse payload
             alp = alp_payload_parse(p, size);
             
-            PRINT("-->\n");
-            alp_payload_print(alp);
+            //PRINT("-->\n");
+            //alp_payload_print(alp);
             
             if (ALP_OPCODE_TAG == (alp->d[0] & 0x3F))
             {
                 // Payload starts with a tag, this must be a FS command
                 call_fs_user_cb(alp);
+                alp_payload_free(alp);
             }
             else
             {
                 // else this is a 'real' URC (or ISTATUS if enabled on modem)
-                call_urc_user_cb(alp);
+                if (g_modem.cb->udata)
+                {
+                    // XXX All URCs go to the user
+                    g_modem.cb->udata(alp);
+                }
+                else
+                {
+                    alp_payload_free(alp);
+                }
+                //call_urc_user_cb(alp);
             }
             
-            alp_payload_free(alp);
 
             break;
         case WC_FLOW_ALP_RESP:
@@ -274,8 +284,8 @@
             // pre-parse payload
             alp = alp_payload_parse(p, size);
             
-            PRINT("-->\n");
-            alp_payload_print(alp);
+            //PRINT("-->\n");
+            //alp_payload_print(alp);
             
             p = alp->d;
             alp_parse_chunk(&p, &r);
@@ -425,11 +435,6 @@
     serial_send(WizziComPacketSysReset, NULL);
 }
 
-void modem_ref_set_lwan_cb(modem_lwan_callbacks_t* callbacks)
-{
-    g_modem.lwan_cb = callbacks;
-}
-
 void modem_ref_set_boot_cb(fx_boot_t* boot_cb)
 {
     g_modem.cb->boot = boot_cb;