Sending and reception of big data file (1kB example)
Dependencies: modem_ref_helper CRC DebouncedInterrupt
Diff: main.cpp
- Revision:
- 6:33dfecc85ebf
- Parent:
- 1:76a8a3cc5f2e
- Child:
- 8:4592de5f3ac1
--- a/main.cpp Mon Jan 29 18:12:32 2018 +0000 +++ b/main.cpp Thu Sep 06 10:01:01 2018 +0000 @@ -9,7 +9,6 @@ #define MIN(a,b) ((a<b)?a:b) -#define MY_POLICY_IDX 0 #define CHUNK_SIZE 128 Semaphore button_user(0); @@ -24,19 +23,6 @@ MODEM_RESP_ACK, MODEM_RESP_TIMEOUT, }; - -// This discribes the retry policy of the stack for each packet -// Do not modify uncommented parameters -// After changing this, reboot the modem to apply it -alp_retry_policy_t my_policy = { - .meta.procedure = 0, - .meta.respond = true, - .meta.persistant = false, - .meta.bulk = false, - .depth = 1, - .retries = 2, // The stack will retry 2 times (each packet will be sent a maximum of 3 times) - .slot_time = 1, // Interval between retries in seconds -}; // This describe the upload interface // Do not modify uncommented parameters @@ -45,9 +31,7 @@ .cfg.to = 0, .cfg.te = 0, .cfg.qos.bf.resp = D7A_RESP_PREFERRED, - .cfg.qos.bf.retry = MY_POLICY_IDX, - .cfg.qos.bf.record = 0, - .cfg.qos.bf.stop_on_err = 0, + .cfg.qos.bf.retry = ALP_RPOL_ONESHOT, .cfg.addressee.ctrl.bf.nls = D7A_NLS_AES_CCM_64, // Security level .cfg.addressee.ctrl.bf.idf = D7A_ID_NBID, .cfg.addressee.xcl.bf = {.s = 0x2, .m = 0x1}, // Gateway access class @@ -278,8 +262,6 @@ // Check if CRC has been updated if ((offsetof(input_file_t, crc) == touch->offset) && (sizeof_field(input_file_t, crc) == touch->length)) { - - PRINT("INPUT CRC 0x%08X CRC 0x%08X (on %d bytes)\n", input->crc, crc, input_length); if (input->crc != crc) @@ -348,7 +330,8 @@ .lqual = my_lqual, .ldown = my_ldown, .reset = my_reset, - .boot = my_boot + .boot = my_boot, + .busy = my_busy, }; // Callback @@ -381,11 +364,9 @@ uint8_t 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 - modem_write_file(WM_FID_ALP_CFG, &my_policy, MY_POLICY_IDX * sizeof(alp_retry_policy_t), sizeof(alp_retry_policy_t), id); - modem_ready.wait(); - modem_flush_file(WM_FID_ALP_CFG, id); + // 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), id); modem_ready.wait(); PRINT("Register Files\n");