Sending data more than once not working

Hello,
I am trying to send data a couple of times to The Things Stack.
It seems that the data is only sending on the first request and I believe that I may have the incorrect idea of how data should be sent.

I should also mention I am on region AS923 Japan. I just saw: AS923 on TTNv3 keeps exchanging LinkADRReq - LinkADRAns NACK and doesn't use one channel · Issue #686 · mcci-catena/arduino-lmic · GitHub and wonder if this has anything to do with my data not being recieved. I am not sure because I am able to make a connection.

Here is my code:

// Send ALL THE DATA!!!!
  Serial.println(data_to_send.size());
  LoRaWANSetup();
  do
  {
    LoRaWAN_DataType& temp = *data_to_send.back(); // Reference Last item in vector
    Serial.print("About to send: ");
    Serial.println(temp.getPrefix());
    LoRaWANSetData(temp.getDataToSend(), sizeof(temp.getDataToSend()) + 1, temp.getDataPort());
    do
    {
      LoRaWANLoop();
    } while (!LoRaWAN_SendComplete);
    data_to_send.pop_back(); // Remove Last item in vector
  } while (data_to_send.size());

I know this is a lot specific to my stuff, but basically this loops through a vector and sends the data (temp.getDataToSend() in byte format). When the data is sent, it sets LoRaWAN_SendComplete to TRUE.

that happens here:

case EV_TXCOMPLETE:
        Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
        if (LMIC.txrxFlags & TXRX_ACK)
            Serial.println(F("Received ack"));
        if (LMIC.dataLen)
        {
            Serial.print(F("Received "));
            Serial.print(LMIC.dataLen);
            Serial.println(F(" bytes of payload"));
        }
        // Schedule next transmission
        os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
        LoRaWAN_SendComplete = true;
        break;

Then we POP the last element out of the vector and if there are remaining elements, we do it all over gain.

My question is if I am doing this correctly? Or Am I totally off base with how I am going about this?

This results in me seeing:

EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)
EV_TXSTART
EV_TXCOMPLETE (includes waiting for RX windows)

and never getting any data :cry:
Thank you very much for any assistance!
-Kevin Cantrell

What’s the value of TX_INTERVAL? How many bytes are you sending? And you need to be calling os_runLoopOnce() inside your busy loop, and you need to check whether the LMIC is busy before you try to send… you should find the thread on the geiger counter on this site and look at what we had to do to make that work.

The TX_INTERVAL is currently set to 60, however when I showed you the example, it was 120. I thought upping it might help, it didn’t. The os_runLoopOnce() is currently the only function running. I will have a look at the Geiger Counter thread. If that doesn’t help, I will try to post full code if you don’t mind!

Thanks a lot!
-Kevin

1 Like