helium / semtech-udp

Apache License 2.0
9 stars 8 forks source link

PUSH_DATA: don't serialize `rssis` when none #61

Closed jca-klk closed 2 years ago

jca-klk commented 2 years ago

rssis is optional and only available when the gateway supports it. When not available, do not serialize it (as JSON "null") otherwise it makes Erlang code to crash.

Code crash has been observed here, when gwmp-mux forwards a packet containing {"rssis": null}: https://github.com/helium/miner/blob/andymck/poc-grpc/src/miner_lora_light.erl#L482

erlang:trunc(packet_rssi(Packet, UseRSSIS)),

with trace: [error] <0.4614.7>@miner_lora_light:handle_packets:482 gen_server miner_lora_light terminated with reason: bad argument in call to erlang:trunc(null) in miner_lora_light:handle_packets/4 line 482 [error] <0.4614.7>@miner_lora_light:handle_packets:482 CRASH REPORT Process miner_lora_light with 0 neighbours crashed with reason: bad argument in call to erlang:trunc(null) in miner_lora_light:handle_packets/4 line 482

This fixes the crash.

lthiery commented 2 years ago

Thank you, @jca-klk !