Page 1 of 2

Occasional "Send confirmed packet error=4"

Posted: Fri Apr 21, 2017 8:35 pm
by ShayVB
I keep receiving "Send confirmed packet error=4" inconsistently when trying to send out frames through LoraWan, why is this happening?

I have tried adjusting the data length around, but it doesn't seem to be fixing the issue. I am not sure if I am not adjusting it right, if I'm sending data too often?

Please help.

Re: Occasional "Send confirmed packet error=4"

Posted: Tue Apr 25, 2017 8:23 am
by libelium-dev
Hi,

Could you please give to us some more information about your network.

Which code are you using? Which base station are you using to send the data?

Regards

Re: Occasional "Send confirmed packet error=4"

Posted: Thu Apr 27, 2017 5:32 pm
by ShayVB
I am connecting the waspmote connected with the 4-20mA sensor board to a multitech gateway via LoRa, and the code I am using is here:

Code: Select all

#include <WaspLoRaWAN.h>
#include <WaspFrame.h>
#include <currentLoop.h>



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



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

uint8_t data[MAX_DATA];

// variable
uint8_t error;

// define the Waspmote ID 
char moteID[] = "Node2";



void setup() 
{
  USB.ON();
  USB.println(F("LoRaWAN example - Send Confirmed packets (ACK)\n"));


  USB.println(F("------------------------------------"));
  USB.println(F("Module configuration"));
  USB.println(F("------------------------------------\n"));


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

  error = LoRaWAN.ON(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("1. Switch ON OK"));     
  }
  else 
  {
    USB.print(F("1. Switch ON error = ")); 
    USB.println(error, DEC);
  }




  //////////////////////////////////////////////
  // 3. Set Application EUI
  //////////////////////////////////////////////

  error = LoRaWAN.setAppEUI("12345678891011121");

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("3. Application EUI set OK"));     
  }
  else 
  {
    USB.print(F("3. Application EUI set error = ")); 
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////
  // 4. Set Application Session Key
  //////////////////////////////////////////////

  error = LoRaWAN.setAppKey("0F1E2D3C4B5A69788796A5B4C3D2E1F0");

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4. Application Key set OK"));     
  }
  else 
  {
    USB.print(F("4. Application Key set error = ")); 
    USB.println(error, DEC);
  }

  /////////////////////////////////////////////////
  // 5. Join OTAA to negotiate keys with the server
  /////////////////////////////////////////////////
  
  error = LoRaWAN.joinOTAA();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("5. Join network OK"));         
  }
  else 
  {
    USB.print(F("5. Join network error = ")); 
    USB.println(error, DEC);
  }


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

  error = LoRaWAN.saveConfig();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("6. Save configuration OK"));     
  }
  else 
  {
    USB.print(F("6. Save configuration error = ")); 
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////
  // 7. Switch off
  //////////////////////////////////////////////

  error = LoRaWAN.OFF(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("7. Switch OFF OK"));     
  }
  else 
  {
    USB.print(F("7. Switch OFF error = ")); 
    USB.println(error, DEC);
  }

  
  USB.println(F("\n---------------------------------------------------------------"));
  USB.println(F("Module configured"));
  USB.println(F("After joining through OTAA, the module and the network exchanged "));
  USB.println(F("the Network Session Key and the Application Session Key which "));
  USB.println(F("are needed to perform communications. After that, 'ABP mode' is used"));
  USB.println(F("to join the network and send messages after powering on the module"));
  USB.println(F("---------------------------------------------------------------\n"));
  USB.println();  
  
  frame.setID(moteID);

  currentLoopBoard.ON(SUPPLY5V);
  delay(1000);

  // Sets the 12V switch ON
  currentLoopBoard.ON(SUPPLY12V); 
  delay(1000); 

}



