Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 5 months ago.
How to speed up connection using LoRaWANInterface?
I'm using a DISCO-L072CZ-LRWAN1 to design a basic humidity sensor that sends the data via LoRa to a gateway. The eventual application will be battery powered. The application is built as stated here: https://os.mbed.com/docs/v5.8/reference/lorawan-api.html
It works but it takes up to a minute to connect to the gateway and start sending data, which is far too long for the battery powered version. What is causing it to take so long? And is there a way to speed it up?
LoRa Humidity Sensor Main
int main (void) { lorawan_status_t retcode; //Stores the status of a call to LoRaWAN protocol if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) { //Initialize LoRaWAN stack pc.printf("[ERROR] LoRa initialization failed! \r\n"); return -1; } pc.printf("Mbed LoRaWANStack initialized \r\n"); callbacks.events = mbed::callback(lora_event_handler); //Prepare application callbacks lorawan.add_app_callbacks(&callbacks); if (lorawan.set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER) //Set number of retries in case of CONFIRMED messages != LORAWAN_STATUS_OK) { pc.printf("[ERROR] set_confirmed_msg_retries failed! \r\n\r\n"); return -1; } pc.printf("CONFIRMED message retries : %d \r\n", CONFIRMED_MSG_RETRY_COUNTER); if (lorawan.enable_adaptive_datarate() != LORAWAN_STATUS_OK) { //Enable adaptive data rate pc.printf("[ERROR] enable_adaptive_datarate failed! \r\n"); return -1; } pc.printf("Adaptive data rate (ADR) - Enabled \r\n"); retcode = lorawan.connect(); if (retcode == LORAWAN_STATUS_OK || retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) { } else { pc.printf("[ERROR] Connection error, code = %d \r\n", retcode); } pc.printf("Connection - In Progress ...\r\n"); uint32_t val; while(1) { val = get_hum(); pc.printf("Read humidity value: %i \r\n", val); ev_queue.dispatch(); wait_ms(30000); } return 0; }