Skip to content

After power cycle bthome broadcasts using random bindkey #372

@agittins

Description

@agittins

After I power-cycle my LYWSD03MMC's, they start broadcasting with what I think is a randomised bindkey, not the one I had configured it with. The bindkey appears to be stored in flash OK, and works if I re-configure the bindkey, but stops working after a power-cycle.

Steps to reproduce:

  • Configure LYWSD03MMC with:

    • advertising format: BTHome
    • adv flags: on
    • encrypted: on
  • Send a bind key to the device

    • it reports it written and read OK (so looks like the flash write is good).
  • disconnect

    • homeassitant then starts receiving encrypted advertisements, and homeassistant's bthome integration decrypts them OK.
  • Remove the battery from the device for several seconds, then reinstall battery.

    • advertisements are still encrypted but homeassistant cannot decrypt them with the previously working bindkey.
  • Connect to the device

    • "read bindkey" shows correct, original bindkey.
    • "write bindkey"
    • disconnect
  • Device sends encrypted advertisements, and homeassistant can decrypt them OK.

(note: currently Homeassistant's BTHome integration has a bug where it gets stuck trying to re-auth/reconfigure the device, I'll link to the PR to fix that once I've raised it)

Guesses :-)

I notice that init_ble is called before bindkey_init but I don't know if that matters at all.

Since I can read the bindkey after a reboot it looks like the flash is working OK, but for some reason the device starts up not using the bindkey that is stored in flash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions