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   [ 6 posts ]
Author Message
 Post subject: LoRa multiprotocol Shield arduino Half Duplex communication
PostPosted: Sun Apr 29, 2018 11:30 am 

Joined: Wed Dec 06, 2017 4:51 pm
Posts: 11
Hello,

I am doing a half duplex communication but at one node I am getting "Packet Sent, state 3".

Please can someone guide me about this.

Thanks.


Top
 Profile  
 
 Post subject: Re: LoRa multiprotocol Shield arduino Half Duplex communicat
PostPosted: Wed May 02, 2018 12:16 pm 

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

Could you give us more details about the issue?

Regards


Top
 Profile  
 
 Post subject: Re: LoRa multiprotocol Shield arduino Half Duplex communicat
PostPosted: Thu May 03, 2018 7:33 pm 

Joined: Wed Dec 06, 2017 4:51 pm
Posts: 11
Hi,

The two way communication issue has been solved. However, I m having difficulty in comparing the received char array with a pre-defined array in RX code. Below is the code for example. When I compare the received char array with a pre-defined array, it does not match.

Below in the code, the problems are written in CAPITAL LETTER COMMENTS.

Code:
***************"RX Code"*****************
#include <Wire.h>
#include <Keypad.h>

// Cooking API libraries
#include <arduinoUtils.h>

// Include the SX1272 and SPI library:
#include "arduinoLoRa.h"
#include <SPI.h>

int e;
char my_packet[100];
char message1 [] = "A";

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
 
  // Print a start message
  Serial.println(F("SX1272 module and Arduino: receive packets with ACK"));
 
  // Power ON the module
  e = sx1272.ON();
  Serial.print(F("Setting power ON: state "));
  Serial.println(e, DEC);
 
  // Set transmission mode and print the result
  e |= sx1272.setMode(4);
  Serial.print(F("Setting Mode: state "));
  Serial.println(e, DEC);
 
  // Set header
  e |= sx1272.setHeaderON();
  Serial.print(F("Setting Header ON: state "));
  Serial.println(e, DEC);
 
  // Select frequency channel
  e |= sx1272.setChannel(CH_10_868);
  Serial.print(F("Setting Channel: state "));
  Serial.println(e, DEC);
 
  // Set CRC
  e |= sx1272.setCRC_ON();
  Serial.print(F("Setting CRC ON: state "));
  Serial.println(e, DEC);
 
  // Select output power (Max, High or Low)
  e |= sx1272.setPower('M');
  Serial.print(F("Setting Power: state "));
  Serial.println(e, DEC);
 
  // Set the node address and print the result
  e |= sx1272.setNodeAddress(8);
  Serial.print(F("Setting node address: state "));
  Serial.println(e, DEC);
 
  // Print a success message
  if (e == 0)
    Serial.println(F("SX1272 successfully configured"));
  else
    Serial.println(F("SX1272 initialization failed"));
}

void loop(void)

  // Receive message
  e = sx1272.receivePacketTimeoutACK(10000);
  while ( e != 0 )
  {
      e = sx1272.sendPacketTimeoutACK(3, message1);
      Serial.print("message sent:");
      Serial.println(message1);
      Serial.print(F("Packet sent, state "));
      Serial.println(e, DEC);
    }
  }
    Serial.print(F("Receive packet with ACK, state "));
    Serial.println(e, DEC);

    for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
    {
      my_packet[i] = (char)sx1272.packet_received.data[i];
    }
    Serial.print(F("Message: "));
    Serial.println(my_packet);
}


Code:
*****************"TX Code"*******************
#include <Wire.h>

// Cooking API libraries
#include <arduinoUtils.h>

// Include the SX1272 and SPI library:
#include "arduinoLoRa.h"
#include <SPI.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";
char my_packet[100];

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
 
  // Print a start message
  Serial.println(F("SX1272 module and Arduino: send packets with ACK"));
 
  // Power ON the module
  e = sx1272.ON();
  Serial.print(F("Setting power ON: state "));
  Serial.println(e, DEC);
 
  // Set transmission mode and print the result
  e |= sx1272.setMode(4);
  Serial.print(F("Setting Mode: state "));
  Serial.println(e, DEC);
 
  // Set header
  e |= sx1272.setHeaderON();
  Serial.print(F("Setting Header ON: state "));
  Serial.println(e, DEC);
 
  // Select frequency channel
  e |= sx1272.setChannel(CH_10_868);
  Serial.print(F("Setting Channel: state "));
  Serial.println(e, DEC);
 
  // Set CRC
  e |= sx1272.setCRC_ON();
  Serial.print(F("Setting CRC ON: state "));
  Serial.println(e, DEC);
 
  // Select output power (Max, High or Low)
  e |= sx1272.setPower('M');
  Serial.print(F("Setting Power: state "));
  Serial.println(e, DEC);
 
  // Set the node address and print the result
  e |= sx1272.setNodeAddress(3);
  Serial.print(F("Setting node address: state "));
  Serial.println(e, DEC);
 
  // Print a success message
  if (e == 0)
    Serial.println(F("SX1272 successfully configured"));
  else
    Serial.println(F("SX1272 initialization failed"));
}
void loop(void)
{
      // Receive message
      e = sx1272.receivePacketTimeoutACK(10000);

      if (e == 0)
      {
        Serial.print(F("Receive packet with ACK, state "));
        Serial.println(e, DEC);

        for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
        {
          my_packet[i] = (char)sx1272.packet_received.data[i]; //WHAT TYPE OF DATA DOES IT RECEIVE?
        }
        Serial.print(F("Message: "));
        Serial.println(my_packet);

    if (my_packet == "A")  //HERE COMPARISON IS NOT SUCCESSFUL
       {
          e = sx1272.sendPacketTimeoutACK(8, message1);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000); 

          // Send message2 broadcast and print the result
          e = sx1272.sendPacketTimeoutACK(0, message2);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000);
       }
       }   
}


