M changelog.md => changelog.md +1 -0
@@ 11,6 11,7 @@
* `[PowerManagement]` PowerManagement: Enable FreeRTOS Run Time Statistics
* `[cellular]` USSD session handling.
* `[settings]` Nightshift window - GUI.
+* `[bluetooth][settings]` Add Bluetooth settings to database.
### Changed
M image/user/db/settings_v2_002.sql => image/user/db/settings_v2_002.sql +5 -1
@@ 13,4 13,8 @@ INSERT OR REPLACE INTO settings_tab (path, value) VALUES
('gs_lock_pass_hash', '3333'),
('gs_lock_time', '30000'),
('gs_display_language', 'En'),
- ('gs_input_language', 'En');
+ ('gs_input_language', 'En'),
+ ('bt_state', '0'),
+ ('bt_device_visibility', '0'),
+ ('bt_device_name', 'PurePhone'),
+ ('bt_bonded_devices', '');
M module-services/service-bluetooth/ServiceBluetooth.cpp => module-services/service-bluetooth/ServiceBluetooth.cpp +36 -1
@@ 12,13 12,16 @@
#include <MessageType.hpp>
#include <Service/Service.hpp>
#include <Service/Message.hpp>
+#include <agents/settings/SystemSettings.hpp>
+#include <service-db/Settings.hpp>
#include <log/log.hpp>
#include <bits/exception.h>
#include <utility>
-ServiceBluetooth::ServiceBluetooth() : sys::Service(service::name::bluetooth)
+ServiceBluetooth::ServiceBluetooth()
+ : sys::Service(service::name::bluetooth), settingsProvider(std::make_unique<settings::Settings>(this))
{
LOG_INFO("[ServiceBluetooth] Initializing");
}
@@ 34,6 37,14 @@ sys::ReturnCodes ServiceBluetooth::InitHandler()
{
LOG_ERROR("Bluetooth experimental!");
worker = std::make_unique<BluetoothWorker>(this);
+ settingsProvider->registerValueChange(settings::Bluetooth::state,
+ [this](std::string value) { stateSettingChanged(value); });
+ settingsProvider->registerValueChange(settings::Bluetooth::deviceVisibility,
+ [this](std::string value) { deviceVisibilitySettingChanged(value); });
+ settingsProvider->registerValueChange(settings::Bluetooth::deviceName,
+ [this](std::string value) { deviceNameSettingChanged(value); });
+ settingsProvider->registerValueChange(settings::Bluetooth::bondedDevices,
+ [this](std::string value) { bondedDevicesSettingChanged(value); });
return sys::ReturnCodes::Success;
}
@@ 123,3 134,27 @@ sys::ReturnCodes ServiceBluetooth::SwitchPowerModeHandler(const sys::ServicePowe
LOG_ERROR("TODO");
return sys::ReturnCodes::Success;
}
+
+void ServiceBluetooth::stateSettingChanged(std::string value)
+{
+ LOG_DEBUG("Received new bt_state: %s", value.c_str());
+ settingsProvider->unregisterValueChange(settings::Bluetooth::state);
+}
+
+void ServiceBluetooth::deviceVisibilitySettingChanged(std::string value)
+{
+ LOG_DEBUG("Received new bt_device_visibility: %s", value.c_str());
+ settingsProvider->unregisterValueChange(settings::Bluetooth::deviceVisibility);
+}
+
+void ServiceBluetooth::deviceNameSettingChanged(std::string value)
+{
+ LOG_DEBUG("Received new bt_device_name: %s", value.c_str());
+ settingsProvider->unregisterValueChange(settings::Bluetooth::deviceName);
+}
+
+void ServiceBluetooth::bondedDevicesSettingChanged(std::string value)
+{
+ LOG_DEBUG("Received new bt_bonded_devices: %s", value.c_str());
+ settingsProvider->unregisterValueChange(settings::Bluetooth::bondedDevices);
+}
M module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp => module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp +10 -0
@@ 11,6 11,10 @@
#include <memory> // for unique_ptr
class BluetoothWorker;
+namespace settings
+{
+ class Settings;
+}
class ServiceBluetooth : public sys::Service
{
@@ 26,4 30,10 @@ class ServiceBluetooth : public sys::Service
private:
std::unique_ptr<BluetoothWorker> worker;
+ std::unique_ptr<settings::Settings> settingsProvider;
+
+ void stateSettingChanged(std::string value);
+ void deviceVisibilitySettingChanged(std::string value);
+ void deviceNameSettingChanged(std::string value);
+ void bondedDevicesSettingChanged(std::string value);
};
M module-services/service-db/agents/settings/SystemSettings.hpp => module-services/service-db/agents/settings/SystemSettings.hpp +20 -9
@@ 3,13 3,24 @@
#pragma once
-namespace settings::SystemProperties
+namespace settings
{
- constexpr inline auto timeFormat12 = "gs_time_format_12";
- constexpr inline auto timeDateFormat = "gs_time_date_format";
- constexpr inline auto activeSim = "gs_active_sim";
- constexpr inline auto lockPassHash = "gs_lock_pass_hash";
- constexpr inline auto lockTime = "gs_lock_time";
- constexpr inline auto displayLanguage = "gs_display_language";
- constexpr inline auto inputLanguage = "gs_input_language";
-}; // namespace settings::SystemProperties
+ namespace SystemProperties
+ {
+ constexpr inline auto timeFormat12 = "gs_time_format_12";
+ constexpr inline auto timeDateFormat = "gs_time_date_format";
+ constexpr inline auto activeSim = "gs_active_sim";
+ constexpr inline auto lockPassHash = "gs_lock_pass_hash";
+ constexpr inline auto lockTime = "gs_lock_time";
+ constexpr inline auto displayLanguage = "gs_display_language";
+ constexpr inline auto inputLanguage = "gs_input_language";
+ } // namespace SystemProperties
+ namespace Bluetooth
+ {
+ constexpr inline auto state = "bt_state";
+ constexpr inline auto deviceVisibility = "bt_device_visibility";
+ constexpr inline auto deviceName = "bt_device_name";
+ constexpr inline auto bondedDevices = "bt_bonded_devices";
+ } // namespace Bluetooth
+
+}; // namespace settings