InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.76k stars 944 forks source link

[help needed] weather service CBOR decode issue #1159

Closed ITCactus closed 2 years ago

ITCactus commented 2 years ago

Verification

What happened?

CBOR decode issue in weather service

What should happen instead?

No response

Reproduction steps

using this source https://codeberg.org/ITCactus/Gadgetbridge/src/branch/pinetime-infinitime-weather-support build and install "Gadgetbridge"; pair with PineTime/InfiniTime; open "Debug" menu, and click "Test new functionality" button; check logcat logs.

you should see something like this: I/nodomain.freeyourgadget.gadgetbridge.service.devices.pinetime.PineTimeJFSupport: onTestNewFunction: null D/nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue: about to add: 16:56:46: Transaction task: send weather info with 1 actions D/nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue: About to run action: May 27, 16:56: WriteAction on characteristic: 00040001-78fc-48fe-8e23-433b3a1942d0 D/nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction: writing to characteristic: 00040001-78fc-48fe-8e23-433b3a1942d0: 0xa4 0x69 0x54 0x69 0x6d 0x65 0x73 0x74 0x61 0x6d 0x70 0x1a 0x62 0x90 0xe6 0xae 0x67 0x45 0x78 0x70 0x69 0x72 0x65 0x73 0x19 0x03 0xe8 0x69 0x45 0x76 0x65 0x6e 0x74 0x54 0x79 0x70 0x65 0x08 0x66 0x41 0x6d 0x6f 0x75 0x6e 0x74 0x01 D/nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue: characteristic write: 00040001-78fc-48fe-8e23-433b3a1942d0 (failed: 13) D/nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue: failed btle action, aborting transaction: 00040001-78fc-48fe-8e23-433b3a1942d0 (failed: 13)

More details?

the "0xa4 0x69 0x54 0x69 0x6d 0x65 0x73 0x74 0x61 0x6d 0x70 0x1a 0x62 0x90 0xe6 0xae 0x67 0x45 0x78 0x70 0x69 0x72 0x65 0x73 0x19 0x03 0xe8 0x69 0x45 0x76 0x65 0x6e 0x74 0x54 0x79 0x70 0x65 0x08 0x66 0x41 0x6d 0x6f 0x75 0x6e 0x74 0x01" means {"Timestamp": 1653663406, "Expires": 1000, "EventType": 8, "Amount": 1} there is attempt to send a "Clouds" info with amount "1%" and can be decoded/verified with cbor.me service here. it's a valid format like expected by the service - fixed-length map with preserved the order of map entries.

hoverer service fails to parse the data here and CBOR return an error 34, that corresponds to

/* When finding an item by lablel, an item with the requested label was not found. / QCBOR_ERR_LABEL_NOT_FOUND = 34,

not sure WHY it can NOT find the "Expires" label as it should be there and in the correct order, especially when the first one "Timestamp" is successfully recognized and parsed.

on Android/Java side the CBOR library used this one, because it can preserve the order of map entries, AND unlike jackson-dataformats-binary-cbor support fixed-length map.

Version

1.9.0 or develop

Companion app

Gadgetbridge from special branch

ITCactus commented 2 years ago

ok, requesting the max MTU on device initialization from Gadgetbridge solved this particular issue

// request max MTU. PineTime will probably negotiate the 256 if (GBApplication.isRunningLollipopOrLater()) { builder.requestMtu(512); }

now the service accept the data... however i don't see it in the Weather app on InfiniTime... for some reason timeline was unable to return the data here... and the same for all Weather screens (Temperature/Air quality/Clouds/Precipitation/Humidity). not sure if it related somehow to the issue #1049

i leave this for some experienced devs, taking into account, that for me that was a huge success to setup environment to play with borrowed jlink into run-and-debug code on InfiniTime =)