Top
 Profile  
 
 Post subject: Re: LoRa multiprotocol Shield arduino Half Duplex communicat
PostPosted: Fri May 04, 2018 2:35 pm 

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

data is declared as uint8_t data[MAX_PAYLOAD], so try to declare my_packets as uint8_t my_packets[251].

Then try to compare the data with something like
Code:
my_packet[0] == "A"


Hope this helps.
Regards


Top
 Profile  
 
 Post subject: Re: LoRa multiprotocol Shield arduino Half Duplex communicat
PostPosted: Fri May 04, 2018 4:50 pm 

Joined: Wed Dec 06, 2017 4:51 pm
Posts: 11
I have declared
Quote:
uint8_t my_packet [251];
below is the code, but then I get error in
Quote:
Serial.print(my_packet);
The error is:
Quote:
size_t println(unsigned long, int = DEC);
Quote:
exit status 1,
call of overloaded 'println(uint8_t [251])' is ambiguous


Also, the comparison is not successful either.

Code:
int e;

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

void loop(void)
{
      // Receive message
      e = sx1272.receivePacketTimeoutACK(10000);

      if (e == 0)
      {
        Serial.print(F("Receive packet with ACK, state "));
        Serial.println(e, DEC);

        for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
        {
          my_packet[i] = (char)sx1272.packet_received.data[i]; //WHAT TYPE OF DATA DOES IT RECEIVE?
        }
        Serial.print(F("Message: "));
        Serial.println(my_packet);

    if (my_packet == "A")  //HERE COMPARISON IS NOT SUCCESSFUL
       {
          e = sx1272.sendPacketTimeoutACK(8, message1);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000); 

          // Send message2 broadcast and print the result
          e = sx1272.sendPacketTimeoutACK(0, message2);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000);
       }
       }   
}


Top
 Profile  
 
 Post subject: Re: LoRa multiprotocol Shield arduino Half Duplex communicat
PostPosted: Mon May 07, 2018 10:41 am 

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

It seems conversion problems between uint8_t and char. Please try the following code
Code:
#include <Wire.h>

// Cooking API libraries
#include <arduinoUtils.h>

// Include the SX1272 and SPI library:
#include "arduinoLoRa.h"
#include <SPI.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";
uint8_t my_packet[251];

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
 
  // Print a start message
  Serial.println(F("SX1272 module and Arduino: send packets with ACK"));
 
  // Power ON the module
  e = sx1272.ON();
  Serial.print(F("Setting power ON: state "));
  Serial.println(e, DEC);
 
  // Set transmission mode and print the result
  e |= sx1272.setMode(4);
  Serial.print(F("Setting Mode: state "));
  Serial.println(e, DEC);
 
  // Set header
  e |= sx1272.setHeaderON();
  Serial.print(F("Setting Header ON: state "));
  Serial.println(e, DEC);
 
  // Select frequency channel
  e |= sx1272.setChannel(CH_10_868);
  Serial.print(F("Setting Channel: state "));
  Serial.println(e, DEC);
 
  // Set CRC
  e |= sx1272.setCRC_ON();
  Serial.print(F("Setting CRC ON: state "));
  Serial.println(e, DEC);
 
  // Select output power (Max, High or Low)
  e |= sx1272.setPower('M');
  Serial.print(F("Setting Power: state "));
  Serial.println(e, DEC);
 
  // Set the node address and print the result
  e |= sx1272.setNodeAddress(3);
  Serial.print(F("Setting node address: state "));
  Serial.println(e, DEC);
 
  // Print a success message
  if (e == 0)
    Serial.println(F("SX1272 successfully configured"));
  else
    Serial.println(F("SX1272 initialization failed"));
}
void loop(void)
{
      // Receive message
      e = sx1272.receivePacketTimeoutACK(10000);

      if (e == 0)
      {
        Serial.print(F("Receive packet with ACK, state "));
        Serial.println(e, DEC);

        for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
        {
          my_packet[i] = sx1272.packet_received.data[i]; //WHAT TYPE OF DATA DOES IT RECEIVE?
        }
        Serial.print(F("Message: "));
        Serial.println((char*)my_packet);

    if (my_packet == (uint8_t*)"A")  //HERE COMPARISON IS NOT SUCCESSFUL
       {
          e = sx1272.sendPacketTimeoutACK(8, message1);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000);

          // Send message2 broadcast and print the result
          e = sx1272.sendPacketTimeoutACK(0, message2);
          Serial.print(F("Packet sent, state "));
          Serial.println(e, DEC);

          delay(4000);
       }
       }   
}


Hope this helps.
Regards


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