M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +24 -18
@@ 42,9 42,12 @@
#include <service-bluetooth/service-bluetooth/messages/Status.hpp>
#include <service-bluetooth/messages/BondedDevices.hpp>
#include <service-bluetooth/messages/DeviceName.hpp>
+#include <service-bluetooth/messages/ResponseVisibleDevices.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <application-settings-new/data/ApnListData.hpp>
#include <application-settings-new/data/BondedDevicesData.hpp>
+#include <application-settings-new/data/BluetoothStatusData.hpp>
+#include <application-settings-new/data/DeviceData.hpp>
#include <application-settings-new/data/LanguagesData.hpp>
#include <application-settings-new/data/PhoneNameData.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
@@ 69,7 72,7 @@ namespace app
ApplicationSettingsNew::ApplicationSettingsNew(std::string name,
std::string parent,
StartInBackground startInBackground)
- : Application(name, parent, startInBackground)
+ : Application(std::move(name), std::move(parent), startInBackground)
{
if ((Store::GSM::SIM::SIM1 == selectedSim || Store::GSM::SIM::SIM2 == selectedSim) &&
Store::GSM::get()->sim == selectedSim) {
@@ 78,8 81,7 @@ namespace app
}
ApplicationSettingsNew::~ApplicationSettingsNew()
- {
- }
+ {}
// Invoked upon receiving data message
auto ApplicationSettingsNew::DataReceivedHandler(sys::DataMessage *msgl,
@@ 92,16 94,7 @@ namespace app
return retMsg;
}
- if (auto btMsg = dynamic_cast<BluetoothScanResultMessage *>(msgl); btMsg != nullptr) {
- auto scannedBtDevices = btMsg->devices;
- LOG_INFO("Received BT Scan message!");
-
- auto data = std::make_unique<gui::DeviceData>(scannedBtDevices);
- windowsFactory.build(this, gui::window::name::add_device);
- switchWindow(gui::window::name::add_device, gui::ShowMode::GUI_SHOW_INIT, std::move(data));
- render(gui::RefreshModes::GUI_REFRESH_FAST);
- }
- else if (auto phoneMsg = dynamic_cast<CellularNotificationMessage *>(msgl); nullptr != phoneMsg) {
+ if (auto phoneMsg = dynamic_cast<CellularNotificationMessage *>(msgl); nullptr != phoneMsg) {
selectedSim = Store::GSM::get()->selected;
if (CellularNotificationMessage::Type::SIM_READY == phoneMsg->type) {
selectedSimNumber = CellularServiceAPI::GetOwnNumber(this);
@@ 155,6 148,19 @@ namespace app
return sys::MessageNone{};
});
+ connect(typeid(::message::bluetooth::ResponseVisibleDevices), [&](sys::Message *msg) {
+ auto responseVisibleDevicesMsg = static_cast<::message::bluetooth::ResponseVisibleDevices *>(msg);
+ if (gui::window::name::add_device == getCurrentWindow()->getName() ||
+ gui::window::name::dialog_settings == getCurrentWindow()->getName()) {
+ auto visibleDevicesData = std::make_unique<gui::DeviceData>(responseVisibleDevicesMsg->getDevices());
+ if (gui::window::name::dialog_settings == getCurrentWindow()->getName()) {
+ visibleDevicesData->ignoreCurrentWindowOnStack = true;
+ }
+ switchWindow(gui::window::name::add_device, std::move(visibleDevicesData));
+ }
+ return sys::MessageNone{};
+ });
+
connect(typeid(CellularGetAPNResponse), [&](sys::Message *msg) {
if (gui::window::name::apn_settings == getCurrentWindow()->getName()) {
auto apns = dynamic_cast<CellularGetAPNResponse *>(msg);
@@ 189,11 195,11 @@ namespace app
::settings::SettingsScope::Global);
settings->registerValueChange(
::settings::SystemProperties::lockPassHash,
- [this](std::string value) { lockPassHash = utils::getNumericValue<unsigned int>(value); },
+ [this](const std::string &value) { lockPassHash = utils::getNumericValue<unsigned int>(value); },
::settings::SettingsScope::Global);
settings->registerValueChange(
::settings::Bluetooth::state,
- [this](std::string value) {
+ [this](const std::string &value) {
if (gui::window::name::bluetooth == getCurrentWindow()->getName()) {
const auto isBtOn = utils::getNumericValue<bool>(value);
auto btStatusData = std::make_unique<gui::BluetoothStatusData>(
@@ 204,7 210,7 @@ namespace app
::settings::SettingsScope::Global);
settings->registerValueChange(
::settings::Bluetooth::deviceVisibility,
- [this](std::string value) {
+ [this](const std::string &value) {
if (gui::window::name::bluetooth == getCurrentWindow()->getName()) {
const auto isVisible = utils::getNumericValue<bool>(value);
auto btStatusData = std::make_unique<gui::BluetoothStatusData>(isVisible);
@@ 346,7 352,7 @@ namespace app
{
operatorsOn = value;
LOG_DEBUG("[ApplicationSettingsNew::setOperatorsOn] to %d", operatorsOn);
- settings->setValue(settings::operators_on, std::to_string(value));
+ settings->setValue(settings::operators_on, std::to_string(static_cast<int>(value)));
}
void ApplicationSettingsNew::setVoLTEOn(bool value)
@@ 432,7 438,7 @@ namespace app
return false;
}
- return {msgState->success};
+ return msgState->success;
}
return false;
}
M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +1 -0
@@ 16,6 16,7 @@ target_sources( ${PROJECT_NAME}
PRIVATE
ApplicationSettings.cpp
models/ApnSettingsModel.cpp
+ models/BluetoothSettingsModel.cpp
models/NewApnModel.cpp
widgets/timeWidget.cpp
widgets/ChangePasscodeLockHandler.cpp
A module-apps/application-settings-new/data/BluetoothStatusData.hpp => module-apps/application-settings-new/data/BluetoothStatusData.hpp +37 -0
@@ 0,0 1,37 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <service-bluetooth/messages/Status.hpp>
+#include <SwitchData.hpp>
+
+namespace gui
+{
+ class BluetoothStatusData : public SwitchData
+ {
+ public:
+ explicit BluetoothStatusData(BluetoothStatus::State state) : state{state}
+ {}
+ explicit BluetoothStatusData(bool visibility) : visibility{visibility}
+ {}
+ BluetoothStatusData(BluetoothStatus::State state, bool visibility) : state{state}, visibility{visibility}
+ {}
+
+ [[nodiscard]] auto getState() const noexcept -> std::optional<bool>
+ {
+ if (state == BluetoothStatus::State::On) {
+ return true;
+ }
+ return false;
+ }
+ [[nodiscard]] auto getVisibility() const noexcept -> std::optional<bool>
+ {
+ return visibility;
+ }
+
+ private:
+ std::optional<BluetoothStatus::State> state{};
+ std::optional<bool> visibility{};
+ };
+} // namespace gui
A module-apps/application-settings-new/data/DeviceData.hpp => module-apps/application-settings-new/data/DeviceData.hpp +23 -0
@@ 0,0 1,23 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <SwitchData.hpp>
+
+namespace gui
+{
+ class DeviceData : public SwitchData
+ {
+ public:
+ explicit DeviceData(std::vector<Devicei> devices) : devices(std::move(devices))
+ {}
+ auto getDevices() -> const std::vector<Devicei> &
+ {
+ return devices;
+ }
+
+ private:
+ std::vector<Devicei> devices{};
+ };
+} // namespace gui
A module-apps/application-settings-new/models/BluetoothSettingsModel.cpp => module-apps/application-settings-new/models/BluetoothSettingsModel.cpp +34 -0
@@ 0,0 1,34 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BluetoothSettingsModel.hpp"
+
+#include <Constants.hpp>
+#include <service-bluetooth/messages/Status.hpp>
+#include <service-bluetooth/messages/SetStatus.hpp>
+
+BluetoothSettingsModel::BluetoothSettingsModel(app::Application *application) : application{application}
+{}
+
+void BluetoothSettingsModel::requestStatus()
+{
+ application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth);
+}
+void BluetoothSettingsModel::setStatus(bool desiredBluetoothState, bool desiredVisibility)
+{
+ BluetoothStatus status{.state = desiredBluetoothState ? BluetoothStatus::State::On : BluetoothStatus::State::Off,
+ .visibility = desiredVisibility};
+ message::bluetooth::SetStatus setStatus(status);
+ application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
+ service::name::bluetooth);
+}
+void BluetoothSettingsModel::stopScan()
+{
+ application->bus.sendUnicast(std::make_shared<BluetoothMessage>(BluetoothMessage::Request::StopScan),
+ service::name::bluetooth);
+}
+
+void BluetoothSettingsModel::setAddrForAudioProfiles(std::string addr)
+{
+ application->bus.sendUnicast(std::make_shared<BluetoothAddrMessage>(std::move(addr)), service::name::bluetooth);
+}
A module-apps/application-settings-new/models/BluetoothSettingsModel.hpp => module-apps/application-settings-new/models/BluetoothSettingsModel.hpp +25 -0
@@ 0,0 1,25 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "Application.hpp"
+
+extern "C"
+{
+#include <module-bluetooth/lib/btstack/src/btstack_util.h>
+}
+
+class BluetoothSettingsModel
+{
+ public:
+ explicit BluetoothSettingsModel(app::Application *application);
+
+ void requestStatus();
+ void setStatus(bool desiredBluetoothState, bool desiredVisibility);
+ void stopScan();
+ void setAddrForAudioProfiles(std::string addr);
+
+ private:
+ app::Application *application = nullptr;
+};
M module-apps/application-settings-new/windows/AddDeviceWindow.cpp => module-apps/application-settings-new/windows/AddDeviceWindow.cpp +18 -25
@@ 3,12 3,10 @@
#include "AddDeviceWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
+#include "application-settings-new/data/DeviceData.hpp"
#include "OptionSetting.hpp"
-#include <i18n/i18n.hpp>
-#include <utility>
-
extern "C"
{
#include <module-bluetooth/lib/btstack/src/btstack_util.h>
@@ 17,30 15,35 @@ extern "C"
namespace gui
{
- AddDeviceWindow::AddDeviceWindow(app::Application *app) : OptionWindow(app, gui::window::name::add_device)
- {}
+ AddDeviceWindow::AddDeviceWindow(app::Application *app, std::string name) : BaseSettingsWindow(app, std::move(name))
+ {
+ bluetoothSettingsModel = std::make_unique<BluetoothSettingsModel>(application);
+ }
- void AddDeviceWindow::onBeforeShow(ShowMode mode, SwitchData *data)
+ void AddDeviceWindow::onBeforeShow(ShowMode /*mode*/, SwitchData *data)
{
- if (data != nullptr) {
- auto newData = static_cast<DeviceData *>(data);
- devices = newData->getDevices();
+ const auto newData = dynamic_cast<DeviceData *>(data);
+ if (newData != nullptr) {
+ devices = newData->getDevices();
}
- rebuildOptionList();
+ refreshOptionsList();
+ }
+
+ void AddDeviceWindow::onClose()
+ {
+ bluetoothSettingsModel->stopScan();
}
- auto AddDeviceWindow::devicesOptionsList() -> std::list<gui::Option>
+ auto AddDeviceWindow::buildOptionsList() -> std::list<gui::Option>
{
std::list<gui::Option> optionsList;
for (const auto &device : devices) {
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
device.name,
- [=](gui::Item &item) {
+ [=](gui::Item & /*unused*/) {
LOG_DEBUG("Device: %s", device.name.c_str());
- application->bus.sendUnicast(std::make_shared<BluetoothAddrMessage>(bd_addr_to_str(device.address)),
- "ServiceBluetooth",
- 5000);
+ bluetoothSettingsModel->setAddrForAudioProfiles(bd_addr_to_str(device.address));
return true;
},
nullptr,
@@ 48,18 51,8 @@ namespace gui
gui::option::SettingRightItem::Bt));
}
- application->bus.sendUnicast(std::make_shared<BluetoothMessage>(BluetoothMessage::Request::StopScan),
- "ServiceBluetooth");
-
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::add));
return optionsList;
}
-
- void AddDeviceWindow::rebuildOptionList()
- {
- clearOptions();
- addOptions(devicesOptionsList());
- }
-
} // namespace gui
M module-apps/application-settings-new/windows/AddDeviceWindow.hpp => module-apps/application-settings-new/windows/AddDeviceWindow.hpp +11 -20
@@ 1,36 1,27 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
-#include "OptionWindow.hpp"
+#include "BaseSettingsWindow.hpp"
+#include "application-settings-new/ApplicationSettings.hpp"
+#include "application-settings-new/models/BluetoothSettingsModel.hpp"
-#include <service-bluetooth/BluetoothMessage.hpp>
+#include <Device.hpp>
namespace gui
{
- class AddDeviceWindow : public OptionWindow
+ class AddDeviceWindow : public BaseSettingsWindow
{
public:
- AddDeviceWindow(app::Application *app);
- void onBeforeShow(ShowMode mode, SwitchData *data) override;
+ explicit AddDeviceWindow(app::Application *app, std::string name = window::name::add_device);
private:
- auto devicesOptionsList() -> std::list<gui::Option>;
- void rebuildOptionList();
- std::vector<Devicei> devices;
- };
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
+ void onClose() override;
+ auto buildOptionsList() -> std::list<Option> override;
- class DeviceData : public SwitchData
- {
+ std::unique_ptr<BluetoothSettingsModel> bluetoothSettingsModel;
std::vector<Devicei> devices;
-
- public:
- DeviceData(std::vector<Devicei> devices) : SwitchData(), devices(std::move(devices))
- {}
- auto getDevices() -> const std::vector<Devicei> &
- {
- return devices;
- }
};
}; // namespace gui
M module-apps/application-settings-new/windows/AllDevicesWindow.cpp => module-apps/application-settings-new/windows/AllDevicesWindow.cpp +5 -5
@@ 15,6 15,7 @@
#include <service-bluetooth/BluetoothMessage.hpp>
#include <service-bluetooth/messages/BondedDevices.hpp>
#include "application-settings-new/data/BondedDevicesData.hpp"
+
namespace gui
{
@@ 43,11 44,10 @@ namespace gui
application->bus.sendUnicast(std::make_shared<BluetoothMessage>(BluetoothMessage::Request::Scan),
"ServiceBluetooth");
gui::DialogMetadata meta;
- meta.icon = "search_big";
- meta.text = utils::localize.get("app_settings_bluetooth_searching_devices");
- meta.title = utils::localize.get("app_settings_bluetooth_add_device");
- auto data = std::make_unique<gui::DialogMetadataMessage>(meta);
- data->ignoreCurrentWindowOnStack = true;
+ meta.icon = "search_big";
+ meta.text = utils::localize.get("app_settings_bluetooth_searching_devices");
+ meta.title = utils::localize.get("app_settings_bluetooth_add_device");
+ auto data = std::make_unique<gui::DialogMetadataMessage>(meta);
application->switchWindow(gui::window::name::dialog_settings, std::move(data));
return true;
}
M module-apps/application-settings-new/windows/BluetoothWindow.cpp => module-apps/application-settings-new/windows/BluetoothWindow.cpp +21 -39
@@ 2,26 2,23 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "BluetoothWindow.hpp"
-#include "application-settings-new/ApplicationSettings.hpp"
+#include "application-settings-new/data/BluetoothStatusData.hpp"
#include "OptionSetting.hpp"
-#include <service-bluetooth/Constants.hpp>
-#include <service-bluetooth/messages/Status.hpp>
-#include <service-bluetooth/messages/SetStatus.hpp>
-
namespace gui
{
- BluetoothWindow::BluetoothWindow(app::Application *app) : OptionWindow(app, gui::window::name::bluetooth)
+ BluetoothWindow::BluetoothWindow(app::Application *app, std::string name) : BaseSettingsWindow(app, std::move(name))
{
- application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth);
+ bluetoothSettingsModel = std::make_unique<BluetoothSettingsModel>(application);
+ bluetoothSettingsModel->requestStatus();
}
- void BluetoothWindow::onBeforeShow(ShowMode mode, SwitchData *data)
+ void BluetoothWindow::onBeforeShow(ShowMode /*mode*/, SwitchData *data)
{
- if (data != nullptr) {
- const auto newData = static_cast<BluetoothStatusData *>(data);
+ const auto newData = dynamic_cast<BluetoothStatusData *>(data);
+ if (newData != nullptr) {
if (const auto btState = newData->getState(); btState.has_value()) {
isBluetoothSwitchOn = btState.value();
}
@@ 29,16 26,16 @@ namespace gui
isPhoneVisibilitySwitchOn = visibility.value();
}
}
- rebuildOptionList();
+ refreshOptionsList();
}
- auto BluetoothWindow::bluetoothOptionsList() -> std::list<gui::Option>
+ auto BluetoothWindow::buildOptionsList() -> std::list<gui::Option>
{
std::list<gui::Option> optionsList;
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
utils::translateI18("app_settings_bluetooth_main"),
- [=](gui::Item &item) {
+ [=](gui::Item & /*unused*/) {
changeBluetoothState(isBluetoothSwitchOn);
return true;
},
@@ 55,7 52,7 @@ namespace gui
if (isBluetoothSwitchOn) {
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
utils::translateI18("app_settings_bluetooth_all_devices"),
- [=](gui::Item &item) {
+ [=](gui::Item & /*unused*/) {
this->application->switchWindow(gui::window::name::all_devices, gui::ShowMode::GUI_SHOW_INIT);
return true;
},
@@ 71,7 68,7 @@ namespace gui
true));
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
utils::translateI18("app_settings_bluetooth_phone_visibility"),
- [=](gui::Item &item) {
+ [=](gui::Item & /*unused*/) {
changeVisibility(isPhoneVisibilitySwitchOn);
return true;
},
@@ 87,7 84,7 @@ namespace gui
if (isPhoneVisibilitySwitchOn) {
optionsList.emplace_back(std::make_unique<gui::option::OptionSettings>(
utils::translateI18("app_settings_bluetooth_phone_name"),
- [=](gui::Item &item) {
+ [=](gui::Item & /*unused*/) {
this->application->switchWindow(gui::window::name::phone_name, gui::ShowMode::GUI_SHOW_INIT);
return true;
},
@@ 107,32 104,17 @@ namespace gui
return optionsList;
}
- void BluetoothWindow::changeBluetoothState(bool currentState)
- {
- ::message::bluetooth::SetStatus setStatus(makeDesiredStatus(!currentState, isPhoneVisibilitySwitchOn));
- application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
- service::name::bluetooth);
- }
-
- void BluetoothWindow::changeVisibility(bool currentVisibility)
- {
- ::message::bluetooth::SetStatus setStatus(makeDesiredStatus(isBluetoothSwitchOn, !currentVisibility));
- application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
- service::name::bluetooth);
- }
-
- BluetoothStatus BluetoothWindow::makeDesiredStatus(bool desiredBluetoothState, bool desiredVisibility) noexcept
+ void BluetoothWindow::changeBluetoothState(bool ¤tState)
{
- BluetoothStatus status;
- status.state = desiredBluetoothState ? BluetoothStatus::State::On : BluetoothStatus::State::Off;
- status.visibility = desiredVisibility;
- return status;
+ currentState = !currentState;
+ refreshOptionsList();
+ bluetoothSettingsModel->setStatus(currentState, isPhoneVisibilitySwitchOn);
}
- void BluetoothWindow::rebuildOptionList()
+ void BluetoothWindow::changeVisibility(bool ¤tVisibility)
{
- clearOptions();
- addOptions(bluetoothOptionsList());
+ currentVisibility = !currentVisibility;
+ refreshOptionsList();
+ bluetoothSettingsModel->setStatus(isBluetoothSwitchOn, currentVisibility);
}
-
} // namespace gui
M module-apps/application-settings-new/windows/BluetoothWindow.hpp => module-apps/application-settings-new/windows/BluetoothWindow.hpp +11 -44
@@ 3,58 3,25 @@
#pragma once
-#include <OptionWindow.hpp>
-#include <service-bluetooth/BluetoothMessage.hpp>
+#include "application-settings-new/ApplicationSettings.hpp"
+#include "application-settings-new/models/BluetoothSettingsModel.hpp"
+#include "BaseSettingsWindow.hpp"
namespace gui
{
- class BluetoothWindow : public OptionWindow
+ class BluetoothWindow : public BaseSettingsWindow
{
public:
- BluetoothWindow(app::Application *app);
- void onBeforeShow(ShowMode mode, SwitchData *data) override;
+ explicit BluetoothWindow(app::Application *app, std::string name = window::name::bluetooth);
private:
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
+ auto buildOptionsList() -> std::list<Option> override;
+ void changeBluetoothState(bool ¤tState);
+ void changeVisibility(bool ¤tVisibility);
+
+ std::unique_ptr<BluetoothSettingsModel> bluetoothSettingsModel;
bool isBluetoothSwitchOn = false;
bool isPhoneVisibilitySwitchOn = false;
- auto bluetoothOptionsList() -> std::list<gui::Option>;
- void changeBluetoothState(bool currentState);
- void changeVisibility(bool currentVisibility);
- void rebuildOptionList();
-
- static BluetoothStatus makeDesiredStatus(bool desiredBluetoothState, bool desiredVisibility) noexcept;
- };
-
- class BluetoothStatusData : public SwitchData
- {
- public:
- explicit BluetoothStatusData(BluetoothStatus::State state) : state{state}
- {}
- explicit BluetoothStatusData(bool visibility) : visibility{visibility}
- {}
- BluetoothStatusData(BluetoothStatus::State state, bool visibility) : state{state}, visibility{visibility}
- {}
-
- [[nodiscard]] auto getState() const noexcept -> std::optional<bool>
- {
- if (!state.has_value()) {
- return std::nullopt;
- }
- if (state == BluetoothStatus::State::On) {
- return true;
- }
- return false;
- }
- [[nodiscard]] auto getVisibility() const noexcept -> std::optional<bool>
- {
- if (!visibility.has_value()) {
- return std::nullopt;
- }
- return visibility;
- }
-
- private:
- std::optional<BluetoothStatus::State> state;
- std::optional<bool> visibility;
};
} // namespace gui
M module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp => module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp +2 -1
@@ 5,6 5,7 @@
#include <log/log.hpp>
#include <service-bluetooth/BluetoothMessage.hpp>
+#include <service-bluetooth/messages/ResponseVisibleDevices.hpp>
extern "C"
{
@@ 78,7 79,7 @@ namespace bluetooth
void GAP::sendDevices()
{
- auto msg = std::make_shared<BluetoothScanResultMessage>(devices);
+ auto msg = std::make_shared<message::bluetooth::ResponseVisibleDevices>(devices);
ownerService->bus.sendUnicast(msg, "ApplicationSettings");
ownerService->bus.sendUnicast(std::move(msg), "ApplicationSettingsNew");
}
M module-services/service-bluetooth/service-bluetooth/messages/BondedDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/BondedDevices.hpp +4 -4
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
@@ 13,7 13,7 @@ namespace message::bluetooth
class ResponseBondedDevices : public BluetoothMessage
{
public:
- ResponseBondedDevices(std::vector<Devicei> devices) : devices(std::move(devices))
+ explicit ResponseBondedDevices(std::vector<Devicei> devices) : devices(std::move(devices))
{}
[[nodiscard]] auto getDevices() const -> std::vector<Devicei>
{
M module-services/service-bluetooth/service-bluetooth/messages/DeviceName.hpp => module-services/service-bluetooth/service-bluetooth/messages/DeviceName.hpp +3 -3
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
M module-services/service-bluetooth/service-bluetooth/messages/ResponseVisibleDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/ResponseVisibleDevices.hpp +4 -4
@@ 1,16 1,16 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
class ResponseVisibleDevices : public BluetoothMessage
{
public:
- ResponseVisibleDevices(std::vector<Devicei> devices) : devices(std::move(devices))
+ explicit ResponseVisibleDevices(std::vector<Devicei> devices) : devices(std::move(devices))
{}
[[nodiscard]] auto getDevices() const -> std::vector<Devicei>
{
M module-services/service-bluetooth/service-bluetooth/messages/SetBondedDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetBondedDevices.hpp +4 -4
@@ 1,16 1,16 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
class SetBondedDevices : public BluetoothMessage
{
public:
- SetBondedDevices(std::vector<Devicei> devices) : devices(std::move(devices))
+ explicit SetBondedDevices(std::vector<Devicei> devices) : devices(std::move(devices))
{}
[[nodiscard]] auto getDevices() const -> std::vector<Devicei>
{
M module-services/service-bluetooth/service-bluetooth/messages/SetDeviceName.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetDeviceName.hpp +3 -3
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
M module-services/service-bluetooth/service-bluetooth/messages/SetScanState.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetScanState.hpp +4 -3
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
@@ 20,3 20,4 @@ namespace message::bluetooth
private:
bool state;
};
+} // namespace message::bluetooth
M module-services/service-bluetooth/service-bluetooth/messages/SetStatus.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetStatus.hpp +4 -4
@@ 1,16 1,16 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
class SetStatus : public BluetoothMessage
{
public:
- SetStatus(BluetoothStatus status) : status(std::move(status))
+ explicit SetStatus(BluetoothStatus status) : status(status)
{}
[[nodiscard]] auto getStatus() const noexcept -> BluetoothStatus
{
M module-services/service-bluetooth/service-bluetooth/messages/Status.hpp => module-services/service-bluetooth/service-bluetooth/messages/Status.hpp +4 -4
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <Service/Message.hpp>
+#pragma once
+
#include "service-bluetooth/BluetoothMessage.hpp"
-#include <string>
namespace message::bluetooth
{
@@ 14,7 14,7 @@ namespace message::bluetooth
class ResponseStatus : public BluetoothMessage
{
public:
- explicit ResponseStatus(BluetoothStatus status) : status(std::move(status))
+ explicit ResponseStatus(BluetoothStatus status) : status(status)
{}
[[nodiscard]] auto getStatus() const noexcept -> BluetoothStatus
{