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 1   [ 7 posts ]
Author Message
 Post subject: Doubt regarding payload of LoraWAN
PostPosted: Fri Nov 24, 2017 3:34 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi,
Just read the documentation of RN2483.To send the data I need to convert the message to hex and send it.Is this right,iam trying to send "hello world,this is lorawan module over the network"and its equivalent value in hexadecimal value

68 65 6c 6c 6f 20 77 6f 72 6c 64 2c 74 68 69 73 20 69 73 20 6c 6f 72 61 77 61 6e 20 6d 6f 64 75 6c 65 20 6f 76 65 72 20 74 68 65 20 6e 65 74 77 6f 72 6b
(from http://www.rapidtables.com/convert/numb ... to-hex.htm

Iam able to sucessfully configure the module but getting send confirmed/unconfirmed packet=2 or 5 sometimes OK


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Mon Nov 27, 2017 8:40 am 

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

Can you copy us here your code?

Have you tried the examples of the library? Have you got the same problem?

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Mon Nov 27, 2017 9:49 am 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
#include "arduPiLoRaWAN.h"

// socket to use
//////////////////////////////////////////////
uint8_t sock = SOCKET0;
//////////////////////////////////////////////

// Device parameters for Back-End registration
////////////////////////////////////////////////////////////
char DEVICE_EUI[] = "0102030405060708";
char DEVICE_ADDR[] = "05060708";
char NWK_SESSION_KEY[] = "01020304050607080910111213141516";
char APP_SESSION_KEY[] = "000102030405060708090A0B0C0D0E0F";
////////////////////////////////////////////////////////////

// Define port to use in Back-End: from 1 to 223
uint8_t PORT = 3;

// Define data payload to send (maximum is up to data rate)
char data[] = "0102030405060708090A0B0C0D0E0F";
//I want to change the payload data to something else


// variable
uint8_t error;

void setup()
{
printf("LoRaWAN example - Send Unconfirmed packets (no ACK)\n");

printf("------------------------------------\n");
printf("Module configuration\n");
printf("------------------------------------\n\n");


//////////////////////////////////////////////
// 1. Switch on
//////////////////////////////////////////////

error = LoRaWAN.ON(sock);

// Check status
if( error == 0 )
{
printf("1. Switch ON OK\n");
}
else
{
printf("1. Switch ON error = %d\n", error);
}


//////////////////////////////////////////////
// 2. Set Device EUI
//////////////////////////////////////////////

error = LoRaWAN.setDeviceEUI(DEVICE_EUI);

// Check status
if( error == 0 )
{
printf("2. Device EUI set OK\n");
}
else
{
printf("2. Device EUI set error = %d\n", error);
}


//////////////////////////////////////////////
// 3. Set Device Address
//////////////////////////////////////////////

error = LoRaWAN.setDeviceAddr(DEVICE_ADDR);

// Check status
if( error == 0 )
{
printf("3. Device address set OK\n");
}
else
{
printf("3. Device address set error = %d\n", error);
}


//////////////////////////////////////////////
// 4. Set Network Session Key
//////////////////////////////////////////////

error = LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);

// Check status
if( error == 0 )
{
printf("4. Network Session Key set OK\n");
}
else
{
printf("4. Network Session Key set error = %d\n",error);
}


//////////////////////////////////////////////
// 5. Set Application Session Key
//////////////////////////////////////////////

error = LoRaWAN.setAppSessionKey(APP_SESSION_KEY);

// Check status
if( error == 0 )
{
printf("5. Application Session Key set OK\n");
}
else
{
printf("5. Application Session Key set error = %d\n", error);
}


//////////////////////////////////////////////
// 6. Save configuration
//////////////////////////////////////////////

error = LoRaWAN.saveConfig();

// Check status
if( error == 0 )
{
printf("6. Save configuration OK\n");
}
else
{
printf("6. Save configuration error = %d\n", error);
}


printf("\n------------------------------------\n");
printf("Module configured\n");
printf("------------------------------------\n\n");

LoRaWAN.getDeviceEUI();
printf("Device EUI: %s\n", LoRaWAN._devEUI);

LoRaWAN.getDeviceAddr();
printf("Device Address: %s\n\n", LoRaWAN._devAddr);
}



void loop()
{

//////////////////////////////////////////////
// 1. Switch on
//////////////////////////////////////////////

error = LoRaWAN.ON(sock);


// Check status
if( error == 0 )
{
printf("1. Switch ON OK\n");
}
else
{
printf("1. Switch ON error = %d\n", error);
}


//////////////////////////////////////////////
// 2. Join network
//////////////////////////////////////////////

error = LoRaWAN.joinABP();

// Check status
if( error == 0 )
{
printf("2. Join network OK\n");

//////////////////////////////////////////////
// 3. Send unconfirmed packet
//////////////////////////////////////////////

error = LoRaWAN.sendUnconfirmed(PORT, data);

// Error messages:
/*
* '6' : Module hasn't joined a network
* '5' : Sending error
* '4' : Error with data length
* '2' : Module didn't response
* '1' : Module communication error
*/
// Check status
if( error == 0 )
{
printf("3. Send Unconfirmed packet OK\n");
if (LoRaWAN._dataReceived == true)
{
printf(" There's data on port number %d.\r\n", LoRaWAN._port);
printf(" Data: %s\n", LoRaWAN._data);
}
}
else
{
printf("3. Send Unconfirmed packet error = %d\n", error);
}
}
else
{
printf("2. Join network error = %d\n",error);
}


//////////////////////////////////////////////
// 4. Clean channels
//////////////////////////////////////////////
error = LoRaWAN.reset();

// Reset channels
if( error == 0 )
{
printf("4. Clean channels OK\n");
}
else
{
printf("4. Clean channels error = %d\n", error);
}


//////////////////////////////////////////////
// 5. Switch off
//////////////////////////////////////////////
error = LoRaWAN.OFF(sock);

// Check status
if( error == 0 )
{
printf("5. Switch OFF OK\n");
}
else
{
printf("5. Switch OFF error = %d\n",error);
}


printf("\n");
delay(5000);
}

//////////////////////////////////////////////
// Main loop setup() and loop() declarations
//////////////////////////////////////////////

int main (){
setup();
while(1){
loop();
}
return (0);
}


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Mon Nov 27, 2017 11:06 am 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi,

My aim is to use the same code to send the data to remote gateway.Please let me know how to do this, I have the info about the location and EUI of the gateway.


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Tue Nov 28, 2017 8:23 am 

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

Before you modify the code with your message:

Have you tried the examples of the library? Have you got the same problem?

Thanks.


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Tue Nov 28, 2017 10:04 am 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi dev,
Tried using example code,but I am not sure how do we configure in the code to send the data to remote gateway.I have info like gateway EUI and its location.Please let me know how to register the gateway in the above code.I am able to see packet sent OK for the example but after sometime I see packet sent error=2.Iam not able to figure out where is this data sent to or is it simple broadcast.

My aim is to send this data to a particular gateway.


Top
 Profile  
 
 Post subject: Re: Doubt regarding payload of LoraWAN
PostPosted: Wed Nov 29, 2017 8:31 am 

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

Your LoRaWAN back-end has to give you all this data:

Code:
char DEVICE_EUI[]
char DEVICE_ADDR[]
char NWK_SESSION_KEY[]
char APP_SESSION_KEY[]


It is the configuration needed to send information from the module to the back-end.

For example:
Image

Image

https://www.cooking-hacks.com/media/coo ... _small.png
Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 7 posts ]


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.