Skip to content

Scale can boot awake with BLE disabled after charging or square-button wake #42

@KarlDavidRosen

Description

@KarlDavidRosen

Hi, I noticed a BLE discovery/reconnect issue that appears to come from the firmware startup path.

In src/hds.ino, BLE is only enabled when GPIO_power_on_with == BUTTON_CIRCLE or GPIO_power_on_with == -1:

if (GPIO_power_on_with == BUTTON_CIRCLE)
  b_ble_enabled = true;
else {
  //power on by button_square/battery_charging
  b_ble_enabled = false;
}

if (GPIO_power_on_with == -1) {
  //power on by serial port
  b_ble_enabled = true;
}

if (b_ble_enabled) {
  ble_init();
}

Because the BATTERY_CHARGING and BUTTON_SQUARE wake paths set b_ble_enabled = false, the scale can be awake but not advertising BLE. From a client/app perspective this looks like unreliable BLE discovery or failed reconnect, but the device is simply not advertising.

Expected behavior:
The scale should advertise BLE whenever it is awake and intended to be controllable by app/scale clients, or there should be a clear explicit setting/mode for BLE-disabled startup.

Observed behavior:
After charging wake or square-button wake, the scale may be awake but absent from BLE scans until it is started via the circle button or another path that calls ble_init().

Related reconnect concern:
In include/ble.h, advertising is restarted directly inside onDisconnect() with delay(100) and pAdvertising->start(). The source comment itself suggests using a restartAdvertising flag and restarting advertising from loop(), which may be safer and more reliable.

Suggested changes:

Enable BLE on normal awake startup regardless of wake source, unless BLE has been explicitly disabled by a user setting.
Move advertising restart out of the disconnect callback into the main loop using a flag.
Optionally document whether square-button/charging wake is intentionally supposed to be BLE-disabled.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions