Dash7Board Code Upgrade Protocol demonstration code.

Dependencies:   modem_ref_helper CRC

Revision:
4:c97df2bc1731
Parent:
3:cfe26c2bb78b
Child:
6:1bdff7d6689c
--- a/main.cpp	Fri Oct 05 16:59:14 2018 +0000
+++ b/main.cpp	Thu Oct 11 12:52:30 2018 +0000
@@ -15,23 +15,7 @@
 extern uint32_t stream_crc;
 extern int32_t last_end;
 
-const uint8_t default_root_key[] = {206, 87, 116, 11, 4, 30, 202, 254, 206, 87, 116, 11, 4, 30, 202, 254};
-
-void print_resp(uint8_t id, int status)
-{
-    switch (status)
-    {
-        case ALP_ERR_NONE:
-            //PRINT("Resp[%d]: OK\n", id);
-            break;
-        case ALP_ERR_FILE_EXIST:
-            PRINT("Resp[%d]: Already registered\n", id);
-            break;
-        default:
-            PRINT("Resp[%d]: error %d\n", id, status);
-            break;
-    }
-}
+const uint8_t default_root_key[] = DEFAULT_ROOT_KEY;
 
 modem_callbacks_t callbacks = {
     .read       = my_read,
@@ -52,7 +36,10 @@
 {
     (void)id;
     
-    print_resp(id, err);
+    if (ALP_ERR_NONE != err)
+    {
+        modem_print_error(ALP_ITF_TYPE_D7A, err);
+    }
 
     if (terminal)
     {
@@ -92,10 +79,10 @@
                     
                     tim.stop();
                     tim.reset();
-                    total = 0;
-                    next_chunk = 0;
-                    stream_crc = 0;
-                    chunks=0;
+                    total       = 0;
+                    next_chunk  = 0;
+                    stream_crc  = 0;
+                    chunks      = 0;
                     
                     // Write to the modem CUP config file (as root)
                     // to enter upload mode
@@ -157,7 +144,6 @@
                     PRINT("Receiving CUP code chunks-> ");
                 }
                 
-                
                 if (next_chunk < touch->offset)
                 {
                     PRINT("\nMissed %d chunk(s) at offset %d (got offset %d)\n", (touch->offset - next_chunk) / CHUNK_SIZE, next_chunk, touch->offset);
@@ -232,7 +218,7 @@
     
     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, 0, true, id);
+    modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_EOP, true, id);
     modem_ready.wait();
     
     PRINT("Notify Modem Version\n");
@@ -240,8 +226,7 @@
     modem_ready.wait();
     
     PRINT("Notify Host Version\n");
-    modem_notify_file(FID_HOST_REV, 0, SIZE_HOST_REV, id);
-    modem_ready.wait();
+    modem_notify_host_rev(&f_rev, &h_rev, (uint8_t*)default_root_key);
     
     // id no longer needed
     modem_free_id(id);