M image/assets/lang/English.json => image/assets/lang/English.json +1 -0
@@ 321,6 321,7 @@
"app_settings_bluetooth_phone_name": "Phone name",
"app_settings_bluetooth_phone_visibility": "Phone visibility",
"app_settings_bluetooth_enter_passkey": "Enter passkey:",
+ "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_net": "Network",
"app_settings_disp_key": "Display and keypad",
"app_settings_display_display_light": "Display light",
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +26 -1
@@ 36,11 36,13 @@
#include "windows/ChangeDateAndTimeWindow.hpp"
#include "Dialog.hpp"
+#include "DialogMetadataMessage.hpp"
#include <service-evtmgr/EventManagerServiceAPI.hpp>
#include <service-cellular/CellularServiceAPI.hpp>
#include <service-bluetooth/BluetoothMessage.hpp>
-#include <service-bluetooth/service-bluetooth/messages/Status.hpp>
+#include <service-bluetooth/Constants.hpp>
+#include <service-bluetooth/messages/Status.hpp>
#include <service-bluetooth/messages/BondedDevices.hpp>
#include <service-bluetooth/messages/DeviceName.hpp>
#include <service-bluetooth/messages/ResponseVisibleDevices.hpp>
@@ 166,6 168,29 @@ namespace app
return sys::MessageNone{};
});
+ connect(typeid(BluetoothPairResultMessage), [&](sys::Message *msg) {
+ auto bluetoothPairResultMsg = static_cast<BluetoothPairResultMessage *>(msg);
+ if (bluetoothPairResultMsg->status) {
+ return sys::MessageNone{};
+ }
+ const std::string toReplace = "%NAME";
+ std::string pairingErrorMessage = utils::localize.get("app_settings_bluetooth_pairing_error_message");
+ pairingErrorMessage.replace(
+ pairingErrorMessage.find(toReplace), toReplace.size(), bluetoothPairResultMsg->name);
+
+ 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", pairingErrorMessage, "", [=]() -> bool {
+ bus.sendUnicast(std::make_shared<BluetoothPairMessage>(std::move(bluetoothPairResultMsg->addr)),
+ service::name::bluetooth);
+ return true;
+ }}));
+
+ return sys::MessageNone{};
+ });
+
connect(typeid(CellularGetAPNResponse), [&](sys::Message *msg) {
if (gui::window::name::apn_settings == getCurrentWindow()->getName()) {
auto apns = dynamic_cast<CellularGetAPNResponse *>(msg);
M module-apps/application-settings-new/models/BluetoothSettingsModel.cpp => module-apps/application-settings-new/models/BluetoothSettingsModel.cpp +5 -0
@@ 60,3 60,8 @@ void BluetoothSettingsModel::setAddrForAudioProfiles(std::string addr)
{
application->bus.sendUnicast(std::make_shared<BluetoothAddrMessage>(std::move(addr)), service::name::bluetooth);
}
+
+void BluetoothSettingsModel::requestDevicePairing(std::string addr)
+{
+ application->bus.sendUnicast(std::make_shared<BluetoothPairMessage>(std::move(addr)), service::name::bluetooth);
+}
M module-apps/application-settings-new/models/BluetoothSettingsModel.hpp => module-apps/application-settings-new/models/BluetoothSettingsModel.hpp +1 -0
@@ 22,6 22,7 @@ class BluetoothSettingsModel
void requestBondedDevices();
void requestScan();
void stopScan();
+ void requestDevicePairing(std::string addr);
void setAddrForAudioProfiles(std::string addr);
private:
M module-apps/application-settings-new/windows/AddDeviceWindow.cpp => module-apps/application-settings-new/windows/AddDeviceWindow.cpp +1 -0
@@ 44,6 44,7 @@ namespace gui
[=](gui::Item & /*unused*/) {
LOG_DEBUG("Device: %s", device.name.c_str());
bluetoothSettingsModel->setAddrForAudioProfiles(bd_addr_to_str(device.address));
+ bluetoothSettingsModel->requestDevicePairing(bd_addr_to_str(device.address));
return true;
},
nullptr,
M module-apps/application-settings-new/windows/AllDevicesWindow.cpp => module-apps/application-settings-new/windows/AllDevicesWindow.cpp +0 -1
@@ 51,7 51,6 @@ namespace gui
{
if (inputEvent.isShortPress() && inputEvent.is(KeyCode::KEY_LEFT)) {
bluetoothSettingsModel->requestScan();
- gui::DialogMetadata meta;
application->switchWindow(gui::window::name::dialog_settings,
gui::ShowMode::GUI_SHOW_INIT,
std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{
M module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp => module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp +4 -3
@@ 193,10 193,11 @@ namespace bluetooth
}
continueScanning();
}
- void GAP::processDedicatedBondingCompleted(std::uint8_t *packet)
+ void GAP::processDedicatedBondingCompleted(std::uint8_t *packet, bd_addr_t &addr)
{
auto result = packet[2];
- auto msg = std::make_shared<BluetoothPairResultMessage>(result == 0u);
+ auto name = std::string{reinterpret_cast<const char *>(&packet[9])};
+ auto msg = std::make_shared<BluetoothPairResultMessage>(bd_addr_to_str(addr), name, result == 0u);
ownerService->bus.sendUnicast(msg, "ApplicationSettings");
ownerService->bus.sendUnicast(std::move(msg), "ApplicationSettingsNew");
}
@@ 225,7 226,7 @@ namespace bluetooth
processNameRequestComplete(packet, addr);
break;
case GAP_EVENT_DEDICATED_BONDING_COMPLETED:
- processDedicatedBondingCompleted(packet);
+ processDedicatedBondingCompleted(packet, addr);
break;
default:
break;
M module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.hpp => module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.hpp +1 -1
@@ 40,7 40,7 @@ namespace bluetooth
static void processInquiryResult(std::uint8_t *packet, bd_addr_t &addr);
static void processInquiryComplete();
static void processNameRequestComplete(std::uint8_t *packet, bd_addr_t &addr);
- static void processDedicatedBondingCompleted(std::uint8_t *packet);
+ static void processDedicatedBondingCompleted(std::uint8_t *packet, bd_addr_t &addr);
static void initStateHandler(std::uint8_t eventType, std::uint8_t *packet);
public:
M module-services/service-bluetooth/service-bluetooth/BluetoothMessage.hpp => module-services/service-bluetooth/service-bluetooth/BluetoothMessage.hpp +4 -2
@@ 56,9 56,11 @@ class BluetoothScanResultMessage : public sys::DataMessage
class BluetoothPairResultMessage : public sys::DataMessage
{
public:
+ std::string addr;
+ std::string name;
bool status;
- explicit BluetoothPairResultMessage(bool status)
- : sys::DataMessage(MessageType::BluetoothPairResult), status(status){};
+ explicit BluetoothPairResultMessage(std::string addr, std::string name, bool status)
+ : sys::DataMessage(MessageType::BluetoothPairResult), addr(addr), name(name), status(status){};
};
class BluetoothScanMessage : public sys::DataMessage