InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.63k stars 901 forks source link

Fix bluetooth setting : emit the radio toggle message only if the value of the setting changed #2037

Closed JF002 closed 3 months ago

JF002 commented 3 months ago

Emit the message BleRadioEnableToggle to DisplayApp only if the enable state of the radio has actually changed.

This fixes an issue where the BLE connected logo would disappear when opening and closing the BLE setting (without changing it) while InfiniTime was already connected to a companion app.

This fix is based on the work done by @JustScott in #1972 and also thanks to the very detailed description of the issue by @rambonette in #1961.

I think this fix makes more sense since we do not actually need to call NimbleController::EnableRadio() again if the radio was previously enabled and need to stay enabled.

This change also removed the need to send the message in SettingBluetooth::~SettingBluetooth() by capturing this in the lambda (which is called in CheckboxList::~CheckboxList() which is destroyed before SettingBluetooth.

What do think about this @JustScott?

Fixes #1961.

github-actions[bot] commented 3 months ago
Build size and comparison to main: Section Size Difference
text 377384B 0B
data 940B 0B
bss 63540B 0B
rambonette commented 3 months ago

Glad to help! Wish I had more time to tackle these problems myself 😵‍💫

JustScott commented 3 months ago

Glad I could help @JF002! Your solution address the issue at its core and works great on my pinetime!