Complete sensor demo.

Dependencies:   modem_ref_helper CRC X_NUCLEO_IKS01A1 DebouncedInterrupt

Files at this revision

API Documentation at this revision

Comitter:
marin_wizzi
Date:
Fri Oct 29 12:55:52 2021 +0000
Parent:
17:3e6083d76bc6
Commit message:
Compatible with 6.2 modem version

Changed in this revision

CRC.lib Show annotated file Show diff for this revision Revisions of this file
files.cpp Show annotated file Show diff for this revision Revisions of this file
files.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
modem_callbacks.cpp Show annotated file Show diff for this revision Revisions of this file
modem_callbacks.h Show annotated file Show diff for this revision Revisions of this file
modem_d7a.lib Show annotated file Show diff for this revision Revisions of this file
modem_ref_helper.lib Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC.lib	Fri Oct 29 12:55:52 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/WizziLab/code/CRC/#88116ae677af
--- a/files.cpp	Thu May 28 09:22:46 2020 +0000
+++ b/files.cpp	Fri Oct 29 12:55:52 2021 +0000
@@ -63,6 +63,9 @@
     .alloc= HAL_U32_BYTE_SWAP((uint32_t)(_size))\
 }
 
+
+#define DATA_FILE_SENSOR_VALUE(name,_size) int32_t f_sensor_value_##name[_size] = {0}
+
 HEADER_FILE_SENSOR_CONFIG(mag);
 HEADER_FILE_SENSOR_CONFIG(acc);
 HEADER_FILE_SENSOR_CONFIG(gyr);
@@ -81,6 +84,15 @@
 HEADER_FILE_SENSOR_VALUE(tem2, 1*sizeof(int32_t));
 HEADER_FILE_SENSOR_VALUE(light, 1*sizeof(int32_t));
 
