Handle download / working example issues

Dear friends,

maybe I am a total noob, but I don;t really understand the examples, especially the download one. I was hoping that if add a void “DownLinkDataHandle(McpsIndication_t *mcpsIndication)” I will be able to handle, parse and process messages to init something like change cycle_time or change status of GPIO.
I am using TTN. I am able to join, but no downloads are processed.

May I kindly ask someone to help and show me the working example?
Here is my try, which doesn’t seems to work. https://pastebin.com/5YxNEnNP

My second question:
Can some explain me the standard loop void? Especially switch( DeviceState ). See if the cube-cell boot up then it’s trying to join lorawan - “Joining” and here I can see “DEVICE_STATE_SLEEP” case handled several times, which include loraWan.sleep. How it can handle the OTAA process if the lorawan is in sleep-mode?

Sorry for stupid questions, but I will really appreciate your help.
Or may I asked to share with us working example which support low-power and download message handling.

Thanks a lot !!!

i am using this it prints the received data to console:

void DownLinkDataHandle(McpsIndication_t *mcpsIndication)
  Serial.printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication->RxSlot?"RXWIN2":"RXWIN1",mcpsIndication->BufferSize,mcpsIndication->Port);
  Serial.print("+REV DATA:");
  for(uint8_t i=0;i<mcpsIndication->BufferSize;i++) {
  for(uint8_t i=0;i<mcpsIndication->BufferSize;i++) {
    if (mcpsIndication->Buffer[i] == 220) { // DC for APP_TX_DUTYCYCLE; 0D BB A0  for 900000 (15min); 04 93 E0 for 300000 (5min)
      APP_TX_DUTYCYCLE = mcpsIndication->Buffer[i++]<<32|mcpsIndication->Buffer[i++]<<16|mcpsIndication->Buffer[i++]<<8|mcpsIndication->Buffer[i++];
      Serial.print("  new DutyCycle received: ");

Hi, such a void is defined as part of LoRaWan_APP.cpp, to make the void DownLinkDataHandle work in my sketch I had to disable in LoRaWan_APP.cpp
As soon as I remove it from library, then the void in sketch start to work.

What I do not really understand is, why it was working for you without necessity to modify library LoRaWan_APP.cpp? I am using Heltec CubeSell version 0.0.4

Please try it with the github version
The 0.0.4 is outdated