TX timeout when using LoraSender Example

Hello,

I am trying the basic LoraSender example on my HTCC_AB01 and it’s always timing out of TX.
Any ideas what could be causing this?
These are the settings:

#define RF_FREQUENCY                                915000000 // Hz
#define TX_OUTPUT_POWER                             20        // dBm
#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false
#define TX_TIMEOUT_VALUE                            3000

And here is the setup call:

void setup() {
  boardInitMcu( );
  Serial.begin(115200);

  txNumber = 0;
  rssi = 0;
  RadioEvents.TxDone = OnTxDone;
  RadioEvents.TxTimeout = OnTxTimeout;

  Radio.Init( &RadioEvents );
  Radio.SetChannel( RF_FREQUENCY );
  Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                     LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                     LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                     true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE );
}

Thanks in advance for the help.
Amir.

hi,

Our point-to-point program has no error correction mechanism . Once a node loses a packet, both nodes may become accepting states. At this time you need to physically reset.

You can add a timeout detection mechanism: when your node does not receive data for a long time, the system will automatically change the node to the sending state.

Hi Jason,

I am not using this in point-to-point (I mean the packet is not send to a specific device, it’s just sent out)

I tried the ping-pong and that does not timeout. The problem I think is a bug in the LorRaSender example from the library.

The TX timeout is set to 3000ms but delay in the loop is only 1000ms. I would think this would cause a timeout if for example the LoRa driver is still in TX state.

    Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                                   LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                                   LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                                   true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 
void loop()
{
	delay(1000);
	txNumber += 0.01;
	sprintf(txpacket,"%s","Hello world number");  //start a package
//	sprintf(txpacket+strlen(txpacket),"%d",txNumber); //add to the end of package
	
	DoubleToString(txpacket,txNumber,3);	   //add to the end of package
	
	turnOnRGB(COLOR_SEND,0); //change rgb color

	Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));

	Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out	
}

The other issue with the example is that it doesn’t check for TxDone before attempting to send another packet. It is also missing a call to Radio.IrqProcess( ); which is important, otherwise it can’t check IRQ_RX_DONE which will stop the TX timer if it is still running.

I modified the LoRaSender example based off the working pingpong. The important part is that it waits for TxDone before sending another message and in the loop it continuously checks for interrupts to make sure timer is reset.

See below:

/* Heltec Automation send communication test example

   Function:
   1. Send data from a CubeCell device over hardware
   2. After TX is done, wait for 10 seconds before sending data again
   this project also realess in GitHub:
   https://github.com/HelTecAutomation/ASR650x-Arduino
 * */

#include "LoRaWan_APP.h"
#include "Arduino.h"

/*
   set LoraWan_RGB to 1,the RGB active in loraWan
   RGB red means sending;
   RGB green means received done;
*/
#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY                                915000000 // Hz

#define TX_OUTPUT_POWER                             14        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
//  1: 250 kHz,
//  2: 500 kHz,
//  3: Reserved]
#define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
//  2: 4/6,
//  3: 4/7,
//  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false


#define TX_TIMEOUT_VALUE                            3000
#define BUFFER_SIZE                                 30 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;
void OnTxDone( void );
void OnTxTimeout( void );

bool txDone = true;

double txNumber;

int16_t rssi, rxSize;
void  DoubleToString( char *str, double double_num, unsigned int len);

void setup() {
  boardInitMcu( );
  Serial.begin(115200);

  txNumber = 0;
  rssi = 0;


  RadioEvents.TxDone = OnTxDone;
  RadioEvents.TxTimeout = OnTxTimeout;

  Radio.Init( &RadioEvents );
  Radio.SetChannel( RF_FREQUENCY );
  Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                     LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                     LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                     true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE );
}

void loop()
{
  if (txDone) {
    txDone = false;
    delay(10000);
    txNumber += 0.01;
    sprintf(txpacket, "%s", "Hello world number"); //start a package
    DoubleToString(txpacket, txNumber, 3);	 //add to the end of package

    turnOnRGB(COLOR_SEND, 0); //change rgb color

    Serial.printf("\r\nsending packet \"%s\" , length %d\r\n", txpacket, strlen(txpacket));

    Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out
  }
  Radio.IrqProcess( );
}

/**
    @brief  Double To String
    @param  str: Array or pointer for storing strings
    @param  double_num: Number to be converted
    @param  len: Fractional length to keep
    @retval None
*/
void  DoubleToString( char *str, double double_num, unsigned int len) {
  double fractpart, intpart;
  fractpart = modf(double_num, &intpart);
  fractpart = fractpart * (pow(10, len));
  sprintf(str + strlen(str), "%d", (int)(intpart)); //Integer part
  sprintf(str + strlen(str), ".%d", (int)(fractpart)); //Decimal part
}

void OnTxDone( void )
{
  Serial.print("TX done......");
  turnOnRGB(0, 0);
  txDone = true;
}

void OnTxTimeout( void )
{
  Radio.Sleep( );
  Serial.print("TX Timeout......");
}

Hi Amir,

I have the same issue and fix it in the same way.

And they correct it serval days ago.

Yeah. Best is to rely on either the factory test example or the pingpong. These have been tested enough to work “out of the box”.