Dash7Board Code Upgrade Protocol demonstration code.

Dependencies:   modem_ref_helper CRC

Revision:
2:49acddddec25
Parent:
1:dd4e18b267a1
Child:
3:cfe26c2bb78b
--- a/main.cpp	Tue Feb 27 11:06:42 2018 +0000
+++ b/main.cpp	Wed Sep 19 15:58:35 2018 +0000
@@ -88,8 +88,8 @@
                 {
                     PRINT("Enter upload mode. Watchdog %ds\n", cup_cfg.arch_nb);
                     
+                    tim.stop();
                     tim.reset();
-                    tim.start();
                     total = 0;
                     next_chunk = 0;
                     stream_crc = 0;
@@ -108,7 +108,7 @@
                     
                     PRINT("Done. %d/%d bytes received in %.2f sec (%.2f kb/s)\r\n"
                           "Expected CRC 0x%08X. Stream CRC 0x%08X.\r\n",
-                            total, expected_size, time_s, (total/time_s)/1024.0,
+                            total, expected_size, time_s, (double)(total/time_s)/1024.0,
                             expected_crc, stream_crc);
                     
                     tim.stop();
@@ -146,6 +146,12 @@
                 // Chunk data should be saved in my_write callback
                 PRINT("Got CUP code chunk length %d offset %d\n", touch->length, touch->offset);
                 
+                if (!next_chunk)
+                {
+                    // First chunk, start timer
+                    tim.start();
+                }
+                
                 total += touch->length;
                 
                 if (next_chunk != touch->offset)