Data reception demo.

Dependencies:   modem_ref_helper

Revision:
3:e9ea4d325c01
Parent:
2:6652be2d061f
Child:
4:854f22f7962b
--- a/modem_callbacks.cpp	Mon May 15 15:55:09 2017 +0000
+++ b/modem_callbacks.cpp	Wed May 17 14:38:25 2017 +0000
@@ -5,6 +5,7 @@
 #include "alp_spec.h"
 #include "alp_helpers.h"
 #include "modem_ref.h"
+#include "d7a_1x.h"
 
 #include "ram_fs.h"
 #include "hal_types.h"
@@ -31,9 +32,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 +72,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);