Downlink Control on LoRaWAN_End_Node

Hello everyone,

Currently, I am trying to do some simple command from Chirpstack Network Server to an end node.

The end mode is Nucleo-WL55JC1 and the code inside is the example LoRaWAN_End_Node. The callback function in the board when receiving something:

static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
{
  /* USER CODE BEGIN OnRxData_1 */
  if ((appData != NULL) || (params != NULL))
  {
    BSP_LED_On(LED_BLUE) ;

    UTIL_TIMER_Start(&RxLedTimer);

    static const char *slotStrings[] = { "1", "2", "C", "C Multicast", "B Ping-Slot", "B Multicast Ping-Slot" };

    APP_LOG(TS_OFF, VLEVEL_M, "\r\n###### ========== MCPS-Indication ==========\r\n");
    APP_LOG(TS_OFF, VLEVEL_H, "###### D/L FRAME:%04d | SLOT:%s | PORT:%d | DR:%d | RSSI:%d | SNR:%d\r\n",
            params->DownlinkCounter, slotStrings[params->RxSlot], appData->Port, params->Datarate, params->Rssi, params->Snr);
    switch (appData->Port)
    {
      case LORAWAN_SWITCH_CLASS_PORT:
        /*this port switches the class*/
        if (appData->BufferSize == 1)
        {
          switch (appData->Buffer[0])
          {
            case 0:
            {
              LmHandlerRequestClass(CLASS_A);
              break;
            }
            case 1:
            {
              LmHandlerRequestClass(CLASS_B);
              break;
            }
            case 2:
            {
              LmHandlerRequestClass(CLASS_C);
              break;
            }
            default:
              break;
          }
        }
        break;
      case LORAWAN_USER_APP_PORT:
        if (appData->BufferSize == 1)
        {
          AppLedStateOn = appData->Buffer[0] & 0x01;
          if (AppLedStateOn == RESET)
          {
            APP_LOG(TS_OFF, VLEVEL_H,   "LED OFF\r\n");
            BSP_LED_Off(LED_RED) ;
          }
          else
          {
            APP_LOG(TS_OFF, VLEVEL_H, "LED ON\r\n");
            BSP_LED_On(LED_RED) ;
          }
        }
        break;

      default:

        break;
    }
  }
  /* USER CODE END OnRxData_1 */
}

As far as I understand, in order to send a downlink packet from Chirpstack Network Server to this end node, I will have to make a downlink packet, which can be done in Tenant/Application/{the application you want to use}/{the device you want to control}. I have to form a packet in Queue tab and the packet is either in Hex, Base64, or JSON. However, I am not clear about how to form such packet to send to my end node. I also searched for some more reference on the document of Chirpstack but nothing hels (maybe I missed then or didnt fully understand). I also looked at the LoRaWAN frames tab but I did not get how to write one.

My question is: Is there any document/tutorial/instruction on how to form such packets and send?

Kind regards, Huy Nguyen.

There is no standard on the payload format. Most devices have their own binary payload format. E.g. if your device expects 01 to turn the light on and 00 to turn the light off (in HEX), then it is simply sending one or the other payload. You also have to check which port the device expects the payload on.

Hello,

Thank you very much for responding my post. I understand a bit more about that. I will try and update here.