+DATA_FILE_SENSOR_VALUE(mag, 3);
+DATA_FILE_SENSOR_VALUE(acc, 3);
+DATA_FILE_SENSOR_VALUE(gyr, 3);
+DATA_FILE_SENSOR_VALUE(pre, 1);
+DATA_FILE_SENSOR_VALUE(hum, 1);
+DATA_FILE_SENSOR_VALUE(tem1, 1);
+DATA_FILE_SENSOR_VALUE(tem2, 1);
+DATA_FILE_SENSOR_VALUE(light, 1);
+
 sensor_config_t f_sensor_config_mag = {
     .report_type = REPORT_ON_DIFFERENCE,
     .read_period = 1000,
--- a/files.h	Thu May 28 09:22:46 2020 +0000
+++ b/files.h	Fri Oct 29 12:55:52 2021 +0000
@@ -7,6 +7,14 @@
 #include "alp_helpers.h"
 #include "modem_ref.h"
 
+TYPEDEF_STRUCT_PACKED {
+    uint8_t fid;
+    uint32_t offset;
+    uint32_t length;
+} touch_t;
+
+extern Queue<touch_t, 8> g_file_modified;
+
 // Types of reporting
 typedef enum 
 {
@@ -39,7 +47,8 @@
 #define FILE_DECLARE_SENSOR_CONFIG(name) extern const alp_file_header_t h_sensor_config_##name;\
     extern sensor_config_t f_sensor_config_##name
 
-#define FILE_DECLARE_SENSOR_VALUE(name) extern const alp_file_header_t h_sensor_value_##name
+#define FILE_DECLARE_SENSOR_VALUE(name) extern const alp_file_header_t h_sensor_value_##name;\
+    extern int32_t f_sensor_value_##name[]
 
 #define FID_SENSOR_CONFIG_MAG           132
 #define FID_SENSOR_CONFIG_ACC           133
--- a/main.cpp	Thu May 28 09:22:46 2020 +0000
+++ b/main.cpp	Fri Oct 29 12:55:52 2021 +0000
@@ -6,9 +6,10 @@
 #include "sensors.h"
 #include "sensors_cfg.h"
 #include "simul.h"
-#include "modem_ref_helper.h"
+#include "modem_d7a.h"
 #include "modem_callbacks.h"
 #include "files.h"
+#include "crc.h"
 
 #define MIN_REPORT_PERIOD   (10) // Seconds
 
@@ -19,10 +20,10 @@
 };
 
 Semaphore button_user(1);
-Semaphore modem_ready[MAX_USER_NB];
 Semaphore thread_ready(0);
 sensor_config_t g_light_config;
-Queue<void, 8> g_file_modified;
+int sensor_id = 0;
+Queue<touch_t, 8> g_file_modified;
 
 static bool report_ok(uint32_t last_report_time)
 {
@@ -37,20 +38,32 @@
 }
 
 // Check parameters to see if data should be send
-static bool report_needed(sensor_config_t* config, int32_t value, int32_t last_value, uint32_t last_report_time, uint8_t user_id)
+static bool report_needed(sensor_config_t* config, int32_t value, int32_t last_value, uint32_t last_report_time, uint8_t thread_id)
 {
-
+    char thread_name[10];        
+    switch (thread_id)
+    {
+        case 0: strcpy(thread_name,"Magnetometer"); break;
+        case 1: strcpy(thread_name,"Accelerometer"); break;
+        case 2: strcpy(thread_name,"Pressure"); break;
+        case 3: strcpy(thread_name,"Humidity"); break;
+        case 4: strcpy(thread_name,"Temperature sensor 1"); break;
+        case 5: strcpy(thread_name,"Temperature sensor 2"); break;
+        case 6: strcpy(thread_name,"Light sensor"); break;
+        default: strcpy(thread_name,"Unknown"); break;          
+    }
+        
     switch (config->report_type)
     {
         case REPORT_ALWAYS:
             // Send a report at each measure
-            PRINT("Report[%d] always\r\n", user_id);
+            PRINT("Report[%d] : %s always\r\n", thread_id, thread_name);
             return report_ok(last_report_time);
         case REPORT_ON_DIFFERENCE:
             // Send a report when the difference between the last reported measure and the current mesure is greater than max_diff
             if (abs(last_value - value) >= config->max_diff && config->max_diff)
             {
-                PRINT("Report[%d] on difference (last:%d new:%d max_diff:%d)\r\n", user_id, last_value, value, config->max_diff);
+                PRINT("Report[%d] : %s on difference (last:%d new:%d max_diff:%d)\r\n", thread_id, thread_name, last_value, value, config->max_diff);
                 return report_ok(last_report_time);
             }
             break;
@@ -61,7 +74,7 @@
                 || (value < config->threshold_high  && last_value >= config->threshold_high)
                 || (value > config->threshold_low   && last_value <= config->threshold_low))
             {
-                PRINT("Report[%d] on threshold (last:%d new:%d th:%d tl:%d)\r\n", user_id, last_value, value, config->threshold_high, config->threshold_low);
+                PRINT("Report[%d] : %s on threshold (last:%d new:%d th:%d tl:%d)\r\n", thread_id, thread_name, last_value, value, config->threshold_high, config->threshold_low);
                 return report_ok(last_report_time);
             }
             break;
@@ -72,10 +85,9 @@
     // Send a report if it's been more than max_period since the last report
     if (((last_report_time/1000) >= config->max_period) && config->max_period)
     {
-        PRINT("Report[%d] on period (max_period:%d time:%d)\r\n", user_id, config->max_period, last_report_time);
+        PRINT("Report[%d] : %s on period (max_period:%d time:%d)\r\n", thread_id, thread_name, config->max_period, last_report_time);
         return report_ok(last_report_time);
     }
-
     return false;
 }
 
@@ -85,7 +97,7 @@
     button_user.release();
 }
 
-modem_callbacks_t callbacks = {
+modem_ref_callbacks_t callbacks = {
     .read       = my_read,
     .write      = my_write,
     .read_fprop = my_read_fprop,
@@ -99,20 +111,6 @@
     .busy       = my_busy,
 };
 
-// Callback for Users
-void my_main_callback(uint8_t terminal, int8_t err, uint8_t id)
-{
-    if (ALP_ERR_NONE > err)
-    {
-        PRINT("Status[%d]: ", id);
-        modem_print_error(ALP_ITF_TYPE_D7A, err);
-    }
-    
-    if (terminal)
-    {
-        modem_ready[id].release();
-    }
-}
 
 // -----------------------------------------------
 // Sensor Threads
@@ -155,7 +153,6 @@
         .config_file_id = FID_SENSOR_CONFIG_##NAME\
     }
 
