M image/assets/lang/English.json => image/assets/lang/English.json +2 -0
@@ 27,6 27,7 @@
"common_abort": "ABORT",
"common_connect": "CONNECT",
"common_disconnect": "DISCONNECT",
+ "common_forget": "FORGET",
"common_mo": "MO",
"common_tu": "TU",
"common_we": "WE",
@@ 325,6 326,7 @@
"app_settings_bluetooth_enter_passkey": "Enter passkey:",
"app_settings_bluetooth_init_error_message": "<text font='gt_pressura' weight='regular' size='27'>Bluetooth initialization process \nhas failed. </text> <text font='gt_pressura' weight='bold' size='27'>TRY AGAIN.</text>",
"app_settings_bluetooth_pairing_error_message": "<text font='gt_pressura' weight='regular' size='27'>Pairing process with</text> <text font='gt_pressura' weight='bold' size='27'>%NAME</text>\n<text font='gt_pressura' weight='regular' size='27'>has failed. Check the device\nand</text> <text font='gt_pressura' weight='bold' size='27'>TRY AGAIN.</text>",
+ "app_settings_bluetooth_unpairing_error_message": "<text font='gt_pressura' weight='regular' size='27'>Unpairing process has failed.\nCheck the device and</text> <text font='gt_pressura' weight='bold' size='27'>TRY AGAIN.</text>",
"app_settings_bluetooth_connecting_error_message": "<text font='gt_pressura' weight='regular' size='27'>Connection process has failed.\nCheck the device and</text> <text font='gt_pressura' weight='bold' size='27'>TRY AGAIN.</text>",
"app_settings_net": "Network",
"app_settings_disp_key": "Display and keypad",
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +23 -0
@@ 49,6 49,7 @@
#include <service-bluetooth/messages/DeviceName.hpp>
#include <service-bluetooth/messages/Passkey.hpp>
#include <service-bluetooth/messages/ResponseVisibleDevices.hpp>
+#include <service-bluetooth/messages/Unpair.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <application-settings-new/data/ApnListData.hpp>
#include <application-settings-new/data/BondedDevicesData.hpp>
@@ 205,6 206,28 @@ namespace app
return sys::MessageNone{};
});
+ connect(typeid(::message::bluetooth::UnpairResult), [&](sys::Message *msg) {
+ auto unpairResultMsg = static_cast<::message::bluetooth::UnpairResult *>(msg);
+ if (unpairResultMsg->isSucceed()) {
+ return sys::MessageNone{};
+ }
+ bus.sendUnicast(std::make_shared<::message::bluetooth::RequestBondedDevices>(), service::name::bluetooth);
+ switchWindow(gui::window::name::dialog_retry,
+ gui::ShowMode::GUI_SHOW_INIT,
+ std::make_unique<gui::DialogMetadataMessage>(
+ gui::DialogMetadata{utils::localize.get("app_settings_bt"),
+ "search_big",
+ utils::localize.get("app_settings_bluetooth_unpairing_error_message"),
+ "",
+ [=]() -> bool {
+ bus.sendUnicast(std::make_shared<message::bluetooth::Unpair>(
+ unpairResultMsg->getAddr()),
+ service::name::bluetooth);
+ return true;
+ }}));
+ return sys::MessageNone{};
+ });
+
connect(typeid(::message::bluetooth::ConnectResult), [&](sys::Message *msg) {
auto connectResultMsg = static_cast<::message::bluetooth::ConnectResult *>(msg);
if (connectResultMsg->isSucceed()) {
M module-apps/application-settings-new/models/BluetoothSettingsModel.cpp => module-apps/application-settings-new/models/BluetoothSettingsModel.cpp +8 -1
@@ 12,6 12,7 @@
#include <service-bluetooth/messages/SetStatus.hpp>
#include <service-bluetooth/messages/SetDeviceName.hpp>
#include <service-bluetooth/messages/Passkey.hpp>
+#include <service-bluetooth/messages/Unpair.hpp>
BluetoothSettingsModel::BluetoothSettingsModel(app::Application *application) : application{application}
{}
@@ 59,11 60,17 @@ void BluetoothSettingsModel::stopScan()
service::name::bluetooth);
}
-void BluetoothSettingsModel::requestDevicePairing(std::string addr)
+void BluetoothSettingsModel::requestDevicePair(std::string addr)
{
application->bus.sendUnicast(std::make_shared<BluetoothPairMessage>(std::move(addr)), service::name::bluetooth);
}
+void BluetoothSettingsModel::requestDeviceUnpair(std::string addr)
+{
+ application->bus.sendUnicast(std::make_shared<message::bluetooth::Unpair>(std::move(addr)),
+ service::name::bluetooth);
+}
+
void BluetoothSettingsModel::responsePasskey(std::string passkey)
{
application->bus.sendUnicast(std::make_shared<message::bluetooth::ResponsePasskey>(std::move(passkey)),
M module-apps/application-settings-new/models/BluetoothSettingsModel.hpp => module-apps/application-settings-new/models/BluetoothSettingsModel.hpp +2 -1
@@ 22,7 22,8 @@ class BluetoothSettingsModel
void requestBondedDevices();
void requestScan();
void stopScan();
- void requestDevicePairing(std::string addr);
+ void requestDevicePair(std::string addr);
+ void requestDeviceUnpair(std::string addr);
void responsePasskey(std::string passkey);
void requestConnection(std::string addr);
void requestDisconnection();
M module-apps/application-settings-new/windows/AddDeviceWindow.cpp => module-apps/application-settings-new/windows/AddDeviceWindow.cpp +1 -1
@@ 43,7 43,7 @@ namespace gui
device.name,
[=](gui::Item & /*unused*/) {
LOG_DEBUG("Device: %s", device.name.c_str());
- bluetoothSettingsModel->requestDevicePairing(bd_addr_to_str(device.address));
+ bluetoothSettingsModel->requestDevicePair(bd_addr_to_str(device.address));
application->switchWindow(gui::window::name::all_devices);
return true;
},
M module-apps/application-settings-new/windows/AllDevicesWindow.cpp => module-apps/application-settings-new/windows/AllDevicesWindow.cpp +18 -1
@@ 50,7 50,10 @@ namespace gui
auto AllDevicesWindow::onInput(const InputEvent &inputEvent) -> bool
{
- if (inputEvent.isShortPress() && inputEvent.is(KeyCode::KEY_LEFT)) {
+ if (!inputEvent.isShortPress()) {
+ return AppWindow::onInput(inputEvent);
+ }
+ if (inputEvent.is(KeyCode::KEY_LEFT)) {
bluetoothSettingsModel->requestScan();
application->switchWindow(gui::window::name::dialog_settings,
gui::ShowMode::GUI_SHOW_INIT,
@@ 60,6 63,17 @@ namespace gui
utils::localize.get("app_settings_bluetooth_searching_devices")}));
return true;
}
+ if (inputEvent.is(KeyCode::KEY_LF)) {
+ devices.erase(std::remove_if(devices.begin(),
+ devices.end(),
+ [&](const auto &device) {
+ return (bd_addr_to_str(device.address) == addressOfSelectedDevice);
+ }),
+ devices.end());
+ refreshOptionsList();
+ bluetoothSettingsModel->requestDeviceUnpair(addressOfSelectedDevice);
+ return true;
+ }
return AppWindow::onInput(inputEvent);
}
@@ 81,6 95,9 @@ namespace gui
this->setBottomBarText(isConnected ? utils::translateI18("common_disconnect")
: utils::translateI18("common_connect"),
BottomBar::Side::CENTER);
+ this->setBottomBarText(utils::translateI18("common_forget"), BottomBar::Side::LEFT);
+ this->bottomBar->setActive(BottomBar::Side::LEFT, true);
+ addressOfSelectedDevice = addr;
}
return true;
},
M module-apps/application-settings-new/windows/AllDevicesWindow.hpp => module-apps/application-settings-new/windows/AllDevicesWindow.hpp +1 -0
@@ 24,6 24,7 @@ namespace gui
Image *crossImage = nullptr;
std::vector<Devicei> devices;
std::string addressOfConnectedDevice;
+ std::string addressOfSelectedDevice;
std::unique_ptr<BluetoothSettingsModel> bluetoothSettingsModel;
};
M module-services/service-bluetooth/service-bluetooth/messages/BondedDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/BondedDevices.hpp +1 -1
@@ 16,7 16,7 @@ namespace message::bluetooth
explicit ResponseBondedDevices(std::vector<Devicei> devices, std::string addressOfConnectedDevice)
: devices(std::move(devices)), addressOfConnectedDevice(std::move(addressOfConnectedDevice))
{}
- [[nodiscard]] auto getDevices() const -> std::vector<Devicei>
+ [[nodiscard]] auto getDevices() const noexcept -> std::vector<Devicei>
{
return devices;
}
M module-services/service-bluetooth/service-bluetooth/messages/Connect.hpp => module-services/service-bluetooth/service-bluetooth/messages/Connect.hpp +3 -3
@@ 12,7 12,7 @@ namespace message::bluetooth
public:
explicit Connect(std::string addr) : addr(std::move(addr))
{}
- [[nodiscard]] auto getAddr() const -> std::string
+ [[nodiscard]] auto getAddr() const noexcept -> std::string
{
return addr;
}
@@ 26,11 26,11 @@ namespace message::bluetooth
public:
explicit ConnectResult(std::string addr, bool succeed) : addr(std::move(addr)), succeed(succeed)
{}
- [[nodiscard]] auto getAddr() const -> std::string
+ [[nodiscard]] auto getAddr() const noexcept -> std::string
{
return addr;
}
- [[nodiscard]] auto isSucceed() const -> bool
+ [[nodiscard]] auto isSucceed() const noexcept -> bool
{
return succeed;
}
M module-services/service-bluetooth/service-bluetooth/messages/DeviceName.hpp => module-services/service-bluetooth/service-bluetooth/messages/DeviceName.hpp +1 -1
@@ 15,7 15,7 @@ namespace message::bluetooth
public:
explicit ResponseDeviceName(std::string name) : name(std::move(name))
{}
- [[nodiscard]] auto getName() const -> std::string
+ [[nodiscard]] auto getName() const noexcept -> std::string
{
return name;
}
M module-services/service-bluetooth/service-bluetooth/messages/Passkey.hpp => module-services/service-bluetooth/service-bluetooth/messages/Passkey.hpp +1 -1
@@ 15,7 15,7 @@ namespace message::bluetooth
public:
explicit ResponsePasskey(std::string passkey) : passkey(std::move(passkey))
{}
- [[nodiscard]] auto getPasskey() const -> std::string
+ [[nodiscard]] auto getPasskey() const noexcept -> std::string
{
return passkey;
}
M module-services/service-bluetooth/service-bluetooth/messages/ResponseVisibleDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/ResponseVisibleDevices.hpp +1 -1
@@ 12,7 12,7 @@ namespace message::bluetooth
public:
explicit ResponseVisibleDevices(std::vector<Devicei> devices) : devices(std::move(devices))
{}
- [[nodiscard]] auto getDevices() const -> std::vector<Devicei>
+ [[nodiscard]] auto getDevices() const noexcept -> std::vector<Devicei>
{
return devices;
}
M module-services/service-bluetooth/service-bluetooth/messages/SetBondedDevices.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetBondedDevices.hpp +1 -1
@@ 12,7 12,7 @@ namespace message::bluetooth
public:
explicit SetBondedDevices(std::vector<Devicei> devices) : devices(std::move(devices))
{}
- [[nodiscard]] auto getDevices() const -> std::vector<Devicei>
+ [[nodiscard]] auto getDevices() const noexcept -> std::vector<Devicei>
{
return devices;
}
M module-services/service-bluetooth/service-bluetooth/messages/SetDeviceName.hpp => module-services/service-bluetooth/service-bluetooth/messages/SetDeviceName.hpp +1 -1
@@ 13,7 13,7 @@ namespace message::bluetooth
public:
explicit SetDeviceName(std::string name) : name(std::move(name))
{}
- [[nodiscard]] auto getName() const -> std::string
+ [[nodiscard]] auto getName() const noexcept -> std::string
{
return name;
}
A module-services/service-bluetooth/service-bluetooth/messages/Unpair.hpp => module-services/service-bluetooth/service-bluetooth/messages/Unpair.hpp +42 -0
@@ 0,0 1,42 @@
+// 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/BluetoothMessage.hpp"
+
+namespace message::bluetooth
+{
+ class Unpair : public BluetoothMessage
+ {
+ public:
+ explicit Unpair(std::string addr) : addr(std::move(addr))
+ {}
+ [[nodiscard]] auto getAddr() const -> std::string
+ {
+ return addr;
+ }
+
+ private:
+ std::string addr;
+ };
+
+ class UnpairResult : public BluetoothMessage
+ {
+ public:
+ explicit UnpairResult(std::string addr, bool succeed) : addr(std::move(addr)), succeed(succeed)
+ {}
+ [[nodiscard]] auto getAddr() const noexcept -> std::string
+ {
+ return addr;
+ }
+ [[nodiscard]] auto isSucceed() const noexcept -> bool
+ {
+ return succeed;
+ }
+
+ private:
+ std::string addr;
+ bool succeed;
+ };
+} // namespace message::bluetooth