chirpstack-api
chirpstack-api copied to clipboard
uplinkID in UplinkRXInfo is parsed wrong as json
What happened?
When I try to connect with MQTT on my C# program and then want to read on the topic "application/123/device/+/event/up
and parse the received bytes as UTF-8 string and then parse it with the google protobuf parser, then I get the following exception:
Google.Protobuf.InvalidProtocolBufferException: Invalid base64 data ---> System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
It happens on this field: gw.UplinkRXInfo.uplink_id
with this data: d902040a-4859-41e3-aacc-a3f79de22e12
Steps to reproduce this issue
C# example:
string json = @"{""applicationID"":""4"",""applicationName"":""WetterStation"",""deviceName"":""0XXXXXXXXXXXX"",""devEUI"":""0101010101010101"",""rxInfo"":[{""gatewayID"":""1234567889141422"",""uplinkID"":""d902040a-4859-41e3-aacc-a3f79de22e12"",""name"":""XXXXXXXXXXXXX"",""time"":""2021-07-27T18:19:23.776381Z"",""rssi"":-106,""loRaSNR"":4,""location"":{""latitude"":54.31039,""longitude"":9.66927,""altitude"":228}},{""gatewayID"":""0000000000000000"",""uplinkID"":""11740492-1111-2222-3333-44444444444"",""name"":""xxxxxxxxxxx"",""time"":""2021-07-27T18:19:23.778124Z"",""rssi"":-114,""loRaSNR"":2,""location"":{""latitude"":0.00000,""longitude"":0.00000,""altitude"":43}}],""txInfo"":{""frequency"":868100000,""dr"":5},""adr"":false,""fCnt"":8706,""fPort"":1,""data"":""dGVzdA=="",""object"":{""Counter"":[299],""Voltage"":[3.406]}}";
UplinkEvent.Parser.ParseJson(json);
Steps to solve it:
When serializing the UplinkEvent in the application server it should parse it as base64 OR make gw.UplinkRXInfo.uplink_id a string:
In gw.proto:
string uplink_id = 16 [json_name = "uplinkID"];