efento / NB-IoT-sensors-integration

This quick tutorial will show you how to set up a simple CoAP server, which receives the data from Efento NB-IoT sensors and saves it to a PostgreSQL database.
Apache License 2.0
7 stars 2 forks source link

Wrong-ish type_ok_alarm calculation? #5

Closed einars closed 1 year ago

einars commented 1 year ago

https://github.com/efento/NB-IoT-sensors-integration/blob/3969b144d71255b2d5e8c217ddaacfd20d39d16d/NB-IoT-sensors-integration-2-way-communication.py#L81-L82

timeDifference = measurementPeriod * int((abs(sampleOffset - 1) / measurementPeriod))

As the actual samples are, say, [1 32401] for one alarm and [-1, -32401] for a different alarm sensor, this calculation seems off,

wrong:
  abs(sampleOffset - 1)   # [0 32400] [2 32402]
better?
  abs(sampleOffset) - 1   # [0 32400] [0 32400]

and, perhaps, now there even might be no need to even consider the measurementPeriod boundaries and this might just work?

timeDifference = abs(sampleOffset) - 1
piotr-szydlowski commented 1 year ago

Hi, you are right. We have already fixed this and uploaded the fix to the repository. Thank you!