theengs / app

Theengs mobile application to read BLE sensors and push data to an MQTT broker
https://app.theengs.io
GNU General Public License v3.0
38 stars 6 forks source link

Assigned MAC addresses get cleared when closing and reopening the app #52

Closed DigiH closed 1 year ago

DigiH commented 2 years ago

Assigned MAC addresses get cleared when closing the app and opening it again, verified on macOS and iOS 1.2

This requires any MAC addresses to be entered again for all devices to be able to get functioning published MQTT messages again.

The assigned MAC addresses need to be persistent across app restarts.

DigiH commented 1 year ago

Likely related to https://github.com/theengs/app/issues/58 as the MAC addresses are also in the database, but not being repopulated (either in the UI, nor for MQTT publishing) when App is reopened.

DigiH commented 1 year ago

Closing as verified with the latest build as fixed.

Opening the app immediately populates the locations, and also the previously saved MAC addresses are there for all devices. 👍

emericg commented 1 year ago

By the way, it might be a nice addition to the decoder to have it parse and expose the sensor's MAC addresses, if available in the advertisement data. That way, there wouldn't be any need to fill that MAC field manually. I already do that for sensors that have an existing WatchFlower implementation, but it might be useful to generalize that.

Kind of https://github.com/theengs/decoder/issues/89, but the other way around.

DigiH commented 1 year ago

I'm not quite sure what you mean by

parse and expose the sensor's MAC addresses

Decoder does get the MAC address from the project, Theengs App, OpenMQTTGateway, Theengs Gateway etc. and doesn't need to send it back because of that - each project already having the "id" key and property.

How would you want it to be additionally exposed?

emericg commented 1 year ago

With the macOS and iOS Bluetooth stack, you don't have access to the MAC addresses, so the ID field of the decoder is filled only with "equivalent" UUIDs.

For instance with the FlowerCare sensors, you do need the actual MAC to interact with the devices for longer than a second, it's part of its handshake process. So they put the MACs in the advertising data (https://github.com/emericg/WatchFlower/blob/master/docs/mibeacon-ble-api.md#protocol-version-0x70), so their iOS app can have the same features than their Android app. So for these devices, you could add a mac field/property in the decoder.

DigiH commented 1 year ago

MAC property added in branch https://github.com/theengs/decoder/tree/mac_property

Needing more device decoder updates for devices known to have their MAC address in broadcast data.