-
 SENSOR_THREAD_CTX(mag, MAG, 3);
 SENSOR_THREAD_CTX(acc, ACC, 3);
 SENSOR_THREAD_CTX(gyr, GYR, 3);
@@ -167,17 +164,16 @@
 
 void thread_sensor()
 {
+    int thread_id = sensor_id++;
+    
     FPRINT("(id:0x%08x)\r\n", osThreadGetId());
 
     // To force a first report
     uint32_t last_report_time = 0xFFFFFFFF;
     sensor_thread_ctx_t* ctx = g_thread_ctx;
-    uint8_t user_id = modem_get_id(my_main_callback);
 
     // Get the sensor configuration
-    ram_fs_read(ctx->config_file_id, 0, sizeof(sensor_config_t), (uint8_t*)&(ctx->config));
-    
-    PRINT("Start sensor thread %d\n", user_id);
+    ram_fs_read(ctx->config_file_id, (uint8_t*)&(ctx->config), 0, sizeof(sensor_config_t));
     
     thread_ready.release();
     
@@ -196,11 +192,10 @@
         
         for (uint8_t i = 0; i < ctx->nb_values; i++)
         {
-            if (report_needed(&(ctx->config), ctx->current_value[i], ctx->last_report_value[i], last_report_time, user_id))
+            if (report_needed(&(ctx->config), ctx->current_value[i], ctx->last_report_value[i], last_report_time, thread_id))
             {
                 // Send notification
-                modem_write_file(ctx->value_file_id, ctx->current_value, 0, ctx->data_size, user_id);
-                modem_ready[user_id].acquire();
+                modem_write_file(ctx->value_file_id, ctx->current_value, 0, ctx->data_size);
                 
                 // Update last report value
                 memcpy(ctx->last_report_value, ctx->current_value, ctx->data_size);
@@ -230,28 +225,28 @@
         {
             // If a configuration file has been modified, update the context
             case FID_SENSOR_CONFIG_MAG:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(mag_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(mag_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_ACC:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(acc_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(mag_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_GYR:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(gyr_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_PRE:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(pre_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_HUM:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(hum_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_TEM1:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(tem1_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_TEM2:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(tem2_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;
             case FID_SENSOR_CONFIG_LIGHT:
-                ram_fs_read(fid, 0, sizeof(sensor_config_t), (uint8_t*)&(light_thread_ctx.config));
+                ram_fs_read(fid, (uint8_t*)&(gyr_thread_ctx.config), 0, sizeof(sensor_config_t));
                 break;                
             default:
                 break;
@@ -259,8 +254,6 @@
     }
 }
 
-Queue<void, 8> modem_resp;
-
 // Callback for button
 void my_response_callback(uint8_t terminal, int8_t err, uint8_t id)
 {
@@ -273,13 +266,13 @@
     
     if (terminal)
     {    
-        modem_resp.put((void*)MODEM_RESP_TERMINAL);
+        g_file_modified.put((touch_t*)MODEM_RESP_TERMINAL);
     }
     else
     {
         if (ALP_ERR_NONE == err)
         {
-            modem_resp.put((void*)MODEM_RESP_DONE);
+            g_file_modified.put((touch_t*)MODEM_RESP_DONE);
         }
     }
 }
@@ -292,8 +285,10 @@
     uint32_t resp;
     uint8_t alarm;
     d7a_sp_res_t istat;
-    uint8_t user_id = modem_get_id(my_response_callback);
+    alp_payload_t* alp;
+    alp_payload_t* alp_rsp;
     uint8_t nb = 0;
+    int err;
     
     alp_d7a_itf_t alarm_itf = {
         .type                           = ALP_ITF_TYPE_D7A,
@@ -308,7 +303,7 @@
     };
     
     // Load alarm value
-    ram_fs_read(FID_ALARM, 0, 1, &alarm);
+    ram_fs_read(FID_ALARM, &alarm, 0, 1);
     
     while (true)
     {
@@ -316,24 +311,27 @@
         button_user.acquire();
         
         // load/save value to keep coherence in case of remote access...
-        ram_fs_read(FID_ALARM, 0, 1, &alarm);
+        ram_fs_read(FID_ALARM, &alarm, 0, 1);
 
         // Initial value
         if (alarm != 255)
         {
             // Toggle alarm state
             alarm = !alarm;
-            ram_fs_write(FID_ALARM, 0, 1, &alarm);
+            ram_fs_write(FID_ALARM, &alarm, 0, 1);
         }
         
         PRINT("BUTTON ALARM %d\r\n", alarm);
         
         nb = 0;
-        modem_send_file_content((uint8_t*)&alarm_itf, D7_ITF_SIZE(&alarm_itf), (void*)&istat, FID_ALARM, &alarm, 0, 1, user_id);
+        alp = NULL;
+        alp = alp_payload_rsp_f_data(alp, FID_ALARM, &alarm, 0, 1);
+                
+        err = modem_remote_raw_alp((void*)&alarm_itf, alp, &alp_rsp, (uint32_t)15000);
         
         do
         {
-            evt = modem_resp.get();
+            evt = g_file_modified.get();
             resp = (evt.status == osEventMessage)? (uint32_t)evt.value.p : MODEM_RESP_NO;
             
             if (MODEM_RESP_DONE == resp)
@@ -353,14 +351,15 @@
         {
             // Toggle alarm state
             alarm = !!alarm;
-            ram_fs_write(FID_ALARM, 0, 1, &alarm);
+            ram_fs_write(FID_ALARM, &alarm, 0, 1);
         }
     }
 }
 
 // Todo for each sensor
-#define SENSOR_SETUP(NAME,name) modem_update_file(FID_SENSOR_VALUE_##NAME, (alp_file_header_t*)&h_sensor_value_##name, NULL);\
-            modem_update_file(FID_SENSOR_CONFIG_##NAME, (alp_file_header_t*)&h_sensor_config_##name, (uint8_t*)&f_sensor_config_##name);\
+#define SENSOR_SETUP(NAME,name) ram_fs_new(FID_SENSOR_VALUE_##NAME, (uint8_t*)&h_sensor_value_##name, (uint8_t*)f_sensor_value_##name); modem_declare_file(FID_SENSOR_VALUE_##NAME, (alp_file_header_t*)&h_sensor_value_##name);\
+            ram_fs_new(FID_SENSOR_CONFIG_##NAME, (uint8_t*)&h_sensor_config_##name, (uint8_t*)&f_sensor_config_##name);\
+            modem_declare_file(FID_SENSOR_CONFIG_##NAME, (alp_file_header_t*)&h_sensor_config_##name);\
             g_thread_ctx = &name##_thread_ctx;\
             Thread th_##name(osPriorityNormal, 1024, NULL);\
             status = th_##name.start(thread_sensor);\
@@ -384,37 +383,26 @@
           
     FPRINT("(id:0x%08x)\r\n", osThreadGetId());
     
-    modem_helper_open(&callbacks);
-    
-    uint8_t main_id = modem_get_id(my_main_callback);
+    modem_open(&callbacks);
     
     PRINT("Register Files\n");
-    modem_update_file(FID_ALARM, &h_alarm, (uint8_t*)&f_alarm);
-
-    // Configure URC: LQUAL on report file notification every 10 reports
-    PRINT("Setup URCs\n");
-    modem_enable_urc(ALP_URC_TYPE_LQUAL, IFID_REPORT, 10, true, main_id);
-    modem_ready[main_id].acquire();
+    ram_fs_new(FID_ALARM, (uint8_t*)&h_alarm, (uint8_t*)&f_alarm);
+    modem_declare_file(FID_ALARM, (alp_file_header_t*)&h_alarm);
     
-    // Put modem to listen to downlink access class
-    d7a_xcl_t xcl = { .bf.s = 0, .bf.m = 0x1 };
-    modem_write_file(D7A_FID_DLL_CFG, (void*)&xcl, offsetof(d7a_dll_cfg_t, xcl), sizeof(d7a_xcl_t), main_id);
-    modem_ready[main_id].acquire();
+    PRINT("Enable D7A interface\n");
+    modem_d7a_enable_itf();
     
-    modem_flush_file(D7A_FID_DLL_CFG, main_id);
-    modem_ready[main_id].acquire();
+    // Host revision file is in the modem. Update it.
+    PRINT("Update host revision\n");
+    modem_write_file(FID_HOST_REV, (void*)&f_rev, 0, sizeof(revision_t));
     
-    PRINT("Start D7A Stack\n");
-    modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS | ALP_D7A_ISTAT_EOP, true, main_id);
-    modem_ready[main_id].acquire();
     
-    PRINT("Notify Modem Version\n");
-    modem_notify_file(D7A_FID_FIRMWARE_VERSION, 0, SIZE_HOST_REV, main_id);
-    modem_ready[main_id].acquire();
+    // Retrieve modem revision
+    PRINT("Send revision\n");
     
-    PRINT("Notify FW Version\n");
-    uint8_t default_root_key[16] = DEFAULT_ROOT_KEY;
-    modem_notify_host_rev(&f_rev, &h_rev, default_root_key);
+    revision_t rev;
+    
+    modem_read_file(FID_WM_REV, &rev, 0, sizeof(revision_t));
     
     // Start file modified thread
     Thread th_file_modified(osPriorityNormal, 1024, NULL);
@@ -483,7 +471,6 @@
     SENSOR_SETUP(LIGHT,light);
 #endif
     
-    modem_free_id(main_id);
     
     // For button
 #ifdef DEBUG_BUTTON
--- a/modem_callbacks.cpp	Thu May 28 09:22:46 2020 +0000
+++ b/modem_callbacks.cpp	Fri Oct 29 12:55:52 2021 +0000
@@ -1,4 +1,5 @@
-#include "modem_ref_helper.h"
+#include "modem_d7a.h"
+#include "files.h"
 
 #define SERIAL_MAX_PACKET_SIZE  (255)
 
@@ -6,116 +7,76 @@
 
 // Callbacks to MODEM's ALP requests
 // ============================================================{{{
-void my_read(u8 fid, u32 offset, u32 length, int id)
+void my_read(u8 action, u8 fid, u32 offset, u32 length, int id)
 {
     u8 data[SERIAL_MAX_PACKET_SIZE];
     
     ASSERT((ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_F_DATA_SIZE(offset, length)) <= SERIAL_MAX_PACKET_SIZE,
-    "Read response too big for serial protocol (%d/%dmax)", length, ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_F_DATA_SIZE(offset,SERIAL_MAX_PACKET_SIZE));    
-    if (ram_fs_read(fid, offset, length, data))
+    "Read response too big for serial protocol (%d/%dmax)", length, ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_F_DATA_SIZE(offset,SERIAL_MAX_PACKET_SIZE));
+    
+    if (ram_fs_read(fid, data, offset, length))
     {
-        modem_respond(ALP_ERR_FILE_NOT_FOUND, id);
+        modem_ref_respond(action, ALP_ERR_FILE_NOT_FOUND, id);
     }
     else
     {
-        modem_respond_read(fid, data, offset, length, id);
+        modem_ref_respond_read(fid, data, offset, length, id);
     }
 }
 
-void my_write(u8 fid, void *data, u32 offset, u32 length, int id)
+
+void my_write(u8 action, 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, (uint8_t*)data, offset, length))
     {
         err = ALP_ERR_FILE_NOT_FOUND;
     }
     else
     {
-        extern Queue<void, 8> g_file_modified;
-
         err = ALP_ERR_NONE;
-        g_file_modified.put((void*)fid);
+        
+        touch_t* touch = (touch_t*)MALLOC(sizeof(touch_t));
+        
+        touch->fid = fid;
+        touch->offset = offset;
+        touch->length = length;
+        
+        g_file_modified.put(touch);
     }
     
-    modem_respond(err, id);
+    modem_ref_respond(action, err, id);
 }
 
-void my_read_fprop(u8 fid, int id)
+void my_read_fprop(u8 action, u8 fid, int id)
 {
     u8* hdr = (u8*)ram_fs_get_header(fid);
     
-    modem_respond_fprop(fid, hdr, id);
-}
-
-void my_flush(u8 fid, int id)
-{
-    // No flush in this file system
-    modem_respond(ALP_ERR_NONE, id);
-}
-
-void my_delete(u8 fid, int id)
-{
-    alp_errors_t err;
-    
-    err = (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE;
-    
-    modem_respond(err, id);
+    if (hdr != NULL)
+    {
+        modem_ref_respond_fprop(fid, (alp_file_header_t*)hdr, id);
+    }
+    else
+    {
+        modem_ref_respond(action, ALP_ERR_FILE_NOT_FOUND, id);
+    }
 }
 
-void my_udata(void *data, u32 length)
-{    
-    uint8_t* p = (uint8_t*)data;
-    int32_t rem = length;
-    alp_parsed_chunk_t r;
-    d7a_sp_res_t* istat;
-    
-    do {
-        uint32_t parsed = alp_parse_chunk(&p, &r);
-        if (!parsed)
-        {
-            // Discard the payload in case of parsing error.
-            PRINT("Parsing error!\r\n");
-            break;
-        }
-        rem -= parsed;
-        
-        switch (r.type)
-        {
-            // Interface status
-            case ALP_OPCODE_RSP_ISTATUS:
-                // D7A Interface
-                if (ALP_ITF_TYPE_D7A == r.meta.itf.type)
-                {
-                    union {
-                        u8      b[8];
-                        u32     w[2];
-                    } uid;
-                    
-                    // 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
-                    istat = (d7a_sp_res_t*)r.data;
-                    memcpy(uid.b,istat->addressee.id,8);
-                        
-                    PRINT("Got accessed by UID:%08X%08X SNR: %3ddB RXLEV: -%-3ddBm LB: %3ddB\n",
-                    HAL_U32_BYTE_SWAP(uid.w[0]), HAL_U32_BYTE_SWAP(uid.w[1]),
-                    istat->snr, istat->rxlev, istat->lb);
-                }
-                else
-                {
-                    PRINT("Got accessed by unknown Interface 0x%02X\n", r.meta.itf.type);
-                }
-                break;
-            // Data return
-            case ALP_OPCODE_RSP_F_DATA:
-                // RSP_F_DATA can come either alone or together with ISTATUS
-                PRINT("Got UNS File[%3d]@%d %d Bytes\n", r.meta.f_data.fid, r.meta.f_data.offset, r.meta.f_data.length);
-                break;
-            default:
-                PRINT("Untreated OPCODE %d\n", r.type);
-                break;
-        }
-    } while (rem > 0);
+void my_flush(u8 action, u8 fid, int id)
+{
+    // No flush in this file system
+    modem_ref_respond(action, ALP_ERR_NONE, id);
+}
+
+void my_delete(u8 action, u8 fid, int id)
+{
+    modem_ref_respond(action, (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
+}
+
+void my_udata(alp_payload_t* alp)
+{
+    alp_payload_print(alp);
 }
 
 void my_lqual(u8 ifid, int per)
--- a/modem_callbacks.h	Thu May 28 09:22:46 2020 +0000
+++ b/modem_callbacks.h	Fri Oct 29 12:55:52 2021 +0000
@@ -1,18 +1,13 @@
-#ifndef __MODEM_CALLBACKS_H__
-#define __MODEM_CALLBACKS_H__
-
 #include "hal_types.h"
 
-void my_read(u8 fid, u32 offset, u32 length, int id);
-void my_write(u8 fid, void *data, u32 offset, u32 length, int id);
-void my_read_fprop(u8 fid, int id);
-void my_flush(u8 fid, int id);
-void my_delete(u8 fid, int id);
-void my_udata(void *data, u32 length);
+void my_read(u8 action, u8 fid, u32 offset, u32 length, int id);
+void my_write(u8 action, u8 fid, void *data, u32 offset, u32 length, int id);
+void my_read_fprop(u8 action, u8 fid, int id);
+void my_flush(u8 action, u8 fid, int id);
+void my_delete(u8 action, u8 fid, int id);
+void my_udata(alp_payload_t*);
 void my_lqual(u8 ifid, int per);
 void my_ldown(u8 ifid);
 void my_reset(void);
 void my_boot(u8 cause, u16 number);
-void my_busy(u8 busy);
-
-#endif
\ No newline at end of file
+void my_busy(u8 busy);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modem_d7a.lib	Fri Oct 29 12:55:52 2021 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/WizziLab/code/modem_ref_helper/#dcf0983476aa
--- a/modem_ref_helper.lib	Thu May 28 09:22:46 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/WizziLab/code/modem_ref_helper/#d624707636f9