bemasher / rtlamr

An rtl-sdr receiver for Itron ERT compatible smart meters operating in the 900MHz ISM band.
GNU Affero General Public License v3.0
2.19k stars 249 forks source link

Duplicate Messages due to Unkn Fields #137

Closed val123456 closed 4 years ago

val123456 commented 4 years ago

Just got a new Neptune R900 water meter, and am integrating it into my monitoring solution. I use the -unique=true flag but noticed what looked like duplicate messages. It appears unique means all fields match AND it only compares to the last message. However, my meter flops the Unkn1 field . . . sample below.

"Message":{"ID":1563476986,"Unkn1":163,"NoUse":35,"BackFlow":0,"Consumption":57171,"Unkn3":0,"Leak":1,"LeakNow":0}}
"Message":{"ID":1563476986,"Unkn1":131,"NoUse":35,"BackFlow":0,"Consumption":57171,"Unkn3":0,"Leak":1,"LeakNow":0}}
"Message":{"ID":1563476986,"Unkn1":163,"NoUse":35,"BackFlow":0,"Consumption":57171,"Unkn3":0,"Leak":1,"LeakNow":0}}
"Message":{"ID":1563476986,"Unkn1":131,"NoUse":35,"BackFlow":0,"Consumption":57171,"Unkn3":0,"Leak":1,"LeakNow":0}}
"Message":{"ID":1563476986,"Unkn1":163,"NoUse":35,"BackFlow":0,"Consumption":57171,"Unkn3":0,"Leak":1,"LeakNow":0}}

Would it may sense to only match the known fields???

type R900 struct {
    ID          uint32 `xml:",attr"` // 32 bits
    Unkn1       uint8  `xml:",attr"` // 8 bits
    NoUse       uint8  `xml:",attr"` // 6 bits, day bins of no use
    BackFlow    uint8  `xml:",attr"` // 2 bits, backflow past 35d hi/lo
    Consumption uint32 `xml:",attr"` // 24 bits
    Unkn3       uint8  `xml:",attr"` // 2 bits
    Leak        uint8  `xml:",attr"` // 4 bits, day bins of leak
    LeakNow     uint8  `xml:",attr"` // 2 bits, leak past 24h hi/lo
    checksum    [5]byte
}
bemasher commented 4 years ago

The issue is likely that determining a message is unique currently requires the checksum, which in most cases would be different if any of the unknown fields are changed. I would recommend writing your own mechanism in your collection system to ignore messages you don't want.