Pi Gateway creating a new Node with every Data Packet (Solved)

Started by dwain69, February 06, 2018, 05:38:15 AM

dwain69

Hi Guys

I have been running a PI gateway and a number of nodes for almost two years with no problems.
Awesome stuff by the way :)

Due to a NodeJS issue I decided to start with a fresh raspbian (Stretch Lite) and run the 8.10 Install script.
Everything went well with the install...although I found I had to enable the GPIO serial port in startup which had me miffed for a little while.

The problem I have is that every time a node packet is received from the Gateway, it creates a new Node in the interface.
It seems the Metrics or Gateway script is seeing the packet count (# [123]) at the start of the data as the NODE ID and creates a new Node based on that.
The code on my Nodes has not changed so not sure what is going on.

Any ideas?
Console Log Below...

[02-06-18_20:26:40.050] [LOG]      [18] DB-Insert new _id:18
[02-06-18_20:26:56.150] [LOG]   >: #[19][177] BAT:4.02v C:26.38   [RX_RSSI:-53] - ACK sent. Pinging node 177 - ACK...nothing
[02-06-18_20:26:56.164] [LOG]   post: /home/pi/gateway/data/db/0019_V.bin[1517912816,4.02]
[02-06-18_20:26:56.174] [LOG]   post: /home/pi/gateway/data/db/0019_C.bin[1517912816,26.38]
[02-06-18_20:26:56.193] [LOG]      [19] DB-Insert new _id:19
[02-06-18_20:27:12.079] [LOG]   >: #[20][177] BAT:4.02v C:26.38   [RX_RSSI:-53] - ACK sent.
[02-06-18_20:27:12.094] [LOG]   post: /home/pi/gateway/data/db/0020_V.bin[1517912832,4.02]
[02-06-18_20:27:12.104] [LOG]   post: /home/pi/gateway/data/db/0020_C.bin[1517912832,26.38]
[02-06-18_20:27:12.120] [LOG]      [20] DB-Insert new _id:20

Data in Minicom
#[56][177] BAT:4.02v C:26.31   [RX_RSSI:-56] - ACK sent.
#[57][177] BAT:4.02v C:26.38   [RX_RSSI:-57] - ACK sent.
#[58][177] BAT:4.02v C:26.38   [RX_RSSI:-57] - ACK sent. Pinging node 177 - ACKg
#[59][177] BAT:4.02v C:26.38   [RX_RSSI:-56] - ACK sent.
#[60][177] BAT:4.02v C:26.38   [RX_RSSI:-57] - ACK sent.
#[61][177] BAT:4.02v C:26.31   [RX_RSSI:-57] - ACK sent. Pinging node 177 - ACKg




dwain69

Ignore my stupidity...
It was the Gateway sketch adding the "packetCount" prefix all along.
Funny how my previous version of the Pi gateway ignored it tho ?

Thanks anyway
Dave


Felix

You got it :)

The Pi Gateway sketch assumes that a message that starts with a [number] means a message from that node, if none was received before, it will add a node for that new [number].

vk3jap

I seem to be getting this issue also... driving me nuts!  How do I fix/resolve it.? I can read code, 80% but some of it perplexes me.

I'm using a real simple setup to test with and this code : https://github.com/johnsdiyplayground/moteino-3-part-series-sample-code/blob/master/moteino-example.ino
.. seems to be sending ok. And if I look at the terminal output in the Mote connected to the rPi it seems consistent (used minicom)  - I ONLY have one sending (powered on) Mote.. ID set to "9" - the unit we are observing.

Note those logs are not in time sync but as you can see the _id: keeps incrementing..  I'm using what I beleive is the latest rpi gateway code and the latest code on the rPi also..   what now.?

also - I have so many nodes now.. how do I delete old Note Data - not hide it.. delete it - and such that if that node popped up again it would just appear as new - ie erase history of nodes etc.


