Commit Graph
13 Commits
Author SHA1 Message Date
jrthomas270andJosé Rebelo b114fe1bd0 Even Realities G1: More connection Reliability
This change aims to improve the connection reliability on Even Realities
G1. It has a few changes:
 1. Fixed a bug in MultiBLEDeviceSupport where if one devices "fails" to
    connect because it is already connected, the other devices would be
    skipped over.
 2. Take the ConectionMonitor lock in G1 Device support when one of the
    devices being disconnected is being handled, this prevents
    reconnection or double disconnects overlapping leading to unexpected
    state.
 3. Add a hack when one side disconnects so that the global state of the
    sub devices never passes through NOT_CONNECTED and instead moves
    right from CONNECTED to WAITING_FOR_RECONNECT. This prevents the the
    doubling of reconnection delay multiple times resulting in full 64
    seconds reconnect attempts.
 4. When one device disconnects, both BLE queues are now explicitly
    disconnected. Previously just the device state was changed, which
    meant reconnection was not always reliable.
 5. Made the heart beat delay dynamic, when android low power mode kicks
    in, the system may only check the timer expiration every 20 seconds.
    Previously to get around this, the delay was set to a fixed 8
    seconds, but this uses additional power when not in low power mode.
    Now the thread will check the system added delay based on the time
    since the last heartbeat and will schedule dymaically based on that.
    The minimum delay is still 8 seconds, but now when batter saver is
    not enabled, the delay will change to 25 seconds.
 6. Fixed some nullptr exceptions when handling the device disconnection
    when one device is not yet connected.
2025-10-19 14:53:51 +02:00
jrthomas270 7ee1f67c54 Even Realities G1: Fix offby one in new BLE name support
It seems like I didn't actually redeploy the app to my phone when
testing my previous change, so I was actually testing the old code
(which works with my particular device name). After rebuilding for
sure with the new code, I didn't get the indexOf offsets correct.
This fixes the bug introduced by the previous change.
2025-10-11 16:40:06 -07:00
jrthomas270andJosé Rebelo 39918f74ab Even Realities G1: Improve Connection Reliability
This change fixes several things:
  1. Update the logic for 3 state related functions for MultiBLEDevice
     so they now take into account all sub devices.
  2. Fix several race condidtions in the initialization logic. This
     fixes one lens permenantly not being connected.
  3. Add a callback when one of the devicess diconnects to put the
     both sides of the lens into WAITING_FOR_RECONNECT state.
  4. Decrease the heartbeat sleep to 8 seconds. Since Android Deep sleep
     can add upwards to 20 seconds to the sleep time, this means most
     heartbeats will be sent every 28 seconds.
  5. Fixed a bug in the per-side state when the device was disconnected
     without the SideManager object being destroyed which lead to the
     full initialization process not being followed on reconnection.
2025-10-11 23:52:59 +02:00
jrthomas270 8e7dc26078 Even Realities G1: Support More BLE Device Names
Some glasses have shown up that have the format G1_X_L instead of the
previously expecte G1_XX_L. Update the regex so it can support any
number of digits in that position.
2025-10-11 13:03:35 -07:00
jrthomas270andJosé Rebelo eec87ab89c Even Realities G1: Move Packet Sequence Generation to the shared space
Previously, each side of the glasses had it's own sequence number, after
longer periods of time, these numbers would go out of sync and the
glasses would crash because the values are expected to be the same. Now
there is a single sequence number, and packets that are sent to both
lenses will now share the same sequence number. The heartbeat runner is
also moved to the shared space so that the time outs of the BLE
connections do not get skewed.
2025-10-04 20:25:42 +02:00
jrthomas270 b10669d933 Even Realities G1: Handle MTU change as the device expects
The Glasses expect a notification when the MTU chagnes, so forward the
new MTU value to the glasses.
2025-10-04 10:48:30 -07:00
jrthomas270 e8f7a1fad3 Even Realities G1: Remove baterry polling
The glasses periodically transmit their battery state, since that is
supported now, use that instead of requesting the battery info
periodically.
2025-10-04 09:53:59 -07:00
jrthomas270andJosé Rebelo d6daab8d0d Even Realites G1: Support Notifications and improve disconnections
This change helps improve the connection experience when GadgetBridge is
working as a background task. The glasses must be send a heartbeat
packet every 32 seconds, otherwise they will disconnect. When
GadgetBridge is running in the background there is a 15-20 second delay
between the background handler waking up. This means that when the wake
up time is sceduled for 30 seconds, it often won't be woken up for 45-50
seconds leading to almost immediate disconnect after the user turns off
the screen. The official app gets around this by using a 5 second delay
leading to ~25 seconds of delay in sleep mode, but this over sends when
the phone is awake. Instead of doing that, I maintain the 28 second
delay but I change the background thread to a higher priority so that it
more consistently wakes up within th 32 second BLE limit.

Also added support for Notifications being sent to the glasses.
2025-08-10 22:34:56 +02:00
jrthomas270andJosé Rebelo 85f01ee6ca Even Realities G1: Support more things
Add support for:
 - Charging status
 - Battery level of the case
 - Fetching Serial Number
 - Parsing hardware information from serial number
 - Add Hard Reset button
 - Toggle for device level debug logging
 - Bug Fix: kill heartbeat worker on disconnect
 - Weather
 - Toggle for 12H/24H time
 - Set the dashboard to minimal on connection
2025-06-04 23:22:54 +02:00
jrthomas270andJosé Rebelo 7021804db5 Even Realities G1: Add Settings menu and silent mode toggle
This change adds in a toggle for "silent mode" which turns the displays
off and makes the glasses act like normal glasses.

This change also adds the following configuration settings:
 - Screen Location/height
 - Screen Depth Effect
 - Head Tilt Activation Angle
 - Toggle Auto Brightness
 - Brightness Level
 - Wear Detection

Also refactored Communications file to have a consistent naming style.
2025-05-26 21:43:19 +02:00
jrthomas270andJosé Rebelo 616e8977c6 Support Even Realities G1 Glasses as a Single Device
This change switches G1DeviceSupport from managing to individual devices
to using AbstractBTLEMultiDeviceSupport which allows it to manage both
BLE connections under a single support class. This also updates the
Pairing activity to make it much more reliable at bonding and pairing
both devices.
2025-05-11 15:26:37 +00:00
jrthomas270 9d8f54ff17 Add multi channel BLE device abstract classes
This change adds a class that mirrors AbstractBTLEDeviceSupport, except
that it holds and arrays of bluetooth queues instead of just one. This
allows a single GBDevice to be composited into a single DeviceSupport
class. This is useful if there is a gadget that has multiple bluetooth
radios, but the gadget is a single device. It could also be useful if
multiple gadgets were to be grouped under a single Device (such as a
display and a remote), this way the support class can access both
devices fully without having to send messages or it can aggregate calls
to things like onNotification and make sure it is sent to all devices.

My main goal is to add support for the Even Realities G1 Smart Glasses
which use two BLE radios (one for each lens of the glasses). This code
is quite well tested on the following branch:
2025-03-02 09:06:05 -08:00
jrthomas270andJosé Rebelo 2d6a7d3866 Even Realities: Add initial support for Even G1 Smart Glasses (#4553)
Co-authored-by: jrthomas270 <jrthomas270@noreply.codeberg.org>
Co-committed-by: jrthomas270 <jrthomas270@noreply.codeberg.org>
2025-02-02 16:59:39 +00:00