Skip to content

Commit f96c5cb

Browse files
committed
Fix bluetooth setting not actually changing bluetooth radio settings.
The bluetooth setting options for changing between Enabled and Disabled wasn't actually turning the bluetooth radio on and off.
1 parent 264b5be commit f96c5cb

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/displayapp/DisplayApp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
522522
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(settingsController, motionController, *systemTask);
523523
break;
524524
case Apps::SettingBluetooth:
525-
currentScreen = std::make_unique<Screens::SettingBluetooth>(this, settingsController);
525+
currentScreen = std::make_unique<Screens::SettingBluetooth>(this, settingsController, bleController);
526526
break;
527527
case Apps::BatteryInfo:
528528
currentScreen = std::make_unique<Screens::BatteryInfo>(batteryController);

src/displayapp/screens/settings/SettingBluetooth.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,25 @@ namespace {
3434
};
3535
}
3636

37-
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
37+
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController, const Pinetime::Controllers::Ble& bleController)
3838
: app {app},
3939
checkboxList(
4040
0,
4141
1,
4242
"Bluetooth",
4343
Symbols::bluetooth,
44-
settingsController.GetBleRadioEnabled() ? 0 : 1,
45-
[&settings = settingsController](uint32_t index) {
46-
const bool priorMode = settings.GetBleRadioEnabled();
47-
const bool newMode = options[index].radioEnabled;
48-
if (newMode != priorMode) {
49-
settings.SetBleRadioEnabled(newMode);
44+
bleController.IsRadioEnabled() ? 0 : 1,
45+
[&settings = settingsController, ble = bleController](uint32_t index) mutable {
46+
// If bluetooth is on and the user chooses to turn it off
47+
if (ble.IsRadioEnabled() && !options[index].radioEnabled && options[index].name[0] == 'D') {
48+
ble.DisableRadio();
49+
// Not sure if this is needed, leaving incase it's used elsewhere
50+
settings.SetBleRadioEnabled(false);
51+
// If bluetooth is off and the user chooses to turn it on
52+
} else if (!ble.IsRadioEnabled() && options[index].radioEnabled && options[index].name[0] == 'E'){
53+
ble.EnableRadio();
54+
// Not sure if this is needed, leaving incase it's used elsewhere
55+
settings.SetBleRadioEnabled(true);
5056
}
5157
},
5258
CreateOptionArray()) {

src/displayapp/screens/settings/SettingBluetooth.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <lvgl/lvgl.h>
66

77
#include "components/settings/Settings.h"
8+
#include "components/ble/BleController.h"
89
#include "displayapp/screens/Screen.h"
910
#include "displayapp/screens/CheckboxList.h"
1011

@@ -15,7 +16,7 @@ namespace Pinetime {
1516

1617
class SettingBluetooth : public Screen {
1718
public:
18-
SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
19+
SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, const Pinetime::Controllers::Ble& bleController);
1920
~SettingBluetooth() override;
2021

2122
private:

0 commit comments

Comments
 (0)