Send file data through D7A Action Protocol demo.

Dependencies:   modem_ref_helper

Revision:
5:4da1ea72e7b4
Parent:
4:45576db9f66c
Child:
10:daa4b52991b7
--- a/modem_callbacks.cpp	Mon May 15 15:58:31 2017 +0000
+++ b/modem_callbacks.cpp	Thu May 18 13:48:39 2017 +0000
@@ -1,13 +1,4 @@
-#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"
+#include "modem_ref_helper.h"
 
 extern Queue<void, 8>   g_file_modified;
 
@@ -31,9 +22,19 @@
 
 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);
+    alp_errors_t err;
     
-    g_file_modified.put((void*)fid);
+    if (ram_fs_write(fid, offset, length, (uint8_t*)data))
+    {
+        err = ALP_ERR_FILE_NOT_FOUND;
+    }
+    else
+    {
+        err = ALP_ERR_NONE;
+        g_file_modified.put((void*)fid);
+    }
+    
+    modem_respond(0, err, id);
 }
 
 void my_read_fprop(u8 fid, int id)
@@ -61,6 +62,25 @@
     modem_respond(0, (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
 }
 
+void my_udata(u8 fid,void *data,u32 offset,u32 length, u8 i_type, u8 i_length, u8* i_data)
+{
+    (void)data;
+    (void)i_length;
+    PRINT("Got UNS File[%3d]@%d %d Bytes\n",fid,offset,length);
+    if (i_type == ALP_ITF_TYPE_D7A)
+    {
+        static union {
+            u8      b[8];
+            u32     w[2];
+        } uid;
+        d7a_sp_res_t* istat = (d7a_sp_res_t*) i_data;
+        memcpy(uid.b,istat->addressee.id,8);
+        PRINT("From UID: %08X%08X (rxlev:%d lb:%d)\n",
+                HAL_U32_BYTE_SWAP(uid.w[0]), HAL_U32_BYTE_SWAP(uid.w[1]),
+                istat->rxlev, istat->lb);
+    }
+}
+
 void my_lqual(u8 ifid, int per)
 {
     PRINT("Interface File [%3d] LQUAL : %d%% PER\r\n", ifid, per);