Helper library to use modem_ref driver.

Dependencies:   WizziCom WizziDebug ram_fs modem_ref

Dependents:   D7A_Localisation D7A_1x_demo_send_file_data_and_forget D7A_1x_demo_CodeUpgradeProtocol D7A_1x_demo_LoRaWAN ... more

Revision:
58:f7105abdceed
Parent:
49:035512e64fdd
Child:
60:524b4f20d332
--- a/modem_ref_helper.cpp	Tue Apr 02 08:54:46 2019 +0000
+++ b/modem_ref_helper.cpp	Wed Jul 31 16:49:08 2019 +0000
@@ -235,7 +235,7 @@
     // Write the version to the version file.
     // This file is notified on write.
     modem_write_file_root(FID_HOST_REV, (void*)data, 0, HAL_U32_BYTE_SWAP(header->alloc), root_key, id);
-    g_modem_ready.wait();
+    g_modem_ready.try_acquire();
     
     // Error when writing to the file
     if (ALP_ERR_NONE != g_err)
@@ -245,16 +245,16 @@
         {
             // Delete old file
             modem_delete_file_root(FID_HOST_REV, root_key, id);
-            g_modem_ready.wait();
+            g_modem_ready.try_acquire();
         }
         
         // Recreate file
         modem_create_file(FID_HOST_REV, header, id);
-        g_modem_ready.wait();
+        g_modem_ready.try_acquire();
         
         // Retry writing to the file
         modem_write_file_root(FID_HOST_REV, (void*)data, 0, HAL_U32_BYTE_SWAP(header->alloc), root_key, id);
-        g_modem_ready.wait();
+        g_modem_ready.try_acquire();
     }
     
     modem_free_id(id);
@@ -269,7 +269,7 @@
     
     // Read remote header
     modem_read_fprop(fid, &remote_header, id);
-    g_modem_ready.wait();
+    g_modem_ready.try_acquire();
     
     // Add file in local file system
     ram_fs_new(fid, (uint8_t*)header, data);
@@ -280,7 +280,7 @@
         HELPER_PRINT("Updating file %d\n", fid);
         // Delete
         modem_delete_file(fid, id);
-        g_modem_ready.wait();
+        g_modem_ready.try_acquire();
         // Restore in local file system
         ram_fs_new(fid, (uint8_t*)header, data);
         // Re-create
@@ -292,7 +292,7 @@
         {
             modem_create_file(fid, header, id);
         }
-        g_modem_ready.wait();
+        g_modem_ready.try_acquire();
     }
     else
     {
@@ -338,7 +338,7 @@
     
     // Hardware reset
     DigitalOut reset_low(MODEM_PIN_RESET, 0);
-    Thread::wait(100);
+    ThisThread::sleep_for(100);
     
     // Open driver to catch boot packet
     modem_open(NULL, &boot_callbacks);
@@ -351,7 +351,7 @@
     
     // Wait for first boot packet
     HELPER_PRINT("Waiting boot packet...\n");
-    boot.wait();
+    boot.try_acquire();
     
     // Re-open with user callbacks
     modem_close();
@@ -360,13 +360,13 @@
     uint8_t id = modem_get_id(my_main_callback);
 
     HELPER_PRINT("Start Modem Process (id=%d)\n", id);
-    Thread::wait(1000);
+    ThisThread::sleep_for(1000);
     
     modem_read_file(D7A_FID_UID, uid.b, 0, 8, id);
-    g_modem_ready.wait();
+    g_modem_ready.try_acquire();
     
     modem_read_file(D7A_FID_FIRMWARE_VERSION, (uint8_t*)&rev, 0, sizeof(revision_t), id);
-    g_modem_ready.wait();
+    g_modem_ready.try_acquire();
     
     PRINT("------------ D7A Modem infos ------------\r\n");
     PRINT_DATA(" - UID:              ", "%02X", uid.b, 8, "\r\n");
@@ -394,7 +394,7 @@
                   "   Right click on modem_ref_helper -> Revision.\r\n"
                   , MODEM_VERSION_MAJOR, MODEM_VERSION_MINOR, MODEM_VERSION_PATCH);
     
-            Thread::wait(osWaitForever);
+            ThisThread::sleep_for(osWaitForever);
         }
     }
     else