Scan example on D7-LoRa
Dependencies: modem_ref_helper DebouncedInterrupt
Diff: main.cpp
- Revision:
- 3:c1a36c817c48
- Parent:
- 2:de388004dca6
- Child:
- 5:8c7ce9a28169
--- a/main.cpp Thu Sep 20 08:36:34 2018 +0000 +++ b/main.cpp Thu Oct 11 11:07:38 2018 +0000 @@ -15,7 +15,7 @@ #define XCL_UL d7fsk_ul_xcl #endif -#if 1 +#if 0 // Disable Duty Cycle #define DUTY 255 #else @@ -23,8 +23,6 @@ #define DUTY D7A_CTF_ENCODE(31) #endif -#define MY_POLICY_IDX 0 - Semaphore button_user(0); Semaphore modem_ready(0); Queue<void, 8> modem_resp; @@ -35,11 +33,11 @@ MODEM_RESP_DONE, }; -d7a_xcl_t d7fsk_dl_xcl = { .bf.s = 0, .bf.m = 1 }; -d7a_xcl_t d7fsk_ul_xcl = { .bf.s = 2, .bf.m = 1 }; +d7a_xcl_t d7fsk_dl_xcl = { .bf.s = 0, .bf.m = 0x1 }; +d7a_xcl_t d7fsk_ul_xcl = { .bf.s = 2, .bf.m = 0x1 }; -d7a_xcl_t d7lora_dl_xcl = { .bf.s = 8, .bf.m = 1 }; -d7a_xcl_t d7lora_ul_xcl = { .bf.s = 9, .bf.m = 1 }; +d7a_xcl_t d7lora_dl_xcl = { .bf.s = 8, .bf.m = 0x1 }; +d7a_xcl_t d7lora_ul_xcl = { .bf.s = 9, .bf.m = 0x1 }; alp_d7a_itf_t my_itf = { .type = ALP_ITF_TYPE_D7A, @@ -50,54 +48,25 @@ .cfg.addressee.ctrl.bf.nls = D7A_NLS_AES_CCM_64, .cfg.addressee.ctrl.bf.idf = D7A_ID_NBID, .cfg.addressee.xcl = XCL_UL, - .cfg.addressee.id[0] = D7A_CTF_VAL(4,0), + .cfg.addressee.id[0] = D7A_CTF_ENCODE(4), }; -void print_status(int status) -{ - switch (status) - { - case ALP_ERR_NONE: - //PRINT("Status: OK\n"); - break; - case ALP_ERR_FILE_EXIST: - PRINT("Status: Already registered\n"); - break; - default: - PRINT("Status: error %d\n", status); - break; - } -} - -void print_resp(int status) -{ - switch (status) - { - case ALP_ERR_NONE: - //PRINT("Resp: OK\n"); - break; - case ALP_ERR_FILE_EXIST: - PRINT("Resp: Already registered\n"); - break; - default: - PRINT("Resp: error %d\n", status); - break; - } -} - // Callback for broadcast read void my_read_response_callback(uint8_t terminal, int8_t err, uint8_t id) { (void)id; + if (ALP_ERR_NONE != err) + { + modem_print_error(ALP_ITF_TYPE_D7A, err); + } + if (terminal) { - print_status(err); modem_resp.put((void*)MODEM_RESP_TERMINAL); } else { - print_resp(err); if (ALP_ERR_NONE == err) { modem_resp.put((void*)MODEM_RESP_DONE); @@ -186,15 +155,15 @@ { (void)id; + if (ALP_ERR_NONE != err) + { + modem_print_error(ALP_ITF_TYPE_D7A, err); + } + if (terminal) - { - print_status(err); + { modem_ready.release(); } - else - { - print_resp(err); - } } /*** Main function ------------------------------------------------------------- ***/ @@ -208,7 +177,7 @@ #endif PRINT("\n" "-----------------------------------------\n" - "-------------- Demo D7A LoRa ------------\n" + "------------- Demo D7A LoRa -------------\n" "-----------------------------------------\n"); FPRINT("(id:0x%08x)\r\n", osThreadGetId()); @@ -246,7 +215,7 @@ } PRINT("Start D7A Stack\n"); - modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS, true, id); + modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_RESP | ALP_D7A_ISTAT_UNS | ALP_D7A_ISTAT_EOP, true, id); modem_ready.wait(); modem_free_id(id);