IoT Drivers  v3.3.0 (S2022)
Engineering in Software Technology
Sent an uplink message

In this use case, an uplink message will be send.

Note
The driver must be initialised Initialise the driver and must be setup to OTAA OTAA setup steps or ABP OTAA setup steps.

In this example these two variables will be send in an uplink message

uint16_t hum; // Humidity
int16_t temp; // Temperature

Uplink Message Setup

The following must be added to a FreeRTOS task in the project:

  1. Define a payload struct variable
    lora_driver_payload_t uplinkPayload;
  2. Populate the payload struct with data
    uplinkPayload.len = 4; // Length of the actual payload
    uplinkPayload.port_no = 1; // The LoRaWAN port no to sent the message to
    uplinkPayload.bytes[0] = hum >> 8;
    uplinkPayload.bytes[1] = hum & 0xFF;
    uplinkPayload.bytes[2] = temp >> 8;
    uplinkPayload.bytes[3] = temp & 0xFF;
  3. Send the uplink message:
    if ((rc = lora_driver_sendUploadMessage(false, &_uplinkPayload)) == LORA_MAC_TX_OK )
    {
    // The uplink message is sent and there is no downlink message received
    }
    else if (rc == LORA_MAC_RX_OK)
    {
    // The uplink message is sent and a downlink message is received
    }
lora_driver_returnCode_t
enum Lora_driver_returnCodes lora_driver_returnCode_t
LoRA Driver return codes.
lora_driver_payload::len
uint8_t len
Definition: lora_driver.h:53
lora_driver_sendUploadMessage
lora_driver_returnCode_t lora_driver_sendUploadMessage(bool confirmed, lora_driver_payload_t *payload)
Send a upload message to the LoRaWAN.
lora_driver_payload::bytes
uint8_t bytes[LORA_MAX_PAYLOAD_LENGTH]
Definition: lora_driver.h:54
LORA_MAC_TX_OK
@ LORA_MAC_TX_OK
Definition: lora_driver.h:81
lora_driver_payload
Payload data structure.
Definition: lora_driver.h:51