ElectronicCats / CayenneLPP

Library for Arduino compatible with Cayenne Low Power Payload
http://electroniccats.com/
MIT License
106 stars 48 forks source link

Payload arriving twice at Cayenne #10

Closed mbobinger closed 4 years ago

mbobinger commented 4 years ago

Dear Github Team,

I am encountering some problems with the displaying of the sensor data. We are using Arduino IDE with this library: https://github.com/ElectronicCats/CayenneLPP version 1.0.2 (1.0.3 has been released a couple of days).

We transmit the following parameters: lpp.addTemperature(1, Temperature0); lpp.addTemperature(2, Temperature1); lpp.addTemperature(3, Temperature2); lpp.addAnalogInput(4, moisture); lpp.addAnalogInput(5, batteryLevel);

As you can see from the attached .png, the parameters arrive multiple times and the values are also different. Have you seen clients with these problems? ground_sensor

Best regards and thank you, Marco

sabas1080 commented 4 years ago

please put more of your example, there may be several factors of why they are repeated

amotl commented 4 years ago

Might a misconfigured frame counter be involved here? According to the specification:

Frame Counter Check (Broker)

The frame counter in LoRaWAN messages is a security measure used to detect replay attacks. After validating the MIC, the Broker checks if the Frame counter is valid. As frame counters can only increase, a message with a frame counter that is lower than the last known frame counter should be dropped. Additionally, the Broker has to verify that the gap between the last known frame counter and the counter in the message is not too big. According to the LoRaWAN specification, the maximum gap is 16384.

-- https://www.thethingsnetwork.org/docs/network/architecture.html#frame-counter-check-broker

In order to get things right, consecutive transmissions should increase the frame counter between them. Special care has to be taken to persist the frame counter across deep sleep phases.