Configure LoRaWan without AT commands?

你好!

Is there any posibility to directly configure the different address directly from the code?

I try the Lorawan_multicast example code but it doesn’t works

  • MulticastParams_t mult1;
    
  • uint8_t mulNwkSKey[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
    
  • uint8_t mulAppSKey[]={0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11};
    
  • uint32_t multicastAddress=0x22222222;
    
  • void setup() {
    
  • 	BoardInitMcu();
    
  • 	Serial.begin(115200);
    
  • #if(AT_SUPPORT)
    
  • 	Enable_AT();
    
  • #endif
    
  • 	DeviceState = DEVICE_STATE_INIT;
    
  • 	LoRaWAN.Ifskipjoin();
    
  • 	mult1.Address=multicastAddress;
    
  • 	for(int i=0;i<16;i++)
    
  • 	{
    
  • 		mult1.NwkSKey[i]=mulNwkSKey[i];
    
  • 		mult1.AppSKey[i]=mulAppSKey[i];
    
  • 	}
    
  • 	LoRaMacMulticastChannelLink(&mult1);
    
  • }
    

thanks!

Just add the following to the start of your code

const char myDevEui[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char myAppEui[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char myAppKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

extern uint8_t DevEui[];
extern uint8_t AppEui[];
extern uint8_t AppKey[];

and this to your setup routine:

void setup()
{
  memcpy(DevEui, myDevEui, sizeof(myDevEui));
  memcpy(AppEui, myAppEui, sizeof(myAppEui));
  memcpy(AppKey, myAppKey, sizeof(myAppKey));

thanks! 谢谢!

I’ll try it.

cheers! 再见

I tried it for ABP parammeters

const char myDevAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char myNwkSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char myAppSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void setup() {
BoardInitMcu();
Serial.begin(115200);
#if(AT_SUPPORT)
Enable_AT();
#endif
DeviceState = DEVICE_STATE_INIT;
LoRaWAN.Ifskipjoin();
Serial.println( “[stup] INIT”);
#if(AT_SUPPORT)
getDevParam();
#endif
Serial.println( “config device params”);
memcpy(DevAddr, myDevAddr, sizeof(myDevAddr));
memcpy(NwkSKey, myNwkSKey, sizeof(myNwkSKey));
memcpy(AppSKey, myAppSKey, sizeof(myAppSKey));

but there is an error compiling

exit status 1
‘DevAddr’ was not declared in this scope

I check the commands in the “AT Command user manual” and the commands are writen as in the manual.

never tried it with ABP.
Will have a look when i am back at office this evening

ok thanks I’ll wait news

put this at the start of your code

const uint32_t myDevAddr = 0;
const char myNwkSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char myAppSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    
extern uint8_t NwkSKey[];
extern uint8_t AppSKey[];
extern uint32_t DevAddr;

and this in the setup routine

DevAddr = myDevAddr;
memcpy(NwkSKey, myNwkSKey, sizeof(myNwkSKey));
memcpy(AppSKey, myAppSKey, sizeof(myAppSKey));

credits to this go to @bwooce

Hi!

The myDevAddr give some problems during compilation but defining as const char works ok!

this is:

> const char myDevAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
> const char myNwkSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
> const char myAppSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
>     
> extern uint8_t NwkSKey[];
> extern uint8_t AppSKey[];
> extern uint32_t DevAddr[];
> 
> void setup() {
> 
>     memcpy(DevAddr, myDevAddr, sizeof(myDevAddr));
>     memcpy(NwkSKey, myNwkSKey, sizeof(myNwkSKey));
>     memcpy(AppSKey, myAppSKey, sizeof(myAppSKey));

And this is the result via Serial port

+NwkSKey=00000000000000000000000000000000(For ABP Mode)
+AppSKey=00000000000000000000000000000000(For ABP Mode)
+DevAddr=00000000(For ABP Mode)

Thanks!

Well it is a little problem.

You must to invert the position of values of the device address to be in the correct position

//const char myDevAddr[] = {0xWW, 0xRR, 0x1C, 0x5E };//this values are paste as is in the TTN Device webpage
const char myDevAddr[] = { 0x5E, 0x1C, 0xRR, 0xWW }; //invert position from original TTN Device Address
const char myNwkSKey[] = { 0x04, 0x12, 0x82, 0x09, 0xC6, 0x80, 0xCC, 0xDD, 0xB1, 0xC7, 0xC0, 0xYY, 0xYY, 0xYY, 0xYY, 0xYY };
const char myAppSKey[] = { 0xD4, 0x0E, 0xE5, 0x82, 0x8C, 0xE3, 0xDC, 0x3C, 0xB7, 0x0C, 0x0F, 0xZZ, 0xZZ, 0xZZ, 0xZZ, 0xZZ };
    
extern uint8_t NwkSKey[];
extern uint8_t AppSKey[];
extern uint8_t DevAddr[];

or considering your code may be to convert the four values into an unsigned long doing something like this:

byte conversor[4] = {0xWW, 0xRR, 0x1C, 0x5E };

DevAddr = (*(unsigned long *)conversor);

I do not test it but may be it works.

Trying to use OTAA - i get this error - just need similar define’s at the start to ABP above, just not sure what to add

‘DevEui’ was not declared in this scope
‘AppEui’ was not declared in this scope
error: ‘AppKey’ was not declared in this scope

cheers
Paul

take a look here:

Great, thanks, works well and much better than using AT commands or editing the commissioning.h file

This should be changed in the example sketch

cheers
Paul

if you only have a few devices hardcoding may be easier but if you have hundreds of devices the AT commands are easier. I only compile one firmware for all and programm keys with the CubeCell Configurator.
Have a look here:

Any way you could incorporate the solution found here https://github.com/HelTecAutomation/ASR650x-Arduino/issues/19 to enable AU915 and TTN usage into your Configurator?

This is included in v2.0.9 firmware.
Selecting AU915 frequency band will select subband 2

1 Like