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   [ 5 posts ]
Author Message
 Post subject: Receiving Ack after packet is sent for authentication
PostPosted: Mon Jan 22, 2018 12:13 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi,
I am sending packets in P2P fashion between Raspberry LoRa(sx1272) nodes.I used the same code from cooking hacks documentation.

(https://www.cooking-hacks.com/documenta ... l-galileo/)

I want to receive acknowledgement for first packet sent and then I want to send second packet.What kind of acknowledgement is received and how to verify the acknowledgement is received so as to send the next packet?


Last edited by karthik22 on Mon Jan 22, 2018 2:59 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Receiving Ack after packet is sent
PostPosted: Mon Jan 22, 2018 12:16 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
/*Transmission code by cooking hacks*/

#include "SX1272.h"

int e;

char message1 [] = "Packet 1, wanting to see if received packet is the same as sent packet";
char message2 [] = "Packet 2, broadcast test";

void setup()
{
// Print a start message
printf("SX1272 module and Raspberry Pi: send packets without ACK\n");

// Power ON the module
e = sx1272.ON();
printf("Setting power ON: state %d\n", e);

// Set transmission mode
e = sx1272.setMode(4);
printf("Setting Mode: state %d\n", e);

// Set header
e = sx1272.setHeaderON();
printf("Setting Header ON: state %d\n", e);

// Select frequency channel
e = sx1272.setChannel(CH_10_868);
printf("Setting Channel: state %d\n", e);

// Set CRC
e = sx1272.setCRC_ON();
printf("Setting CRC ON: state %d\n", e);

// Select output power (Max, High or Low)
e = sx1272.setPower('H');
printf("Setting Power: state %d\n", e);

// Set the node address
e = sx1272.setNodeAddress(3);
printf("Setting Node address: state %d\n", e);

// Print a success message
printf("SX1272 successfully configured\n\n");
delay(1000);
}

void loop(void)
{
// Send message1 and print the result
e = sx1272.sendPacketTimeout(8, message1);
printf("Packet sent, state %d\n",e);

delay(4000);

// Send message2 broadcast and print the result
e = sx1272.sendPacketTimeout(0, message2);
printf("Packet sent, state %d\n",e);

delay(4000);
}

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


Top
 Profile  
 
 Post subject: Re: Receiving Ack after packet is sent
PostPosted: Mon Jan 22, 2018 12:16 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
/*sender code by cooking hacks*/

#include "SX1272.h"

int e;
char my_packet[100];

void setup()
{
// Print a start message
printf("SX1272 module and Raspberry Pi: receive packets without ACK\n");

// Power ON the module
e = sx1272.ON();
printf("Setting power ON: state %d\n", e);

// Set transmission mode
e = sx1272.setMode(4);
printf("Setting Mode: state %d\n", e);

// Set header
e = sx1272.setHeaderON();
printf("Setting Header ON: state %d\n", e);

// Select frequency channel
e = sx1272.setChannel(CH_10_868);
printf("Setting Channel: state %d\n", e);

// Set CRC
e = sx1272.setCRC_ON();
printf("Setting CRC ON: state %d\n", e);

// Select output power (Max, High or Low)
e = sx1272.setPower('H');
printf("Setting Power: state %d\n", e);

// Set the node address
e = sx1272.setNodeAddress(8);
printf("Setting Node address: state %d\n", e);

// Print a success message
printf("SX1272 successfully configured\n\n");
delay(1000);
}

void loop(void)
{
// Receive message
e = sx1272.receivePacketTimeout(10000);
if ( e == 0 )
{
printf("Receive packet, state %d\n",e);

for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
{
my_packet[i] = (char)sx1272.packet_received.data[i];
}
printf("Message: %s\n", my_packet);
}
else {
printf("Receive packet, state %d\n",e);
}
}

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


Top
 Profile  
 
 Post subject: Re: Receiving Ack after packet is sent
PostPosted: Mon Jan 22, 2018 2:23 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Purpose of doing this is to authentication of the user sending the packets.Apart from the nodeAddress that is set at the time of configuring the module.

My idea is to get the first packet as password and comparing this packet against the password that is known to receiver.If this matches then following packets should be exchanged.It might be bad or good idea.But I am an CSE student ,I can think it as this way.


Top
 Profile  
 
 Post subject: Re: Receiving Ack after packet is sent for authentication
PostPosted: Tue Jan 23, 2018 8:10 am 

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

Maybe saving your "password" in the receiver and comparing this data with the data received can help you.

Something like this:

https://www.arduino.cc/en/Tutorial/Stri ... nOperators

What do you think?

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 5 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:


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.