Quotepi@raspberrypi:~ $ cat logfile.txt
#[112][9] 9905:112   [RX_RSSI:-33] - ACK sent. Pinging node 9 - ACK...nothing   
#[113][9] 9905:102   [RX_RSSI:-33] - ACK sent.                                 
#[114][9] 9905:98   [RX_RSSI:-34] - ACK sent.                                   
#[115][9] 9905:107   [RX_RSSI:-34] - ACK sent. Pinging node 9 - ACK...nothing   
116][9] 9905:112   [RX_RSSI:-32] - ACK sent.                                   
#[117][9] 9905:107   [RX_RSSI:-32] - ACK sent.                                 
#[118][9] 9905:97   [RX_RSSI:-31] - ACK sent. Pinging node 9 - ACK...nothing   
119][9] 9905:96   [RX_RSSI:2] - ACK sent.                                       
#[120][9] 9905:106   [RX_RSSI:-32] - ACK sent.                                 
#[121][9] 9905:112   [RX_RSSI:-32] - ACK sent. Pinging node 9 - ACK...nothing


Quote6:14:25 PM : {"_id":260,"updated":1523770457580,"descr":"[260]","metrics":{"CM":{"label":"CM","value":2,"unit":"cm","updated":1523770457580,"pin":1,"graph":1}}}
6:14:25 PM : {"_id":81,"updated":1523776116917,"metrics":{"Light Level":{"label":"Light Level","value":110,"unit":" level","updated":1523776116917}}}
6:14:25 PM : {"_id":80,"updated":1523776086939,"metrics":{"Light Level":{"label":"Light Level","value":97,"unit":" level","updated":1523776086939}}}
6:14:25 PM : {"_id":79,"updated":1523776056994,"metrics":{"Light Level":{"label":"Light Level","value":100,"unit":" level","updated":1523776056994}}}
6:14:25 PM : {"_id":78,"updated":1523776026986,"metrics":{"Light Level":{"label":"Light Level","value":98,"unit":" level","updated":1523776026986}}}
6:14:25 PM : {"_id":77,"updated":1523775997008,"metrics":{"Light Level":{"label":"Light Level","value":89,"unit":" level","updated":1523775997008}}}
6:14:25 PM : {"_id":75,"updated":1523775937059,"metrics":{"Light Level":{"label":"Light Level","value":97,"unit":" level","updated":1523775937059}}}
6:14:25 PM : {"_id":73,"updated":1523775877285,"metrics":{"Light Level":{"label":"Light Level","value":89,"unit":" level","updated":1523775877285}}}
6:14:25 PM : {"_id":72,"updated":1523775847128,"metrics":{"Light Level":{"label":"Light Level","value":90,"unit":" level","updated":1523775847128}}}
6:14:25 PM : {"_id":67,"updated":1523779069874,"metrics":{"Light Level":{"label":"Light Level","value":112,"unit":" level","updated":1523779069874}}}
6:14:25 PM : {"_id":68,"updated":1523779084204,"metrics":{"Light Level":{"label":"Light Level","value":96,"unit":" level","updated":1523775727267}}}

Felix

vk3jap,
You can simply delete the binary file from the db folder that corresponds to your node/metric(s) to start from scratch. Note you have to stop the gateway first to ensure the file handles are released, then restart.

sudo systemctl stop gateway
... delete the data files for your node/metrics ...
sudo systemctl start gateway

Please rephrase if you still have another question, I don't quite get what your other question is.

vk3jap

Hey Felix...the biggest issue I'm having is that the gateway is creating a new node for every received packet.. so, for example, every 30 seconds. Just one transmitter..but every packet it sends, equates to a new node in the webUi

What would be causing that do you think?

Felix

Ensure your one transmitter doesn't change its ID. Then ensure your gateway/Pi receiver assigns the ID correctly. For the gateway a sample working sketch is here.

vk3jap

I was looking at the data send from the moteino to the Pi and in that I could see the node ID sending correctly? It's as if the rPi code is incrementing for some reason..wierd.?

Felix

The only way to really fix something is go in code and trace the error.
The stock examples work and will not do something like this. When nothing works I suggest using the stock known-to-work examples and start customizing from there once you get those working. Always verify your sketch settings to ensure they match the hardware configuration (frequency, power setting, node/network/encryption key IDs etc).

vk3jap

I did try all of this. I think it must be the SW running on the Pi as I was loking at what was coming in from serial and that all showed the correct node etc every time.

Now trying to get a working OS and doesn't say -waiting for socket connection-

if you tell me exactly what code to run (flash image for rPi and what code to run for the Mote attached to the gateway - I'll do that). latest rPi - 3B etc.

Verrry confused and disheartened :-(