~aleteoryx/muditaos

619ad219d2f6bb9d52d630387ad176c7e4a0d56d — SP2FET 5 years ago f7a6b72
[EGD-4394] Add BT device name change

Added handling of BT device name changing
M module-bluetooth/Bluetooth/interface/profiles/PAN.cpp => module-bluetooth/Bluetooth/interface/profiles/PAN.cpp +4 -4
@@ 115,10 115,10 @@ namespace bluetooth
    {
        // name has to have storage
        constexpr uint32_t size = 64;
        static char lname[size] = {0};
        snprintf(lname, size, "%s %s", name.c_str(), "00:00:00:00:00:00");
        LOG_INFO("Setting local name: %s", lname);
        gap_set_local_name(lname);
        static std::array<char, size> lname;
        snprintf(lname.data(), size, "%s", name.c_str());
        LOG_INFO("Setting local name: %s", lname.data());
        gap_set_local_name(lname.data());
        return Error();
    }
    namespace PAN

M module-services/service-bluetooth/ServiceBluetooth.cpp => module-services/service-bluetooth/ServiceBluetooth.cpp +10 -0
@@ 21,6 21,8 @@
#include <utility>
#include <service-desktop/service-desktop/DesktopMessages.hpp>
#include <service-desktop/service-desktop/Constants.hpp>
#include <service-bluetooth/messages/SetDeviceName.hpp>
#include <BtCommand.hpp>

ServiceBluetooth::ServiceBluetooth() : sys::Service(service::name::bluetooth)
{


@@ 85,6 87,14 @@ sys::ReturnCodes ServiceBluetooth::InitHandler()
        return sys::MessageNone{};
    });

    connect(typeid(message::bluetooth::SetDeviceName), [&](sys::Message *msg) {
        auto setNameMsg = static_cast<message::bluetooth::SetDeviceName *>(msg);
        auto newName    = setNameMsg->getName();
        bluetooth::set_name(newName);
        settingsHolder->setValue(bluetooth::Settings::DeviceName, newName);
        return sys::MessageNone{};
    });

    connect(sdesktop::developerMode::DeveloperModeRequest(), [&](sys::Message *msg) {
        using namespace sdesktop::developerMode;
        auto req = static_cast<DeveloperModeRequest *>(msg);