chirpstack / chirpstack-gateway-bridge

ChirpStack Gateway Bridge abstracts Packet Forwarder protocols into Protobuf or JSON over MQTT.
https://www.chirpstack.io
MIT License
423 stars 270 forks source link

Care an empty string value that is contained in RXPK as `time` property #82

Closed moznion closed 6 years ago

moznion commented 6 years ago

Some vendor's (e.g. gemtek) gateway sends an empty string value as time property of Rx packet (an empty string means "ignore me", this is terrible...) In the current implementation, the gateway-bridge raises errors at here when an empty time has come so it cannot receive any packets if time is an empty string.

This pull-request cares this problem.

brocaar commented 6 years ago

Thanks for working on this! I'm not sure if it is worth all the effort when the actual implementation error is at the side of the gateway vendor (empty string instead of null). If you do a:

func (t *CompactTime) UnmarshalJSON(data []byte) error {
    if string(data) == `""` {
        return nil
    }
    ...

It would at least solve the error (resulting probably in a 0001-01-01 ... timestamp), without the need to add extra complexity :-) Note that such timestamp does not break any functionality.

It might also be worth to contact Gemtek about this, hopefully they can fix this at their side too :-)

moznion commented 6 years ago

Thank you for your response and suggestions!

This commit (fa83519fdb249e22c83f50909e37ab67185fc7e4) fixes simpler, is this correct? Are following changes not necessary?