Broadcast read demo.
Dependencies: modem_ref_helper DebouncedInterrupt
Diff: main.cpp
- Revision:
- 9:8f4e03d45e1e
- Parent:
- 7:93ad76eebd33
- Child:
- 10:da9ad8019d02
--- a/main.cpp Thu Dec 21 15:18:38 2017 +0000 +++ b/main.cpp Mon Jan 29 18:11:25 2018 +0000 @@ -121,6 +121,7 @@ while (true) { // Wait for button press + PRINT("Press button to scan...\r\n"); button_user.wait(); for (uint8_t i = 0; i < sizeof(scan_xcl); i++) @@ -208,10 +209,22 @@ // Set custom retry policy // XXX Won't work the first time as we need to reboot the modem for the changes to be applied - modem_write_file(WM_FID_ALP_CFG, &my_policy, MY_POLICY_IDX * sizeof(alp_retry_policy_t), sizeof(alp_retry_policy_t), g_main_id); + // Check current retry policy + alp_retry_policy_t old; + modem_read_file(WM_FID_ALP_CFG, &old, MY_POLICY_IDX * sizeof(alp_retry_policy_t), sizeof(alp_retry_policy_t), g_main_id); modem_ready.wait(); - modem_flush_file(WM_FID_ALP_CFG, g_main_id); - modem_ready.wait(); + if (memcmp(&old, &my_policy, sizeof(alp_retry_policy_t))) + { + // Update retry policy + modem_write_file(WM_FID_ALP_CFG, &my_policy, MY_POLICY_IDX * sizeof(alp_retry_policy_t), sizeof(alp_retry_policy_t), g_main_id); + modem_ready.wait(); + modem_flush_file(WM_FID_ALP_CFG, g_main_id); + modem_ready.wait(); + + // Reboot + PRINT("Rebooting to apply new retry policy\n"); + my_reset(); + } // Configure URC: LQUAL on report file notification every 10 reports PRINT("Setup URCs\n");