Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 2   [ 17 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: LoraWAN Module Not Saving
PostPosted: Tue Aug 22, 2017 1:24 pm 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
Hi there,

I got a LoraWAN Radio Shield for Arduino and have been trying to connect to my gateway using OTAA but I'm some problems. The module doesn't appear to be saving it's config, so the EUI, address and keys are never saved despite the module reporting they saved OK. See serial output below:

Code:
sys get ver
RN2903 0.9.7 Jan 19 2017 11:41:51
sys factoryRESET
mac set deveui 0102030405060708
ok
mac get deveui
0004A30B001F417C
mac set devaddr 05060708
ok
mac get devaddr
00000000


I've tried with the examples provided on Cooking Hacks as well as my own custom code. Both exhibited the same issue.

Is there a pre-requisite step I should be performing that I've missed?

Thanks.


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Wed Aug 23, 2017 7:23 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi brandon,

Can you copy here the code that you are using?

Can you show us some photos of your hardware configuration to see if something is wrong?

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Sun Aug 27, 2017 4:34 pm 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
Hi there,

Code is as follows:

Code:
#include <arduinoUtils.h>

uint8_t _buffer[64];

void setup() {
 
  Serial.begin(57600);         //change to your module baudrate
  Utils.multiprotocolBegin(); // initialize multiprotocol shield
  Utils.disableMUX();         // disable sokets

  //******************************************************
  //sys get ver
  //******************************************************
  sendRequest("sys get ver");

  //******************************************************
  //sys factoryRESET
  //******************************************************
  sendRequest("sys factoryRESET");

  //******************************************************
  //mac set deveui
  //******************************************************
  sendRequest("mac set deveui 0102030405060708");

  //******************************************************
  //mac get deveui
  //******************************************************
  sendRequest("mac get deveui");
 
  //******************************************************
  //mac set devaddr
  //******************************************************
  sendRequest("mac set devaddr 05060708");

  //******************************************************
  //mac get devaddr
  //******************************************************
  sendRequest("mac get devaddr"); 
}

void sendRequest(String reqBuffer)
{
  Utils.setONSocket1();
  delay(1000);
  Utils.setMUXSocket1();
  Serial.println(reqBuffer);
  delay(1000);
  readBuffer();
  Utils.disableMUX();
  Serial.print((char *)_buffer);
}

void loop()
{
  if (readBuffer() > 0)
  {
    readResponse();
  }
  delay(5000);
}

void readResponse()
{
    Utils.setONSocket1();
    delay(100);
    Utils.setMUXSocket1();
    Serial.print((char *)_buffer);
    delay(500);
    readBuffer();
    Utils.disableMUX();
    Serial.print((char *)_buffer);
}

uint8_t readBuffer()
{
  uint16_t i = 0;
  uint16_t bytes = 0;
  memset(_buffer, 0x00, sizeof(_buffer));
  while (Serial.available())
  {
    if (i < (sizeof(_buffer) - 1))
    {
      _buffer[i++] = Serial.read();
      bytes++;
    }
    else
    {
      break;
    }
  }
  return bytes;
}


Hardware is configured like so:

Image


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Sun Aug 27, 2017 4:41 pm 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
A better scaled image of the hardware:

Image


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Mon Aug 28, 2017 7:24 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi brandon,

Have you got the same problem if you use the codes of our library without modification?

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Wed Aug 30, 2017 7:50 am 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
libelium-dev wrote:
Hi brandon,

Have you got the same problem if you use the codes of our library without modification?

Thanks.

Regards


I'm assuming so. The Cooking Hacks code didn't work either but the debugging capability in it is limited to binary success or failure.

That is why I wrote my own because I wanted to see exactly what the module was responding with and it appears to respond to "set" commands with an "ok" response but when submitting a "get" request for those values, they appear to be the factory default values.

I did also try adding a "save" command since the RN2903 documentation states it's necessary for persistence but it didn't help.


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Wed Aug 30, 2017 9:12 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi Brandom,

We have been trying your code and our code.

In your code, remember to send \r\n each time that you send a message to the module, if not, it won't work. But we can't give you support with personal code, we recommend you to use our libraries and codes. Also, remember to wait more time once you reset the module.

With our codes, sending the data to a LoRaWAN server, you can see that the module send the address and the EUI correctly. You can't print in the code the address because with the las firmware versions, it is a private variable and the module always print 0000.

Please use the module with a LoRaWAN server and you will see that it works perfectly.

Regards.


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Sun Sep 03, 2017 12:39 pm 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
Hi there,

In my code the commands are sent using println which includes \r\n by default. However I tried adding \r\n to the the commands but the result was the same. The "ok" responses would seem to indicate they are being sent correctly. In terms of delays, I've tried with delays of up to 5 seconds and it made no difference to the result. I can't imagine more than 5 seconds would be required?

I should have shown a complete OTAA attempt; the response back is "keys_not_init". Below is the code and output:

Code:
#include <arduinoUtils.h>

uint8_t _buffer[64];

void setup() {
 
  Serial.begin(57600);         //change to your module baudrate
  Utils.multiprotocolBegin(); // initialize multiprotocol shield
  Utils.disableMUX();         // disable sokets

  //******************************************************
  //sys reset
  //******************************************************
  sendRequest("sys reset");

  //******************************************************
  //sys factoryRESET
  //******************************************************
  sendRequest("sys factoryRESET");

  //******************************************************
  //mac set deveui
  //******************************************************
  sendRequest("mac set deveui 0102030405060708");

  //******************************************************
  //mac set appeui
  //******************************************************
  sendRequest("mac set appeui FBBB729A5F54DA72");

  //******************************************************
  //mac set appkey
  //******************************************************
  sendRequest("mac set appkey B42D9B36D6917576B26DF782A7BBB8F4");
 
  //******************************************************
  //mac set devaddr
  //******************************************************
  sendRequest("mac set devaddr 00000000");

  //******************************************************
  //mac set nwkskey
  //******************************************************
  sendRequest("mac set nwkskey 00000000000000000000000000000000");

  //******************************************************
  //mac set appskey
  //******************************************************
  sendRequest("mac set appskey 00000000000000000000000000000000");

  //******************************************************
  //mac save
  //******************************************************
  //sendRequest("mac save");

  //******************************************************
  //mac join otaa
  //******************************************************
  sendRequest("mac join otaa");
}

void sendRequest(String reqBuffer)
{
  Utils.setONSocket1();
  delay(1000);
  Utils.setMUXSocket1();
  Serial.println(reqBuffer);
  delay(5000);
  readBuffer();
  Utils.disableMUX();
  Serial.print((char *)_buffer);
}

void loop()
{
  if (readBuffer() > 0)
  {
    readResponse();
  }
  delay(5000);
}

void readResponse()
{
    Utils.setONSocket1();
    delay(100);
    Utils.setMUXSocket1();
    Serial.print((char *)_buffer);
    delay(500);
    readBuffer();
    Utils.disableMUX();
    Serial.print((char *)_buffer);
}

uint8_t readBuffer()
{
  uint16_t i = 0;
  uint16_t bytes = 0;
  memset(_buffer, 0x00, sizeof(_buffer));
  while (Serial.available())
  {
    if (i < (sizeof(_buffer) - 1))
    {
      _buffer[i++] = Serial.read();
      bytes++;
    }
    else
    {
      break;
    }
  }
  return bytes;
}



Code:
sys reset
RN2903 0.9.7 Jan 19 2017 11:41:51
sys factoryRESET
RN2903 0.9.7 Jan 19 2017 11:41:51
mac set deveui 0102030405060708
ok
mac set appeui FBBB729A5F54DA72
ok
mac set appkey B42D9B36D6917576B26DF782A7BBB8F4
ok
mac set devaddr 00000000
ok
mac set nwkskey 00000000000000000000000000000000
ok
mac set appskey 00000000000000000000000000000000
ok
mac join otaa
keys_not_init


This follows the instructions set out here: http://www.microchip.com/forums/m945840.aspx

Documentation for the RN2903 (http://ww1.microchip.com/downloads/en/D ... 01811A.pdf) states:

Quote:
keys_not_init – if the keys corresponding to the Join mode (otaa or abp) were not configured


and

Quote:
Before joining the network, the specific parameters for each activation type should be configured (for over the air activation: device EUI, application EUI, application key; for activation by personalization: device address, network session key, application session key).


In the code you can see I have set the devEUI, appEUI and appKey, yet the module responds saying it's not configured.

I believe this is exactly what jmueller in his post is experiencing.


As mentioned before I have tried with the code provided by Cooking Hacks but it has it's own issues. Below is the output from running "LoRaWAN_08_join_otaa_send_unconfirmed":

Code:
[UART] cmd:sys get ver

[UART] ans1:RN2483
[UART] ans2:RN2903
[UART] ans3:invalid_param
sys get ver
[UART] found:invalid_param
[UART] cmd:mac set deveui 0102030405060708

[UART] ans1:ok
[UART] ans2:invalid_param
mac set deveui 0102030405060708
[UART] found:invalid_param
[UART] cmd:mac set appeui 1112131415161718

[UART] ans1:ok
[UART] ans2:invalid_param
mac set appeui 1112131415161718
[UART] found:invalid_param
[UART] cmd:mac set appkey 01020304050607080910111213141516

[UART] ans1:ok
[UART] ans2:invalid_param
mac set appkey 01020304050607080910111213141516
[UART] found:invalid_param
[UART] cmd:mac save

[UART] ans1:ok
[UART] ans2:invalid_param
mac save
[UART] found:invalid_param
[UART] cmd:mac get deveui

[UART] ans1:

[UART] ans2:invalid_param
mac get deveui
[UART] found:invalid_param
[UART] cmd:mac get appeui

[UART] ans1:

[UART] ans2:invalid_param
mac get appeui
[UART] found:

[UART] cmd:sys get ver

[UART] ans1:RN2483
[UART] ans2:RN2903
[UART] ans3:invalid_param
sys get ver
[UART] found:invalid_param
[UART] cmd:mac join otaa

[UART] ans1:ok
[UART] ans2:invalid_param
[UART] ans3:keys_not_init
mac join otaa
[UART] found:invalid_param


As you can see it is the same result jmueller gets when he runs it.

It's worth noting that compiling the sketch does present this warning:

Code:
Sketch uses 14866 bytes (46%) of program storage space. Maximum is 32256 bytes.
Global variables use 1594 bytes (77%) of dynamic memory, leaving 454 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.


I believe the result obtained above was due to the lack of available memory because when I modify the code to reduce the memory footprint I was able to get more of the commands to execute successfully. In the end it was performing all the commands but as with my code, the join otaa command returned "keys_not_init".

The Cooking Hacks code does not work out of the box with an UNO. However that is not my problem, my problem is it appears the LoRaWAN module does not appear to be saving the values which means it can never connect to a LoRa network.

Please can you assist in identifying why? If it is working for you, can you provide details of your module (hardware rev, firmware version, etc)?

Thanks,
Brandon


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Mon Sep 04, 2017 9:07 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi brandon,

This is the version of our module:

Quote:
RN2903 0.9.5 Sep 02 2015 17:19:55


Other colleague shave used your version without problems.

We can't give you support to your personal code, but if we use the code of our libraries, without modifications. Here you have got the Serial output:

libelium_files/lorawan_900_serial.png

And here you have got how the data is received in the Gateway:

libelium_files/loriot_ouput.png

Can you tell us which LoRaWAN gateway are you using?

How many modules have you got? Have you got the same problem in all the modules?

Thanks.

Regards.


Top
 Profile  
 
 Post subject: Re: LoraWAN Module Not Saving
PostPosted: Mon Sep 04, 2017 11:52 am 

Joined: Tue Aug 22, 2017 12:59 pm
Posts: 9
Hi there,

As mentioned, the libraries provided by Cooking Hacks don't seem to work for the Uno. Here is the serial output (DEBUG=2) for "LoRaWAN_09_join_otaa_send_confirmed":

Image

That is with unmodified code. As you can see every result is "invalid param". I believe this is due to the libraries requiring too much memory.

I'm using a MultiTech MultiConnect Conduit for the gateway. I only have this one module, it is a proof of concept.

Can you please share the code you're using on your Uno (examples including all libraries)? Also, what version of Arduino AVR Boards are you using?

Thanks,
Brandon


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 17 posts ]
Go to page 1, 2  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.