Data reception demo.

Dependencies:   modem_ref_helper

Revision:
5:a44b6f60bfc7
Parent:
4:854f22f7962b
Child:
9:72a15235e097
--- a/modem_callbacks.cpp	Thu May 18 13:46:00 2017 +0000
+++ b/modem_callbacks.cpp	Thu Sep 21 13:50:17 2017 +0000
@@ -10,31 +10,27 @@
 {
     u8 data[256];
     
-    if (ram_fs_read(fid, offset, length, data))
+    if (!ram_fs_read(fid, offset, length, data))
     {
-        modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
+        modem_respond_read(fid, data, offset, length, id);
     }
     else
     {
-        modem_respond_read(fid, data, offset, length, id);
+        modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
     }
 }
 
 void my_write(u8 fid, void *data, u32 offset, u32 length, int id)
 {
-    alp_errors_t err;
-    
-    if (ram_fs_write(fid, offset, length, (uint8_t*)data))
+    if (!ram_fs_write(fid, offset, length, (uint8_t*)data))
     {
-        err = ALP_ERR_FILE_NOT_FOUND;
+        modem_respond(0, ALP_ERR_NONE, id);
+        g_file_modified.put((void*)fid);
     }
     else
     {
-        err = ALP_ERR_NONE;
-        g_file_modified.put((void*)fid);
-    }
-    
-    modem_respond(0, err, id);
+        modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
+    }   
 }
 
 void my_read_fprop(u8 fid, int id)
@@ -93,12 +89,14 @@
 
 void my_reset(void)
 {
+    PRINT("Restarting application...\r\n");
+    FLUSH();
     NVIC_SystemReset();
 }
 
 void my_boot(u8 cause, u16 number)
 {
-    PRINT("Modem BOOT[%c] #%d\r\nRe-Init\r\n", cause, number);
+    PRINT("Modem BOOT[%c] #%d\r\n", cause, number);
     
     // Modem re-booted, restart APP
     my_reset();