Sending and reception of big data file (1kB example)

Dependencies:   modem_ref_helper CRC DebouncedInterrupt

Revision:
9:26cd994b5303
Parent:
8:4592de5f3ac1
Child:
11:dc0e19b2d4a0
--- a/main.cpp	Wed Sep 26 13:59:45 2018 +0000
+++ b/main.cpp	Thu Oct 11 14:01:39 2018 +0000
@@ -34,28 +34,18 @@
     .cfg.qos.bf.retry               = ALP_RPOL_ONESHOT,
     .cfg.addressee.ctrl.bf.nls      = D7A_NLS_AES_CCM_64, // Security level
     .cfg.addressee.ctrl.bf.idf      = D7A_ID_NBID,
-    .cfg.addressee.xcl.bf           = {.s = 0x2, .m = 0x1}, // Gateway access class
-    .cfg.addressee.id[0]            = D7A_CTF_VAL(4,0),
+    .cfg.addressee.xcl.bf           = {.s = 2, .m = 0x1}, // Gateway access class
+    .cfg.addressee.id[0]            = D7A_CTF_ENCODE(4),
 };
 
-void print_status(uint8_t id, int status)
-{
-    switch (status)
-    {
-        case ALP_ERR_NONE:
-            PRINT("Status[%d]: OK\n", id);
-            break;
-        default:
-            PRINT("Status[%d]: error %d\n", id, status);
-            break;
-    }
-}
-
 // Response Callback
 void my_response_callback(uint8_t terminal, int8_t err, uint8_t id)
 {    
-    print_status(id, err);
-
+    if (ALP_ERR_NONE != err)
+    {
+        modem_print_error(ALP_ITF_TYPE_D7A, err);
+    }
+    
     if (terminal)
     {
         modem_resp[id].put((void*)MODEM_RESP_TERMINAL);
@@ -332,8 +322,11 @@
 // Callback
 void my_main_callback(uint8_t terminal, int8_t err, uint8_t id)
 {    
-    print_status(id, err);
-
+    if (ALP_ERR_NONE != err)
+    {
+        modem_print_error(ALP_ITF_TYPE_D7A, err);
+    }
+    
     if (terminal)
     {
         modem_ready.release();
@@ -363,13 +356,11 @@
     modem_ready.wait();
     
     PRINT("Register Files\n");
-    // HOST Revision is a local file. Uses D7AActP Notification.
-    modem_update_file(FID_HOST_REV, (alp_file_header_t*)&h_rev, (uint8_t*)&f_rev);
     modem_update_file(FID_OUTPUT_FILE, (alp_file_header_t*)&h_output_file, (uint8_t*)&f_output_file);
     modem_update_file(FID_INPUT_FILE, (alp_file_header_t*)&h_input_file, (uint8_t*)&f_input_file);
     
     PRINT("Start D7A Stack\n");
-    modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS, true, id);
+    modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS | ALP_D7A_ISTAT_EOP, true, id);
     modem_ready.wait();
     
     PRINT("Notify Modem Version\n");
@@ -377,8 +368,8 @@
     modem_ready.wait();
     
     PRINT("Notify Host Version\n");
-    modem_notify_file(FID_HOST_REV, 0, SIZE_HOST_REV, id);
-    modem_ready.wait();
+    uint8_t default_root_key[] = DEFAULT_ROOT_KEY;
+    modem_notify_host_rev(&f_rev, &h_rev, default_root_key);
     
     // id no longer needed
     modem_free_id(id);