Gadgetbridge can be configured to perform an action when a
Huami device is taken off or the user was detected to fall asleep or
wake up. This functionality was specific to Huami devices, but this
changeset moves this upstream to the AbstractDeviceSupport class in
combination with new GBDeviceEvents.
Now that the ADS has centralized support for this functionality, the
same logic can be used for other devices. In this case, an
implementation is added for supported Xiaomi devices.
Works:
- notifications
- call notification
- set time
- setting brightness
- setting 24h/12h format
- sending weather
Note
- this is implemented using using the classic bluetooth serial protocol, the
device can do BLE, but I don't know how to use it, as I did not have the
offical app to sniff.
- The information about the protocol comes from here
https://github.com/jfroehlich/node-p1x3lramen/blob/main/source/devices/pixoo.js
TODO:
- Enable beep? Possible? I heard it beep once at least when switching it on
- Getting out of factory mode? Why does it always play animations even when I
switch to the clock?
- Implement switching modes (can be done with the button)
- Implement sending own images and animations
- Firmware update?
- ...
Because the reporting of battery state is inconsistent between different
models, the device's battery state was not correctly processed in GB.
For at least the firmware on the Xiaomi Watch S1 Active, the charger
state is broadcast through a separate message from the message
containing the battery level. Even though the battery level was
requested by GB upon receiving this broadcast, the charger state got
discarded as it was expected to also be included in the result of the
subsequent request.
This patch changes the name of the `Charger` message to `DeviceState`
and includes more fields that may be presented by some device models.
Furthemore, the broadcast is cached so that the charger state can be
processed from this cache instead of the battery level response message.