Broadcast read demo.
Dependencies: modem_ref_helper DebouncedInterrupt
Diff: main.cpp
- Revision:
- 11:22ba8d277699
- Parent:
- 10:da9ad8019d02
- Child:
- 12:5e1fd1a5580a
--- a/main.cpp Fri Mar 09 16:16:16 2018 +0000 +++ b/main.cpp Wed Sep 19 15:16:45 2018 +0000 @@ -17,24 +17,13 @@ MODEM_RESP_DONE, }; -uint8_t g_main_id; - -alp_retry_policy_t my_policy = { - .meta.procedure = 0, - .meta.respond = true, - .meta.persistant = false, - .meta.bulk = false, - .depth = 1, - .retries = 0, - .slot_time = 0 -}; alp_d7a_itf_t my_itf = { .type = ALP_ITF_TYPE_D7A, .cfg.to = 0, .cfg.te = 0, .cfg.qos.bf.resp = D7A_RESP_ALL, - .cfg.qos.bf.retry = MY_POLICY_IDX, + .cfg.qos.bf.retry = ALP_RPOL_ONESHOT, .cfg.addressee.ctrl.bf.nls = D7A_NLS_AES_CCM_64, .cfg.addressee.ctrl.bf.idf = D7A_ID_NBID, .cfg.addressee.xcl.bf = {.s = 0x2, .m = 0x1},// XXX D7A_XCL_GW, @@ -109,7 +98,7 @@ fw_version_t fw_ver; uint8_t nb = 0; - uint8_t my_user_id = modem_get_id(my_read_response_callback); + uint8_t id = modem_get_id(my_read_response_callback); uint8_t scan_xcl[] = { 0x01, 0x21 }; @@ -129,7 +118,7 @@ PRINT("Scanning XCL 0x%02X...\n", my_itf.cfg.addressee.xcl.byte); - modem_remote_read_file((uint8_t*)&my_itf, D7_ITF_SIZE(&my_itf), (void*)&istat, D7A_FID_FIRMWARE_VERSION, (void*)&fw_ver, 12, sizeof(fw_version_t), my_user_id); + modem_remote_read_file((uint8_t*)&my_itf, D7_ITF_SIZE(&my_itf), (void*)&istat, D7A_FID_FIRMWARE_VERSION, (void*)&fw_ver, 12, sizeof(fw_version_t), id); do { @@ -166,10 +155,11 @@ .lqual = my_lqual, .ldown = my_ldown, .reset = my_reset, - .boot = my_boot + .boot = my_boot, + .busy = my_busy, }; -// Callback for g_main_id User +// Callback for id User void my_main_callback(uint8_t terminal, int8_t err, uint8_t id) { (void)id; @@ -203,35 +193,18 @@ modem_helper_open(&callbacks); - g_main_id = modem_get_id(my_main_callback); - - // Set custom retry policy - // XXX Won't work the first time as we need to reboot the modem for the changes to be applied - // 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(); - 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(); - } + uint8_t id = modem_get_id(my_main_callback); // 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, g_main_id); + modem_enable_urc(ALP_URC_TYPE_LQUAL, IFID_REPORT, 10, true, id); modem_ready.wait(); PRINT("Start D7A Stack\n"); - modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS, true, g_main_id); + modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS, true, id); modem_ready.wait(); + + modem_free_id(id); #ifdef DEBUG_BUTTON DebouncedInterrupt user_interrupt(DEBUG_BUTTON);