LoRa Send Unconfirmed packet error = 7

Everything about programming the platform and using the Waspmote API
Post Reply
PhilippeS
Posts: 3
Joined: Fri Oct 07, 2016 1:27 pm

LoRa Send Unconfirmed packet error = 7

Post by PhilippeS » Tue Oct 11, 2016 4:51 pm

Hello,

I use the smart cities sensor and want to send the output of the temperature, humidity, luminosity and noise level over the LoRa network (with Actility TPW). I have the following code below and get the serial output at the end of this message.
I continuously get "Send Unconfirmed packet error = 7" and the packet is not sent.

please advise.

best regards

---------------------------

// Read the temperature sensor
temperature = SensorCities.readValue(SENS_CITIES_TEMPERATURE);
USB.println(F("Temperature:"));
USB.println(temperature);
char temperatureString[20];
Utils.float2String(temperature,temperatureString,2);
//dtostrf(temperature, 10, 2, temperatureString);
USB.printf("%s\n", temperatureString);

error = LoRaWAN.sendUnconfirmed(PORT, temperatureString);
// 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 )
{
USB.println(F("3. Send Unconfirmed packet OK"));
if (LoRaWAN._dataReceived == true)
{
USB.print(F(" There's data on port number "));
USB.print(LoRaWAN._port,DEC);
USB.print(F(".\r\n Data: "));
USB.println(LoRaWAN._data);
}
}
else
{
USB.print(F("3. Send Unconfirmed packet error = "));
USB.println(error, DEC);
}
----------------------------------------------------------------------------------------------------
serial output I get:

E#
LoRaWAN Module configuration
1. Switch ON OK
2. Reset to factory default values OK
3.1. Set Device EUI OK
3.2. Get Device EUI OK. Device EUI: 5656A30B0828A063
4.1. Set Device address OK
4.2. Get Device address OK. Device address: 0600015D
5. Set Network Session Key OK
6. Set Application Session Key OK
5.2 ADR set on
7.1. Set Retransmissions for uplink confirmed packet OK
7.2. Get Retransmissions for uplink confirmed packet OK. TX retries: 7
13. Save configuration OK
------------------------------------
Now the LoRaWAN module is ready for
joining networks and send messages.
------------------------------------

1. Switch ON OK
2. Join network OK
Battery Level(dec): 76 %
Temperature:
23.8709659576
23.87
Humidity:
43.7233963012
43.723
Analog LDR Voltage:
82.7957000732
82.796
Audio:
50.0000000000
50.000
Þ
3. Send Unconfirmed packet error = 7
4. Switch OFF OK

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by libelium-dev » Thu Oct 13, 2016 10:49 am

Hi,

The "Send Unconfirmed packet error = 7" means port error input.

So please revise your code, port can't be higher than 223.

Hope this help.

Regards

celarcm
Posts: 54
Joined: Wed Aug 12, 2015 2:24 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by celarcm » Thu Mar 01, 2018 9:19 pm

Hi,

I am having the same issue..

When I am sending this char the data is successfully sent over LoRaWAN.

Code: Select all

char data[] = "1337";
error = LoRaWAN.sendUnconfirmed( PORT, data);
But when I try to send the reading of a pm1 particle sensor, I get
Send Unconfirmed packet error = 7

Code: Select all

float pm1;
pm1 = OPC_N2._PM1;
char pm1Val[10];
Utils.float2String(pm1, pm1Val, 2);

error = LoRaWAN.sendUnconfirmed( PORT, pm1Val);
Please advice on how to proceed.

Thanks.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by libelium-dev » Fri Mar 02, 2018 11:29 am

Hi,

Data sending through LoRaWAN module must be stings in hexadecimal formal. So you have to convert data to hex, you can use Utils.hex2str() function. Her you can see a example

Code: Select all

// define local buffer for float to string conversion
char float_str[10];
char message[100];
char payload_hex[200];

  // use dtostrf() to convert from float to string: 
  // '1' refers to minimum width
  // '3' refers to number of decimals
  dtostrf( temperature, 1, 2, float_str);
  
  // use snprintf() to include the float representation
  snprintf( message, sizeof(message), "Temp:%s", float_str );
  USB.println( message );

  Utils.hex2str((uint8_t*)message, payload_hex, strlen(message));

  LoRaWAN.sendConfirmed( PORT, payload_hex);
Hope this helps.
Regards

celarcm
Posts: 54
Joined: Wed Aug 12, 2015 2:24 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by celarcm » Tue Mar 13, 2018 11:34 am

Thank you, that solved my problem!

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by libelium-dev » Tue Mar 13, 2018 1:48 pm

Glad to hear that! :D

aduma
Posts: 3
Joined: Tue Mar 21, 2017 4:18 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by aduma » Mon Nov 05, 2018 11:35 am

I am sorry, but I think your solution is not best practice. LoraWan frame is limited (I think 56 bytes or so). Putting value in a string and then converting the string to hex is just a waste of space and requires additional processing on the back-end.
You suggest that for sending one temperature to build a string such as "Temp: 23.75" and then converting it to hex: "54656d703a2032332e3735", and then send it.

the better way to do it would be to convert directly 2375 to hex, which is "0947" and send just this. It would also be easier to extract it on the backend and you can send a lot of readings in 56 bytes.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa Send Unconfirmed packet error = 7

Post by libelium-dev » Tue Nov 06, 2018 8:43 am

Hi,

You are right, sending a string converter to hex isn't the best practice to send packet through LoRaWAN protocol but it is a easy way. For this cases, we develop the tiny frames
http://www.libelium.com/downloads/docum ... df#page=11

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest