Exportable version of WizziLab's modem driver.

Dependents:   modem_ref_helper

Revision:
31:517fc900afba
Parent:
26:2c934a269914
Child:
34:137ae523ca43
--- a/src/modem_ref.cpp	Mon Jun 04 15:32:05 2018 +0000
+++ b/src/modem_ref.cpp	Wed Jul 18 15:26:54 2018 +0000
@@ -93,19 +93,34 @@
                     switch (r.type)
                     {
                         case ALP_OPCODE_F_RD_DATA:
-                            g_modem.cb->read(r.meta.f_data.fid,r.meta.f_data.offset,r.meta.f_data.length,id);
+                            if (g_modem.cb->read)
+                            {
+                                g_modem.cb->read(r.meta.f_data.fid,r.meta.f_data.offset,r.meta.f_data.length,id);
+                            }
                             break;
                         case ALP_OPCODE_F_WR_DATA:
-                            g_modem.cb->write(r.meta.f_data.fid,r.data,r.meta.f_data.offset,r.meta.f_data.length,id);
+                            if (g_modem.cb->write)
+                            {
+                                g_modem.cb->write(r.meta.f_data.fid,r.data,r.meta.f_data.offset,r.meta.f_data.length,id);
+                            }
                             break;
                         case ALP_OPCODE_F_RD_PROP:
-                            g_modem.cb->read_fprop(r.meta.f_data.fid,id);
+                            if (g_modem.cb->read_fprop)
+                            {
+                                g_modem.cb->read_fprop(r.meta.f_data.fid,id);
+                            }
                             break;
                         case ALP_OPCODE_F_DELETE:
-                            g_modem.cb->remove(r.meta.f_data.fid,id);
+                            if (g_modem.cb->remove)
+                            {
+                                g_modem.cb->remove(r.meta.f_data.fid,id);
+                            }
                             break;
                         case ALP_OPCODE_F_FLUSH:
-                            g_modem.cb->flush(r.meta.f_data.fid,id);
+                            if (g_modem.cb->flush)
+                            {
+                                g_modem.cb->flush(r.meta.f_data.fid,id);
+                            }
                             break;
                         default:
                             ASSERT(false,"ASSERT: Unsupported ALP File Operation: %d\n",r.type);
@@ -123,31 +138,6 @@
                 {
                     switch (r.type)
                     {
-                        case ALP_OPCODE_RSP_ISTATUS:
-                            // ISTATUS can come either alone or together with ALP_OPCODE_RSP_F_DATA
-                            // but there should be only one per payload, moreover it will come first
-                            URC_PRINT("Got ISTATUS[%x] %d Bytes\n",r.meta.itf.type,r.meta.itf.length);
-                            g_modem.istatus.type    = r.meta.itf.type;
-                            g_modem.istatus.length  = r.meta.itf.length;
-                            g_modem.istatus.data    = r.data;
-                            if (0)// (!rem) // TODO : do we really want this ?
-                            {
-                                g_modem.cb->udata(  0, NULL, 0, 0,
-                                                    g_modem.istatus.type,
-                                                    g_modem.istatus.length,
-                                                    g_modem.istatus.data);
-                            }
-                            break;
-                        case ALP_OPCODE_RSP_F_DATA:
-                            // RSP_F_DATA can come either alone or together with ISTATUS
-                            g_modem.cb->udata(  r.meta.f_data.fid,
-                                                r.data,
-                                                r.meta.f_data.offset,
-                                                r.meta.f_data.length,
-                                                g_modem.istatus.type,
-                                                g_modem.istatus.length,
-                                                g_modem.istatus.data);
-                            break;
                         case ALP_OPCODE_RSP_URC:
                             if (ALP_URC_TYPE_LQUAL == r.meta.urc.type)
                                 g_modem.cb->lqual(r.meta.urc.ifid,r.meta.urc.per);
@@ -159,7 +149,11 @@
                                 ASSERT(false,"ASSERT: Unsupported ALP URC: %d\n",r.meta.urc.type);
                             break;
                         default:
-                            ASSERT(false,"ASSERT: Unsupported ALP URC: %d\n",r.type);
+                            if (g_modem.cb->udata)
+                            {
+                                g_modem.cb->udata(payload, size);
+                            }
+                            rem = 0;
                             break;
                     }
 
@@ -229,11 +223,17 @@
                 REF_PRINT("EOP\n");
             }
             // User Callback
-            g_modem.user[id].cb(eop,err,id);
+            if (g_modem.user[id].cb)
+            {
+                g_modem.user[id].cb(eop,err,id);
+            }
             break;
         case WC_FLOW_SYS_RST:
             // 'Software' reset request
-            g_modem.cb->reset();
+            if (g_modem.cb->reset)
+            {
+                g_modem.cb->reset();
+            }
             break;
         case WC_FLOWID_CMD:
             if (*p == WM_BOOT)
@@ -243,7 +243,10 @@
                 p++;
                 cause = p[0];
                 nb_boot = HAL_TO_U16(p[3],p[2]);
-                g_modem.cb->boot(cause,nb_boot);
+                if (g_modem.cb->boot)
+                {
+                    g_modem.cb->boot(cause,nb_boot);
+                }
             }
             else
             {