Data reception demo.

Dependencies:   modem_ref_helper

Revision:
0:02418479dcf7
Child:
2:6652be2d061f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modem_callbacks.cpp	Thu May 11 17:48:47 2017 +0000
@@ -0,0 +1,85 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "WizziDebug.h"
+
+#include "alp_spec.h"
+#include "alp_helpers.h"
+#include "modem_ref.h"
+
+#include "ram_fs.h"
+#include "hal_types.h"
+
+extern Queue<void, 8>   g_file_modified;
+
+// ============================================================}}}
+
+// Callbacks to MODEM's ALP requests
+// ============================================================{{{
+void my_read(u8 fid, u32 offset, u32 length, int id)
+{
+    u8 data[256];
+    
+    if (ram_fs_read(fid, offset, length, data))
+    {
+        modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
+    }
+    else
+    {
+        modem_respond_read(fid, data, offset, length, id);
+    }
+}
+
+void my_write(u8 fid, void *data, u32 offset, u32 length, int id)
+{
+    modem_respond(0, (ram_fs_write(fid, offset, length, (uint8_t*)data))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
+    
+    g_file_modified.put((void*)fid);
+}
+
+void my_read_fprop(u8 fid, int id)
+{
+    u8* hdr = (u8*)ram_fs_get_header(fid);
+    
+    if (hdr != NULL)
+    {
+        modem_respond_fprop(fid, hdr, id);
+    }
+    else
+    {
+        modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
+    }
+}
+
+void my_flush(u8 fid, int id)
+{
+    // No flush in this file system
+    modem_respond(0, ALP_ERR_NONE, id);
+}
+
+void my_delete(u8 fid, int id)
+{
+    modem_respond(0, (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
+}
+
+void my_lqual(u8 ifid, int per)
+{
+    DPRINT("Interface File [%3d] LQUAL : %d%% PER\r\n", ifid, per);
+}
+
+void my_ldown(u8 ifid)
+{
+    DPRINT("Interface File [%3d] LDOWN\r\n", ifid);
+}
+
+void my_reset(void)
+{
+    NVIC_SystemReset();
+}
+
+void my_boot(u8 cause, u16 number)
+{
+    DPRINT("Modem BOOT[%c] #%d\r\nRe-Init\r\n", cause, number);
+    
+    // Modem re-booted, restart APP
+    my_reset();
+}
\ No newline at end of file