Uplink to TTN using LoRa-E5-Dev-Board and Mbed OS

Hi there,

I am currently working on a project using the LoRa-E5-Dev-Board with Mbed OS, and I need assistance with sending a simple “Hello World” message to The Things Network (TTN). I have encountered issues while using the provided LoRaWAN example, and I’m not receiving any results.

Which example where?

This could have so many possible meanings. Can you tell us what is happening?

Sending text is hugely inefficient and becomes a bad habit - just send a single random number!


Please have a look at some of the other requests for assistance on the forum so you can see what is an appropriate level of detail and supporting material that is required - links to code, logs formatted with the </> tool etc etc.

2 Likes

Hi , Thanks for your suggestions. Here is the detailed information about my issue:

I am trying to send a simple “Hello TTN” message to The Things Network (TTN) using ABP activation. Below is the code I am using:

#include “mbed.h”
#include “LoRaWANInterface.h”
#include “lorawan/lorawan_types.h”
#include “events/EventQueue.h”
#include “trace_helper.h”
#include “lora_radio_helper.h”
#include “mbedtls_lora_config.h” // Inclusion de la configuration mbedtls

// Configuration de l’interface LoRaWAN
static LoRaWANInterface lorawan(radio);
static lorawan_app_callbacks_t callbacks;
static EventQueue ev_queue;

// Clé de réseau, clé d’application et adresse du dispositif pour ABP
static uint32_t DEVADDR = 0x260B9922; // Remplacez par votre DevAddr
static uint8_t NWKSKEY = { 0x1F, 0x3B, 0x32, 0xB8, 0xFF, 0x04, 0x4A, 0x15, 0xE9, 0x04, 0xE8, 0x94, 0xD3, 0x24, 0x1C, 0x6E }; // Remplacez par votre NwkSKey
static uint8_t APPSKEY = { 0x6A, 0x99, 0xCB, 0x86, 0x6C, 0x99, 0x91, 0x9F, 0x7C, 0xFD, 0xF7, 0x30, 0xC4, 0x77, 0x6D, 0xD9 }; // Remplacez par votre AppSKey

static void lora_event_handler(lorawan_event_t event) {
printf(“Événement LoRa : %d\n”, event);
switch (event) {
case CONNECTED:
printf(“Connexion réussie!\n”);
break;
case DISCONNECTED:
printf(“Déconnexion!\n”);
break;
case TX_DONE:
printf(“Transmission terminée!\n”);
break;
case TX_TIMEOUT:
case TX_ERROR:
case TX_CRYPTO_ERROR:
case TX_SCHEDULING_ERROR:
printf(“Erreur de transmission!\n”);
break;
case RX_DONE:
printf(“Message reçu!\n”);
break;
case RX_TIMEOUT:
case RX_ERROR:
printf(“Erreur de réception!\n”);
break;
case JOIN_FAILURE:
printf(“Échec de la connexion!\n”);
break;
case UPLINK_REQUIRED:
printf(“Uplink requis!\n”);
break;
default:
printf(“Événement inconnu (%d)!\n”, event);
break;
}
}

void send_message() {
uint8_t tx_buffer = “hello ttn”;
int16_t retcode = lorawan.send(15, tx_buffer, sizeof(tx_buffer), MSG_UNCONFIRMED_FLAG);
printf(“Envoi d’un message…\n”);
if (retcode < 0) {
printf(“Échec de l’envoi du message (%d)!\n”, retcode);
} else {
printf(“Message envoyé!\n”);
}
}

int main() {
// Initialisation de la trace
setup_trace();
printf(“Trace initialisée…\n”);

// Initialisation de l'interface LoRaWAN
if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
    printf("Échec de l'initialisation de LoRa!\n");
    return -1;
}
printf("Interface LoRaWAN initialisée...\n");

// Configuration des callbacks
callbacks.events = mbed::callback(lora_event_handler);
lorawan.add_app_callbacks(&callbacks);
printf("Callbacks configurés...\n");

// Configuration des paramètres ABP
lorawan_connect_t connection_params;
connection_params.connect_type = LORAWAN_CONNECTION_ABP;
connection_params.connection_u.abp.dev_addr = DEVADDR;
connection_params.connection_u.abp.nwk_skey = NWKSKEY;
connection_params.connection_u.abp.app_skey = APPSKEY;
printf("Paramètres ABP configurés...\n");

// Connexion au réseau
if (lorawan.connect(connection_params) != LORAWAN_STATUS_OK) { 
    printf("Échec de la connexion LoRa!\n");
    return -1;
}
printf("Connexion LoRaWAN en cours...\n");

// Envoi d'un message après connexion
send_message();

// Boucle principale
ev_queue.dispatch_forever();

}

Here are the steps I followed and the issues I am facing:

-. The code compiles successfully without any errors.
-. Upon running the code, I see the following outputs:

  • “Trace initialisée…”
  • “Interface LoRaWAN initialisée…”
  • “Callbacks configurés…”
  • “Paramètres ABP configurés…”
  • “Connexion LoRaWAN en cours…”
    *“Échec de la connexion LoRa!”
  • Consequently, the “Envoi d’un message…” message does not appear, indicating that the send_message function is not being called.

I have verified that my DevAddr, NwkSKey, and AppSKey are correct and match the details provided in TTN. Additionally, I am not seeing any activity on the TTN console.

This ^^^

Please consider that you are making it harder for the volunteers to answer.

Just to clarify, you have a message that comes up that tells you where in the code that it got to. What have you looked at to investigate this?

I compiled the code using the command: mbedtools compile -m LORA_E5_DEV_BOARD -t GCC_ARM
This successfully created a .hex file, which I then downloaded to the board. The messages I observed were displayed in Tera Term when I powered up the board

All fine and good - but what have you done about the actual error that you get?

Do you understand the flow of the code?