Complete sensor demo.

Dependencies:   modem_ref_helper CRC X_NUCLEO_IKS01A1 DebouncedInterrupt

Revision:
15:1271f3566b98
Parent:
14:8fd5405f7ab2
Child:
17:3e6083d76bc6
--- a/main.cpp	Thu Oct 11 15:15:30 2018 +0000
+++ b/main.cpp	Fri Aug 02 16:39:28 2019 +0000
@@ -200,7 +200,7 @@
             {
                 // Send notification
                 modem_write_file(ctx->value_file_id, ctx->current_value, 0, ctx->data_size, user_id);
-                modem_ready[user_id].wait();
+                modem_ready[user_id].acquire();
                 
                 // Update last report value
                 memcpy(ctx->last_report_value, ctx->current_value, ctx->data_size);
@@ -212,7 +212,7 @@
         // Update last report time
         last_report_time += ctx->config.read_period;
         
-        Thread::wait(ctx->config.read_period);
+        ThisThread::sleep_for(ctx->config.read_period);
     }
 }
 
@@ -313,7 +313,7 @@
     while (true)
     {
         // Wait for button press
-        button_user.wait();
+        button_user.acquire();
         
         // load/save value to keep coherence in case of remote access...
         ram_fs_read(FID_ALARM, 0, 1, &alarm);
@@ -365,7 +365,7 @@
             Thread th_##name(osPriorityNormal, 1024, NULL);\
             status = th_##name.start(thread_sensor);\
             ASSERT(status == osOK, "Failed to start thread (err: %d)\r\n", status);\
-            thread_ready.wait()
+            thread_ready.acquire()
             
 /*** Main function ------------------------------------------------------------- ***/
 int main()
@@ -394,23 +394,23 @@
     // 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].wait();
+    modem_ready[main_id].acquire();
     
     // 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].wait();
+    modem_ready[main_id].acquire();
     
     modem_flush_file(D7A_FID_DLL_CFG, main_id);
-    modem_ready[main_id].wait();
+    modem_ready[main_id].acquire();
     
     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].wait();
+    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].wait();
+    modem_ready[main_id].acquire();
     
     PRINT("Notify FW Version\n");
     uint8_t default_root_key[16] = DEFAULT_ROOT_KEY;
@@ -500,11 +500,11 @@
 #endif
 
     // Set main task to lowest priority
-    osThreadSetPriority(osThreadGetId(), osPriorityIdle);
+    osThreadSetPriority(osThreadGetId(), osPriorityLow);
     while(true)
     {
         // Wait to avoid beeing stuck in loop
-        Thread::wait(500);
+        ThisThread::sleep_for(500);
 #ifdef DEBUG_LED
         my_led = !my_led;
 #endif