mysensors / MySensors

MySensors library and examples

Home Page:https://www.mysensors.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

N2N logic sends message from node to parent twice

virtual-maker opened this issue · comments

Setup

My setup to reproduce the problem consists of 3 nodes:
Gateway (0), Repeater(20) and one Sensor-Node(21).
The parent of the sensor node is the repeater.

Current:

The problem occurs when the sensor node sends a message to the repeater as destination. In this case first a telegram is sent via the N2N logic. If the sending fails, the message is sent again via the standard path to the repeater as parent node.

This way the telegram can arriving twice at the repeater (if only ACK is lost at first N2N transmission).

The decision whether to send a telegram with N2N is present in core/MyTransport.cpp#L548:

if (destination > GATEWAY_ADDRESS && destination < BROADCAST_ADDRESS) {
  // Send N2N ...

Expected:

The decision whether to send the telegram using N2N should not test if the destination is the gateway, but the parent node:

route = _transportConfig.parentNodeId;
if (destination != route && destination != BROADCAST_ADDRESS) {
  // Send N2N ...

Debug log of the Sensor-Node (21) is:

17 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=0,VER=2.4.0-alpha
27 TSM:INIT
28 TSF:WUR:MS=0
35 TSM:INIT:TSP OK
37 TSM:INIT:STATID=21
39 TSF:SID:OK,ID=21
40 TSM:FPAR
41 TSM:FPAR:STATP=20
44 TSM:ID
45 TSM:ID:OK
...
2293 MCO:PIM:NODE REG=1
2295 MCO:BGN:STP
2297 MCO:BGN:INIT OK,TSP=1
2504 !TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=NACK:00 ... 002A
2515 !TSF:RTE:N2N FAIL
2521 TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=OK:00 ... 002A
3068 !TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=NACK:00 ... 002A
3080 !TSF:RTE:N2N FAIL
3084 TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=OK:00 ... 002A
3633 !TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=NACK:00 ... 002A
3644 !TSF:RTE:N2N FAIL
3649 TSF:MSG:SEND,21-21-20-20,s=0,c=1,t=2,pt=6,l=25,sg=0,ft=0,st=OK:00 ... 002A
...