void loop() 
{
  
  float current_CH1 = currentLoopBoard.readCurrent(CHANNEL1); 
  float current_CH2 = currentLoopBoard.readCurrent(CHANNEL2);
  
  //////////////////////////////////////////////
  // 1. Creating a new frame
  //////////////////////////////////////////////
  USB.println(F("Creating an ASCII frame"));

  // Create new frame (ASCII)
  frame.createFrame(ASCII); 

  frame.addSensor(SENSOR_STR, "SSI");
  frame.addSensor(SENSOR_4_20_CURRENT_SOCKET_A, current_CH1);
  frame.addSensor(SENSOR_STR, "ALS");
  frame.addSensor(SENSOR_4_20_CURRENT_SOCKET_B, current_CH2);
  


  // Prints frame
  frame.showFrame();
  
  //////////////////////////////////////////////
  // 2. Switch on
  //////////////////////////////////////////////

  error = LoRaWAN.ON(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("1. Switch ON OK"));     
  }
  else 
  {
    USB.print(F("1. Switch ON error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 3. Join network
  //////////////////////////////////////////////

  error = LoRaWAN.joinABP();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Join network OK")); 

    //////////////////////////////////////////////
    // 4. Send confirmed packet 
    //////////////////////////////////////////////

    error = LoRaWAN.sendConfirmed( PORT, frame.buffer, frame.length);

    // 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 confirmed 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 confirmed packet error = ")); 
      USB.println(error, DEC);
    }    
  }
  else 
  {
    USB.print(F("2. Join network error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 5. Switch off
  //////////////////////////////////////////////

  error = LoRaWAN.OFF(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4. Switch OFF OK"));     
  }
  else 
  {
    USB.print(F("4. Switch OFF error = ")); 
    USB.println(error, DEC);
  }


  USB.println();
  delay(60000);

}

Re: Occasional "Send confirmed packet error=4"

Posted: Fri Apr 28, 2017 9:41 am
by libelium-dev
Hi,

Could you please tell us which LoRaWAN module are you using? US or EU version?

Regards

Re: Occasional "Send confirmed packet error=4"

Posted: Fri Apr 28, 2017 5:19 pm
by ShayVB
I am using the US version.

Re: Occasional "Send confirmed packet error=4"

Posted: Tue May 02, 2017 8:54 am
by libelium-dev
Hi,

Please try to run the examples to configure the LoRaWAN module. First run the example to configure the US module and all general settings related to back-end registration process.
http://www.libelium.com/development/was ... module-us/

Then please run the example to configure the channels for LoRaWAN US according the channels of your base station.
http://www.libelium.com/development/was ... ration-us/

Now try to run your code, if you get error 4 again please copy here all output you get.

Regards

Re: Consistent "Send confirmed packet error=4" for US Module

Posted: Wed Feb 13, 2019 3:32 pm
by Abhijit
Hi Support Team,

I am also this issue and consistently. Not able to make the code work for lora US module. Followed the configuration and channel setting also. Please help

GOOD CASE

//char *str ="232354433a32312e353223"; //char *str ="12#1#24#0#TC:21.52#";
error = LoRaWAN.sendUnconfirmed (1, str);

BAD CASE - If data size is above 22 HEX chars or 11 aschii chars, get "Send confirmed packet error=4" error
//frame (HEX): 3C3D3E8608233335383036463035374331303534383723323423352354433A32312E39312348554D3A32372E3223505245533A3130303132332E3937234E4F323A302E30303023504D313A302E3336303023504D325F353A302E3432303023504D31303A302E3432303023434F3A302E30303023
//frame (STR): <=>†#35806F057C105487#24#5#TC:21.91#HUM:27.2#PRES:100123.97#NO2:0.000#PM1:0.3600#PM2_5:0.4200#PM10:0.4200#CO:0.000#

error = LoRaWAN.sendUnconfirmed (PORT, frame.buffer,frame.length);

Re: Occasional "Send confirmed packet error=4"

Posted: Thu Feb 14, 2019 12:48 pm
by libelium-dev
Hi,

The maximum payload depend to de data rate. If the data rate is 0, the maximum payload is 11bytes for LoRaWAN US module. You can find more information here
http://www.libelium.com/downloads/docum ... df#page=38

You can try to set a fixed data rate to be able to send more than 11bytes.

Regards

Re: Occasional "Send confirmed packet error=4"

Posted: Thu Jan 09, 2020 3:56 pm
by nespoo
Hello Support Team,

We have Smart City kit with LoRa US band and have been consistently facing the issue of "Send Confirmed Packet Error = 4".

We have tried different approaches to fix the issue, which we suspect to be due to data length. However, no luck so far. Below are the detailed information of the what we tried:

1. Limiting the channels to 3 , tried with min and max data rate at each channel level
a. Out of 64 channels, Only 3 channels were set to On and remaining were set to off
b. The channels which are set to On , were set with maximum Data Rate ( tried with 3 4 and 5)
c. The channels which are set to On , were set with maximum Data Rate ( tried with 3 4 and 5)

2. Setting Data Rate to specific channel

3. Limiting data to 2 Probes and without probe data
a. Tried limiting output data only from 2 probes – Still same issue
b. Tried removing all the probe data – still same issue

4. Output data format from ASCII to Binary – Still same issue

Below is the code that we used for the above trials.

---------------------------------------------------------
/*
* ------ LoRaWAN Code Example --------
*
* Explanation: This example shows how to configure the channels settings.
* There are 64 channels. All channels are set to on by default. In addition
* to the status user can change the data rate range and query the frequency
* of the channel
*
* Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 3.2
* Design: David Gascon
* Implementation: Luismi Marti
*/

#include <WaspLoRaWAN.h>
#include <WaspFrame.h>
#include <WaspSensorGas_Pro.h>
#include <WaspSensorCities_PRO.h>
#include <WaspOPC_N2.h>
#include <WaspUART.h>
//////////////////////////////////////////////
uint8_t socket = SOCKET0;
//////////////////////////////////////////////
//////////////////////////////////////////////
bmeCitiesSensor bme(SOCKET_E);
Gas NO2(SOCKET_C);
Gas CO(SOCKET_F);

char info_string[61];
int status;
int measure;

float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa

float concentration_NO2; // Stores the concentration level in ppm

float concentration_CO; // Stores the concentration level in ppm

////////////////////////////////////////////////////////////

// Define port to use in Back-End: from 1 to 223
uint8_t PORT = 3;
// variable
uint8_t error;
// define the Waspmote ID
char moteID[] = "24";

void setup()
{
USB.ON();
USB.println(F("LoRaWAN example - LoRaWAN US Channel configuration"));

//////////////////////////////////////////////
// 1. switch on
//////////////////////////////////////////////

error = LoRaWAN.ON(socket);

// Check status
if( error == 0 )
{
USB.println(F("1. Switch ON OK"));
}
else
{
USB.print(F("1. Switch ON error = "));
USB.println(error, DEC);
}


//////////////////////////////////////////////
// 2. Set frequency for specific channel
//////////////////////////////////////////////

error = LoRaWAN.getChannelFreq(3);

// Check status
if( error == 0 )
{
USB.print(F("2. Frequency get OK. "));
USB.print(F("Frequency:"));
USB.println(LoRaWAN._freq[3]);
}
else
{
USB.print(F("2. Frequency get error = "));
USB.println(error, DEC);
}


//////////////////////////////////////////////
// 3. Set Data rate range for specific channel
//////////////////////////////////////////////

error = LoRaWAN.setChannelDRRange(3, 0, 3);

// Check status
if( error == 0 )
{
USB.print(F("3. Data Rate range set OK. "));
USB.print(F("Data Rate min:"));
USB.print(LoRaWAN._drrMin[3], DEC);
USB.print(F(". Data Rate max:"));
USB.println(LoRaWAN._drrMax[3], DEC);
}
else
{
USB.print(F("3. Data rate range set error = "));
USB.println(error, DEC);
}


//////////////////////////////////////////////
// 4. Set Data rate range for specific channel
//////////////////////////////////////////////

error = LoRaWAN.setChannelStatus(3, "off");

// Check status
if( error == 0 )
{
USB.print(F("4. Channel status set OK: "));
USB.println(LoRaWAN._status[3], DEC);
}
else
{
USB.print(F("4. Channel status set error = "));
USB.println(error, DEC);
}


//////////////////////////////////////////////
// 5. Save configuration
//////////////////////////////////////////////

error = LoRaWAN.saveConfig();

// Check status
if( error == 0 )
{
USB.println(F("5. Save configuration OK"));
}
else
{
USB.print(F("5. Save configuration error = "));
USB.println(error, DEC);
}


///////////////////////////////////////////////////////////
// show configuration for all channels available
///////////////////////////////////////////////////////////

USB.println(F("\n----------------------------"));

for( int i=0; i<64; i++)
{
if( i <= 3){
LoRaWAN.setChannelStatus(i, "on");
LoRaWAN.setChannelDRRange(i, 5, 5);
} else{
LoRaWAN.setChannelStatus(i, "off");
LoRaWAN.setChannelDRRange(i, 0, 3);
}
LoRaWAN.getChannelFreq(i);
LoRaWAN.getChannelDRRange(i);
LoRaWAN.getChannelStatus(i);

USB.print(F("Channel: "));
USB.println(i);
USB.print(F(" Freq: "));
USB.println(LoRaWAN._freq);
USB.print(F(" DR min: "));
USB.println(LoRaWAN._drrMin, DEC);
USB.print(F(" DR max: "));
USB.println(LoRaWAN._drrMax, DEC);
USB.print(F(" Status: "));
/** if (LoRaWAN._status == 1)
{
USB.println(F("on"));
}
else
{
USB.println(F("off"));
}**/
USB.println(F("----------------------------"));
}
USB.println(F("\n------------------------------------"));
USB.println(F("Module configured"));
USB.println(F("------------------------------------\n"));

LoRaWAN.getDeviceEUI();
USB.print(F("Device EUI: "));
USB.println(LoRaWAN._devEUI);

LoRaWAN.getDeviceAddr();
USB.print(F("Device Address: "));
USB.println(LoRaWAN._devAddr);

USB.println();

frame.setID(moteID);

status = OPC_N2.ON();
if (status == 1)
{
status = OPC_N2.getInfoString(info_string);
if (status == 1)
{
USB.println(F("Information string extracted:"));
USB.println(info_string);
}
else
{
USB.println(F("Error reading the particle sensor"));
}
OPC_N2.OFF();
}
else
{
USB.println(F("Error starting the particle sensor"));
}
}


void loop()
{

///////////////////////////////////////////
// 1. Turn on the sensor
///////////////////////////////////////////


// Power on the temperature, humidity and pressure sensor.
bme.ON();
// Power on the NO2 sensor.
NO2.ON();
// Power on the CO sensor.
CO.ON();
USB.println(F("Sensors reading in progress......"));
// PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);

status = OPC_N2.ON();
if (status == 1)
{
USB.println(F("Particle sensor started"));
}
else
{
USB.println(F("Error starting the particle sensor"));
}

///////////////////////////////////////////
// 2. Read sensors
///////////////////////////////////////////

temperature = bme.getTemperature();
humidity = bme.getHumidity();
pressure = bme.getPressure();
concentration_NO2 = NO2.getConc();
concentration_CO = CO.getConc();

// And print the values via USB
USB.println(F("***************************************"));
USB.print(F("Temperature: "));
USB.printFloat(temperature, 2);
USB.println(F(" Celsius degrees"));
USB.print(F("RH: "));
USB.printFloat(humidity, 2);
USB.println(F(" %"));
USB.print(F("Pressure: "));
USB.printFloat(pressure, 2);
USB.println(F(" Pa"));
USB.print(F("NO2: "));
USB.print(concentration_NO2);
USB.println(F(" ppm"));
USB.print(F("CO: "));
USB.print(concentration_CO);
USB.println(F(" ppm"));

if (status == 1)
{
// Power the fan and the laser and perform a measure of 5 seconds
measure = OPC_N2.getPM(5000);
if (measure == 1)
{
USB.println(F("Measure performed"));
USB.print(F("PM 1: "));
USB.print(OPC_N2._PM1);
USB.println(F(" ug/m3"));
USB.print(F("PM 2.5: "));
USB.print(OPC_N2._PM2_5);
USB.println(F(" ug/m3"));
USB.print(F("PM 10: "));
USB.print(OPC_N2._PM10);
USB.println(F(" ug/m3"));

}
else
{
USB.print(F("Error performing the measure. Error code:"));
USB.println(measure, DEC);
}
}


//////////////////////////////////////////////
// 3. Creating a new frame
//////////////////////////////////////////////
USB.println(F("Creating an ASCII frame"));

// Create new frame (ASCII)
// frame.count == 0;
frame.createFrame(ASCII);

// set frame fields (String - char*)
// frame.addSensor(SENSOR_STR, (char*) "this_is_a_string");
// set frame fields (Battery sensor - uint8_t)
// frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
// frame.addSensor(SENSOR_GASES_PRO_TC,temperature);

//frame.addSensor(SENSOR_GASES_PRO_HUM,humidity);
/**frame.addSensor(SENSOR_GASES_PRO_PRES,pressure);
frame.addSensor(SENSOR_GASES_PRO_NO2,concentration_NO2);
frame.addSensor(SENSOR_GASES_PRO_PM1,OPC_N2._PM1);
frame.addSensor(SENSOR_GASES_PRO_PM2_5,OPC_N2._PM2_5);
frame.addSensor(SENSOR_GASES_PRO_PM10,OPC_N2._PM10);
frame.addSensor(SENSOR_GASES_PRO_CO,concentration_CO);
**/
// Prints frame
frame.showFrame();

///////////////////////////////////////////
// 3. Turn off the sensor
///////////////////////////////////////////

bme.OFF();
NO2.OFF();
CO.OFF();
OPC_N2.OFF();
//////////////////////////////////////////////
// 2. Switch on LoRaWAN
//////////////////////////////////////////////

error = LoRaWAN.ON(socket);

// Check status
if( error == 0 )
{
USB.println(F("1. Switch ON OK"));
}
else
{
USB.print(F("1. Switch ON error = "));
USB.println(error, DEC);
}


//////////////////////////////////////////////
// 3. Join network
//////////////////////////////////////////////

error = LoRaWAN.joinABP();

// Check status
if( error == 0 )
{
USB.println(F("2. Join network OK"));
//////////////////////////////////////////////
// 4. Send confirmed packet
//////////////////////////////////////////////

//frame (HEX): 3C3D3E8608233335383036463035374331303534383723323423352354433A32312E39312348554D3A32372E3223505245533A3130303132332E3937234E4F323A302E30303023504D313A302E3336303023504D325F353A302E3432303023504D31303A302E3432303023434F3A302E30303023
//frame (STR): <=>†#35806F057C105487#24#5#TC:21.91#HUM:27.2#PRES:100123.97#NO2:0.000#PM1:0.3600#PM2_5:0.4200#PM10:0.4200#CO:0.000#

error = LoRaWAN.sendUnconfirmed (PORT, frame.buffer,frame.length);

//char *str ="232354433a32312e353223"; //char *str ="12#1#24#0#TC:21.52#";
//error = LoRaWAN.sendUnconfirmed (1, str);

// 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 Confirmed 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 Confirmed packet error = "));
USB.println(error, DEC);
}
}
else
{
USB.print(F("2. Join network error = "));
USB.println(error, DEC);
}


delay(5000);
//////////////////////////////////////////////
// 5. Switch off
//////////////////////////////////////////////
error = LoRaWAN.OFF(socket);

// Check status
if( error == 0 )
{
USB.println(F("4. Switch OFF OK"));
}
else
{
USB.print(F("4. Switch OFF error = "));
USB.println(error, DEC);
}


USB.println();
// delay(5000);
/*
///////////////////////////////////////////
// 3. Turn off the sensor
///////////////////////////////////////////

bme.OFF();
NO2.OFF();
CO.OFF();
OPC_N2.OFF();
*/
///////////////////////////////////////////
// 4. Sleep
///////////////////////////////////////////

// Go to deepsleep
// After 10 seconds, Waspmote wakes up thanks to the RTC Alarm
USB.println(F("Go to deep sleep mode..."));
PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
USB.println(F("Wake up!!\r\n"));

}
------------------------------------------------

Best Regards

Re: Occasional "Send confirmed packet error=4"

Posted: Fri Jan 10, 2020 8:43 am
by libelium-dev
Hi,

Could you please post the output through the serial monitor? If the error is related to the data length, it means that the packet length is higher than the maximum packet according to the data rate. You can try to decrease it creating a BINARY tiny frame instead of ASCII frame. You can find an example code in the following link.
http://www.libelium.com/development/was ... iny-frame/

Regards