Cubecell LoRaWan with LoRa passthrough ability

Hi, Im looking to create a LoRaWan sensor for the helium network that can break from its LoRaWan functionality to execute LoRa functions. The purpose of this is to create a LoRaWan sensor that can communicate with a private LoRa network to report the status of certain devices on the private LoRa network. I have tried starting with a LoRaWan template arduino code and added LoRa code to a function that sets the payload of the LoRaWan packet, however it seems the LoRa setup/parameters are interfering with the LoRaWan functionality. The LoRa portion works properly and the LoRaWan join request/accept appears to still be working but when it tries to send the uplink I can see on a spectrum analyzer that nothing was sent. I am wondering what is the proper way to implement this ability.

The code below has the LoRa code in the setup to execute only once and before LoRaWan initialization for troubleshooting purposes yet it still interferes with LoRaWan functionality.

#include “LoRaWan_APP.h”
#include “Arduino.h”

#define RX_TIMEOUT_VALUE 1000

uint8_t devEui[] = {xxx};
uint8_t appEui[] = {xxx};
uint8_t appKey[] = {xxx};

uint16_t userChannelsMask[6]={ 0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000 };
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;
DeviceClass_t loraWanClass = LORAWAN_CLASS;
uint32_t appTxDutyCycle = 15000;
bool overTheAirActivation = LORAWAN_NETMODE;
bool loraWanAdr = LORAWAN_ADR;
bool keepNet = LORAWAN_NET_RESERVE;
bool isTxConfirmed = LORAWAN_UPLINKMODE;
uint8_t appPort = 2;
uint8_t confirmedNbTrials = 4;

uint8_t uintPack[50] = {1};
int txSize;
bool rx = false;

//LoRa rx interrupt
void onRxDone(uint8_t *payload, uint16_t size, int16_t xrssi, int8_t snr){
memcpy(uintPack, payload, size );
Serial.println(“heard something”);
Serial.println(uintPack[0]);
txSize = size;
rx = true;
}

//LoRaWan set payload
static void prepareTxFrame( uint8_t port ){
appDataSize = 2;
appData[0] = uintPack[0];
appData[1] = uintPack[1];
rx = false;
delay(3000);
}

void setup() {
Serial.begin(115200);
//LORA PORTION BEGIN
static RadioEvents_t RadioEvents;
Radio.Init(&RadioEvents);
RadioEvents.RxDone = onRxDone;
Radio.SetChannel(9045e5);
Radio.SetTxConfig(MODEM_LORA, 10, 0, 0, 10, 1, 8, false, true, 0, 0, false, 3000 );
Radio.SetRxConfig(MODEM_LORA, 0, 10, 1, 0, 8, 0, false, 0, true, 0, 0, false, true);
Radio.SetSyncWord(0x34);
Serial.println(“About to Send”);
delay(2000);
Radio.Send(uintPack, 1);
delay(500);
Serial.println(“Packet Sent”);
Radio.Rx(0);
int x = 0;
while(!rx){ //wait for LoRa Packet
Serial.println(++x);
delay(1000);
}
Serial.println(“Payload Ready”);
//LORA PORTION END

#if(AT_SUPPORT)
enableAt();
#endif
deviceState = DEVICE_STATE_INIT;
LoRaWAN.ifskipjoin();
}

void loop()
{
switch( deviceState )
{
case DEVICE_STATE_INIT:
{
#if(AT_SUPPORT)
getDevParam();
#endif
printDevParam();
LoRaWAN.init(loraWanClass,loraWanRegion);
deviceState = DEVICE_STATE_JOIN;
break;
}
case DEVICE_STATE_JOIN:
{
LoRaWAN.join();
break;
}
case DEVICE_STATE_SEND:
{
prepareTxFrame( appPort );
LoRaWAN.send();
deviceState = DEVICE_STATE_CYCLE;
break;
}
case DEVICE_STATE_CYCLE:
{
txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );
LoRaWAN.cycle(txDutyCycleTime);
deviceState = DEVICE_STATE_SLEEP;
break;
}
case DEVICE_STATE_SLEEP:
{
LoRaWAN.sleep();
break;
}
default:
{
deviceState = DEVICE_STATE_INIT;
break;
}
}
}

Nobody has any knowledge of this??

This isn’t trivial as you need to put the radio back to the exact state that the LoRaWAN component left it in.

But why it doesn’t work when you do the LoRa send first before init’ing the LoRaWAN would need some picking through - there may be a register set in LoRa mode that LoRaWAN isn’t expecting - it’s using the reset default value.

You can add code to dump register setups for both portions and see if there is anything set in LoRa that’s not set in LoRaWAN.

To make it able to switch, you’ll have to get the base LoRaWAN radio configuration so you can restore that each time - some things like frequency are set on each uplink - not sure if the SF is written to each time.