~aleteoryx/muditaos

bc4d32c7d8717eebd9e2eb7b1e91ac535eb363e9 — Piotr Tański 5 years ago 8204cba
[EGD-5158] Change access to the bus methods

The bus is now accessible only via Service object.
95 files changed, 821 insertions(+), 830 deletions(-)

M module-apps/Application.cpp
M module-apps/Application.hpp
M module-apps/application-alarm-clock/ApplicationAlarmClock.cpp
M module-apps/application-antenna/ApplicationAntenna.cpp
M module-apps/application-calendar/ApplicationCalendar.cpp
M module-apps/application-desktop/ApplicationDesktop.cpp
M module-apps/application-desktop/widgets/PinLockHandler.cpp
M module-apps/application-desktop/windows/DesktopMainWindow.cpp
M module-apps/application-desktop/windows/Update.cpp
M module-apps/application-messages/ApplicationMessages.cpp
M module-apps/application-notes/ApplicationNotes.cpp
M module-apps/application-phonebook/ApplicationPhonebook.cpp
M module-apps/application-settings-new/ApplicationSettings.cpp
M module-apps/application-settings-new/models/ApnSettingsModel.cpp
M module-apps/application-settings-new/models/LanguagesModel.cpp
M module-apps/application-settings-new/windows/AddDeviceWindow.cpp
M module-apps/application-settings-new/windows/AllDevicesWindow.cpp
M module-apps/application-settings-new/windows/BluetoothWindow.cpp
M module-apps/application-settings-new/windows/DisplayLightWindow.cpp
M module-apps/application-settings-new/windows/PhoneNameWindow.cpp
M module-apps/application-settings/ApplicationSettings.cpp
M module-apps/application-settings/windows/BtScanWindow.cpp
M module-apps/application-settings/windows/BtWindow.cpp
M module-apps/application-settings/windows/ColorTestWindow.cpp
M module-apps/application-settings/windows/EinkModeWindow.cpp
M module-apps/application-settings/windows/Fota.cpp
M module-apps/application-settings/windows/Fota.hpp
M module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp
M module-bluetooth/Bluetooth/interface/profiles/GAP.cpp
M module-bluetooth/Bluetooth/interface/profiles/HSP/HSP.cpp
M module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.cpp
M module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.hpp
M module-bsp/bsp/battery-charger/battery_charger.hpp
M module-cellular/Modem/ATParser.cpp
M module-cellular/Modem/TS0710/TS0710.cpp
M module-services/service-antenna/ServiceAntenna.cpp
M module-services/service-antenna/api/AntennaServiceAPI.cpp
M module-services/service-appmgr/Controller.cpp
M module-services/service-appmgr/model/ApplicationManager.cpp
M module-services/service-audio/AudioServiceAPI.cpp
M module-services/service-audio/ServiceAudio.cpp
M module-services/service-bluetooth/ServiceBluetooth.cpp
M module-services/service-cellular/CellularRequestHandler.cpp
M module-services/service-cellular/CellularServiceAPI.cpp
M module-services/service-cellular/CellularUrcHandler.cpp
M module-services/service-cellular/ServiceCellular.cpp
M module-services/service-db/DBServiceAPI.cpp
M module-services/service-db/DBServiceAPI_GetByQuery.cpp
M module-services/service-db/ServiceDB.cpp
M module-services/service-db/agents/file_indexer/FileIndexerAgent.cpp
M module-services/service-db/agents/settings/Settings.cpp
M module-services/service-db/agents/settings/SettingsAgent.cpp
M module-services/service-db/service-db/DBServiceAPI.hpp
M module-services/service-db/test/test-service-db-settings-messages.cpp
M module-services/service-db/test/test-settings/test-service-db-settings-api.cpp
M module-services/service-db/test/test-settings/test-service-db-settings-testapps.hpp
M module-services/service-db/test/test-settings/test-service-db-settings-testservices.hpp
M module-services/service-desktop/ServiceDesktop.cpp
M module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp
M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp
M module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp
M module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp
M module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp
M module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp
M module-services/service-eink/ServiceEink.cpp
M module-services/service-evtmgr/EventManager.cpp
M module-services/service-evtmgr/WorkerEvent.cpp
M module-services/service-evtmgr/alarm/EventManagerAlarm.cpp
M module-services/service-evtmgr/api/EventManagerServiceAPI.cpp
M module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.cpp
M module-services/service-fileindexer/ServiceFileIndexer.cpp
M module-services/service-fileindexer/StartupIndexer.cpp
M module-services/service-fota/FotaServiceAPI.cpp
M module-services/service-fota/ServiceFota.cpp
M module-services/service-gui/ServiceGUI.cpp
M module-services/service-gui/WorkerGUI.cpp
M module-services/service-lwip/ServiceLwIP.cpp
M module-services/service-time/ServiceTime.cpp
M module-sys/CMakeLists.txt
D module-sys/Service/Bus.cpp
D module-sys/Service/Bus.hpp
A module-sys/Service/BusProxy.cpp
A module-sys/Service/BusProxy.hpp
D module-sys/Service/Channel.hpp
M module-sys/Service/Common.hpp
M module-sys/Service/Message.cpp
M module-sys/Service/Message.hpp
M module-sys/Service/Service.cpp
M module-sys/Service/Service.hpp
M module-sys/Service/Timer.cpp
A module-sys/Service/details/bus/Bus.cpp
A module-sys/Service/details/bus/Bus.hpp
M module-sys/SystemManager/SystemManager.cpp
M module-sys/SystemManager/SystemManager.hpp
M module-utils/state/ServiceState.hpp
M module-apps/Application.cpp => module-apps/Application.cpp +14 -16
@@ 77,7 77,7 @@ namespace app
          settings(std::make_unique<settings::Settings>(this))
    {
        topBarManager->enableIndicators({gui::top_bar::Indicator::Time});
        busChannels.push_back(sys::BusChannels::ServiceCellularNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);

        longPressTimer = std::make_unique<sys::Timer>("LongPress", this, key_timer_ms);
        longPressTimer->connect([&](sys::Timer &) { longPressTimerCallback(); });


@@ 146,7 146,7 @@ namespace app
            else if (suspendInProgress) {
                message->setCommandType(service::gui::DrawMessage::Type::SUSPEND);
            }
            sys::Bus::SendUnicast(std::move(message), service::name::gui, this);
            bus.sendUnicast(std::move(message), service::name::gui);
        }

        if (suspendInProgress)


@@ 171,12 171,12 @@ namespace app
            window = getCurrentWindow()->getName();
            auto msg =
                std::make_shared<AppSwitchWindowMessage>(window, getCurrentWindow()->getName(), std::move(data), cmd);
            sys::Bus::SendUnicast(msg, this->GetName(), this);
            bus.sendUnicast(msg, this->GetName());
        }
        else {
            auto msg = std::make_shared<AppSwitchWindowMessage>(
                windowName, getCurrentWindow() ? getCurrentWindow()->getName() : "", std::move(data), cmd);
            sys::Bus::SendUnicast(msg, this->GetName(), this);
            bus.sendUnicast(msg, this->GetName());
        }
    }



@@ 195,7 195,7 @@ namespace app
    {
        if (not windowsStack.isEmpty()) {
            auto msg = std::make_shared<AppRefreshMessage>(mode, getCurrentWindow()->getName());
            sys::Bus::SendUnicast(msg, this->GetName(), this);
            bus.sendUnicast(msg, this->GetName());
        }
    }



@@ 549,10 549,8 @@ namespace app
    {
        using namespace bsp;

        auto retGetState = sys::Bus::SendUnicast(std::make_shared<sevm::TorchStateMessage>(torch::Action::getState),
                                                 service::name::evt_manager,
                                                 this,
                                                 pdMS_TO_TICKS(1500));
        auto message     = std::make_shared<sevm::TorchStateMessage>(torch::Action::getState);
        auto retGetState = bus.sendUnicast(std::move(message), service::name::evt_manager, pdMS_TO_TICKS(1500));
        if (retGetState.first == sys::ReturnCodes::Success) {
            auto msgGetState = dynamic_cast<sevm::TorchStateResultMessage *>(retGetState.second.get());
            if (msgGetState == nullptr) {


@@ 569,7 567,7 @@ namespace app
                msgSetState->state = torch::State::off;
                break;
            }
            sys::Bus::SendUnicast(msgSetState, service::name::evt_manager, this);
            bus.sendUnicast(msgSetState, service::name::evt_manager);
        }
    }



@@ 579,7 577,7 @@ namespace app
                                    manager::actions::ActionParamsPtr &&data)
    {
        auto msg = std::make_shared<AppActionRequest>(actionId, std::move(data));
        sys::Bus::SendUnicast(msg, applicationName, sender);
        sender->bus.sendUnicast(msg, applicationName);
    }

    void Application::messageSwitchApplication(sys::Service *sender,


@@ 588,26 586,26 @@ namespace app
                                               std::unique_ptr<gui::SwitchData> data)
    {
        auto msg = std::make_shared<AppSwitchMessage>(application, window, std::move(data));
        sys::Bus::SendUnicast(msg, application, sender);
        sender->bus.sendUnicast(msg, application);
    }

    void Application::messageCloseApplication(sys::Service *sender, std::string application)
    {

        auto msg = std::make_shared<AppMessage>(MessageType::AppClose);
        sys::Bus::SendUnicast(msg, application, sender);
        sender->bus.sendUnicast(msg, application);
    }

    void Application::messageRebuildApplication(sys::Service *sender, std::string application)
    {
        auto msg = std::make_shared<AppRebuildMessage>();
        sys::Bus::SendUnicast(msg, application, sender);
        sender->bus.sendUnicast(msg, application);
    }

    void Application::messageApplicationLostFocus(sys::Service *sender, std::string application)
    {
        auto msg = std::make_shared<AppLostFocusMessage>();
        sys::Bus::SendUnicast(msg, application, sender);
        sender->bus.sendUnicast(msg, application);
    }

    void Application::messageInputEventApplication(sys::Service *sender,


@@ 615,7 613,7 @@ namespace app
                                                   const gui::InputEvent &event)
    {
        auto msg = std::make_shared<AppInputEventMessage>(event);
        sys::Bus::SendUnicast(msg, application, sender);
        sender->bus.sendUnicast(msg, application);
    }

    bool Application::popToWindow(const std::string &window)

M module-apps/Application.hpp => module-apps/Application.hpp +0 -1
@@ 7,7 7,6 @@
#include "Audio/AudioCommon.hpp"                        // for Volume, Play...
#include "Audio/Profiles/Profile.hpp"                   // for Profile, Pro...
#include "CallbackStorage.hpp"
#include "Service/Bus.hpp"                              // for Bus
#include "Service/Common.hpp"                           // for ReturnCodes
#include "Service/Message.hpp"                          // for MessagePointer
#include "Service/Service.hpp"                          // for Service

M module-apps/application-alarm-clock/ApplicationAlarmClock.cpp => module-apps/application-alarm-clock/ApplicationAlarmClock.cpp +1 -1
@@ 23,7 23,7 @@ namespace app
                                                 sys::ServicePriority priority)
        : Application(name, parent, false, stackDepth, priority)
    {
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
    }

    sys::MessagePointer ApplicationAlarmClock::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)

M module-apps/application-antenna/ApplicationAntenna.cpp => module-apps/application-antenna/ApplicationAntenna.cpp +1 -2
@@ 37,8 37,7 @@ namespace app
    ApplicationAntenna::ApplicationAntenna(std::string name, std::string parent, StartInBackground startInBackground)
        : Application(name, parent, startInBackground, 4096 * 2)
    {
        busChannels.push_back(sys::BusChannels::AntennaNotifications);
        busChannels.push_back(sys::BusChannels::AntennaNotifications);
        bus.channels.push_back(sys::BusChannel::AntennaNotifications);
        appTimer = std::make_unique<sys::Timer>("Antena", this, 2000);
        appTimer->connect([=](sys::Timer &) { timerHandler(); });
        appTimer->start();

M module-apps/application-calendar/ApplicationCalendar.cpp => module-apps/application-calendar/ApplicationCalendar.cpp +1 -1
@@ 49,7 49,7 @@ namespace app
                                             sys::ServicePriority priority)
        : Application(name, parent, startInBackground, stackDepth, priority)
    {
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
        addActionReceiver(manager::actions::ShowReminder, [this](auto &&data) {
            switchWindow(style::window::calendar::name::event_reminder_window, std::move(data));
            return msgHandled();

M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +5 -6
@@ 44,7 44,7 @@ namespace app
                                         Indicator::Battery,
                                         Indicator::SimCard,
                                         Indicator::NetworkAccessTechnology});
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);

        addActionReceiver(app::manager::actions::RequestPin, [this](auto &&data) {
            lockHandler.handlePasscodeRequest(gui::PinLock::LockType::SimPin, std::move(data));


@@ 169,7 169,7 @@ namespace app
        if (event != nullptr) {
            auto event = std::make_unique<sdesktop::developerMode::ScreenlockCheckEvent>(lockHandler.isScreenLocked());
            auto msg   = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
            sys::Bus::SendUnicast(std::move(msg), service::name::service_desktop, this);
            bus.sendUnicast(std::move(msg), service::name::service_desktop);
        }

        return true;


@@ 240,9 240,8 @@ namespace app
                return true;
            }
            else if (need_sim_select == false) {
                sys::Bus::SendUnicast(std::make_shared<CellularRequestMessage>(MessageType::CellularSimProcedure),
                                      ServiceCellular::serviceName,
                                      this);
                bus.sendUnicast(std::make_shared<CellularRequestMessage>(MessageType::CellularSimProcedure),
                                ServiceCellular::serviceName);
            }
        }
        if (msg->request == cellular::State::ST::ModemFatalFailure) {


@@ 327,7 326,7 @@ namespace app

        auto msgToSend =
            std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateCheckForUpdateOnce);
        sys::Bus::SendUnicast(msgToSend, service::name::service_desktop, this);
        bus.sendUnicast(msgToSend, service::name::service_desktop);

        settings->registerValueChange(
            settings::SystemProperties::activeSim,

M module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/application-desktop/widgets/PinLockHandler.cpp +5 -6
@@ 173,8 173,7 @@ namespace gui
    {
        if (type == PinLock::LockType::SimPin) {
            setSimLockHandled();
            sys::Bus::SendUnicast(
                std::make_shared<CellularSimPinDataMessage>(simLock.sim, passcode), serviceCellular, app);
            app->bus.sendUnicast(std::make_shared<CellularSimPinDataMessage>(simLock.sim, passcode), serviceCellular);
        }
        else if (type == PinLock::LockType::SimPuk) {
            handlePasscodeChange(passcode);


@@ 213,12 212,12 @@ namespace gui
    {
        setSimLockHandled();
        if (type == PinLock::LockType::SimPin) {
            sys::Bus::SendUnicast(
                std::make_shared<CellularSimNewPinDataMessage>(simLock.sim, passcode, pin), serviceCellular, app);
            app->bus.sendUnicast(std::make_shared<CellularSimNewPinDataMessage>(simLock.sim, passcode, pin),
                                 serviceCellular);
        }
        else if (type == PinLock::LockType::SimPuk) {
            sys::Bus::SendUnicast(
                std::make_shared<CellularSimPukDataMessage>(simLock.sim, passcode, pin), serviceCellular, app);
            app->bus.sendUnicast(std::make_shared<CellularSimPukDataMessage>(simLock.sim, passcode, pin),
                                 serviceCellular);
        }
    }


M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +2 -4
@@ 109,8 109,7 @@ namespace gui
            setFocusItem(nullptr);
            buildNotifications(app);

            sys::Bus::SendUnicast(
                std::make_shared<TimersProcessingStopMessage>(), service::name::service_time, application);
            application->bus.sendUnicast(std::make_shared<TimersProcessingStopMessage>(), service::name::service_time);
        }
        else {
            if (!buildNotifications(app)) {


@@ 122,8 121,7 @@ namespace gui
                app::manager::Controller::sendAction(application, app::manager::actions::SelectSimCard);
            }

            sys::Bus::SendUnicast(
                std::make_shared<TimersProcessingStartMessage>(), service::name::service_time, application);
            application->bus.sendUnicast(std::make_shared<TimersProcessingStartMessage>(), service::name::service_time);
        }
        application->refreshWindow(RefreshModes::GUI_REFRESH_FAST);
    }

M module-apps/application-desktop/windows/Update.cpp => module-apps/application-desktop/windows/Update.cpp +1 -1
@@ 228,7 228,7 @@ namespace gui
                percentLabel->setVisible(true);
                percentLabel->setText(utils::localize.get("app_desktop_update_start"));
                auto msgToSend = std::make_shared<sdesktop::UpdateOsMessage>(updateFile.c_str(), 0);
                sys::Bus::SendUnicast(msgToSend, service::name::service_desktop, application);
                application->bus.sendUnicast(msgToSend, service::name::service_desktop);

                return true;
            }

M module-apps/application-messages/ApplicationMessages.cpp => module-apps/application-messages/ApplicationMessages.cpp +1 -1
@@ 40,7 40,7 @@ namespace app
    ApplicationMessages::ApplicationMessages(std::string name, std::string parent, StartInBackground startInBackground)
        : Application(name, parent, startInBackground, 4096 * 2), AsyncCallbackReceiver{this}
    {
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
        addActionReceiver(manager::actions::CreateSms, [this](auto &&data) {
            switchWindow(gui::name::window::new_sms, std::move(data));
            return msgHandled();

M module-apps/application-notes/ApplicationNotes.cpp => module-apps/application-notes/ApplicationNotes.cpp +1 -1
@@ 30,7 30,7 @@ namespace app
    ApplicationNotes::ApplicationNotes(std::string name, std::string parent, StartInBackground startInBackground)
        : Application(name, parent, startInBackground, NotesStackSize)
    {
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
    }

    // Invoked upon receiving data message

M module-apps/application-phonebook/ApplicationPhonebook.cpp => module-apps/application-phonebook/ApplicationPhonebook.cpp +1 -1
@@ 24,7 24,7 @@ namespace app
                                               StartInBackground startInBackground)
        : Application(name, parent, startInBackground, phonebook_stack_size)
    {
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
        addActionReceiver(manager::actions::ShowContacts, [this](auto &&data) {
            switchWindow(gui::name::window::main_window, std::move(data));
            return msgHandled();

M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +20 -26
@@ 374,8 374,8 @@ namespace app
    {
        constexpr int timeout = pdMS_TO_TICKS(1500);

        auto response = sys::Bus::SendUnicast(
            std::make_shared<sevm::ScreenLightControlRequestParameters>(), service::name::evt_manager, this, timeout);
        auto response = bus.sendUnicast(
            std::make_shared<sevm::ScreenLightControlRequestParameters>(), service::name::evt_manager, timeout);

        if (response.first == sys::ReturnCodes::Success) {
            auto msgState = dynamic_cast<sevm::ScreenLightControlParametersResponse *>(response.second.get());


@@ 392,39 392,35 @@ namespace app
    void ApplicationSettingsNew::setBrightness(bsp::eink_frontlight::BrightnessPercentage value)
    {
        screen_light_control::Parameters parameters{value};
        sys::Bus::SendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(
                                  screen_light_control::Action::setManualModeBrightness, parameters),
                              service::name::evt_manager,
                              this);
        bus.sendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(
                            screen_light_control::Action::setManualModeBrightness, parameters),
                        service::name::evt_manager);
    }

    void ApplicationSettingsNew::setMode(bool isAutoLightSwitchOn)
    {
        sys::Bus::SendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(
                                  isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode
                                                      : screen_light_control::Action::disableAutomaticMode),
                              service::name::evt_manager,
                              this);
        bus.sendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(
                            isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode
                                                : screen_light_control::Action::disableAutomaticMode),
                        service::name::evt_manager);
    }

    void ApplicationSettingsNew::setStatus(bool isDisplayLightSwitchOn)
    {
        sys::Bus::SendUnicast(
            std::make_shared<sevm::ScreenLightControlMessage>(
                isDisplayLightSwitchOn ? screen_light_control::Action::turnOn : screen_light_control::Action::turnOff),
            service::name::evt_manager,
            this);
        bus.sendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(isDisplayLightSwitchOn
                                                                              ? screen_light_control::Action::turnOn
                                                                              : screen_light_control::Action::turnOff),
                        service::name::evt_manager);
    }

    auto ApplicationSettingsNew::isKeypadBacklightOn() -> bool
    {
        constexpr int timeout = pdMS_TO_TICKS(1500);

        auto response = sys::Bus::SendUnicast(
            std::make_shared<sevm::KeypadBacklightMessage>(bsp::keypad_backlight::Action::checkState),
            service::name::evt_manager,
            this,
            timeout);
        auto response =
            bus.sendUnicast(std::make_shared<sevm::KeypadBacklightMessage>(bsp::keypad_backlight::Action::checkState),
                            service::name::evt_manager,
                            timeout);

        if (response.first == sys::ReturnCodes::Success) {
            auto msgState = dynamic_cast<sevm::KeypadBacklightResponseMessage *>(response.second.get());


@@ 439,11 435,9 @@ namespace app

    void ApplicationSettingsNew::setKeypadBacklightState(bool newState)
    {
        sys::Bus::SendUnicast(
            std::make_shared<sevm::KeypadBacklightMessage>(newState ? bsp::keypad_backlight::Action::turnOn
                                                                    : bsp::keypad_backlight::Action::turnOff),
            service::name::evt_manager,
            this);
        bus.sendUnicast(std::make_shared<sevm::KeypadBacklightMessage>(
                            newState ? bsp::keypad_backlight::Action::turnOn : bsp::keypad_backlight::Action::turnOff),
                        service::name::evt_manager);
    }

} /* namespace app */

M module-apps/application-settings-new/models/ApnSettingsModel.cpp => module-apps/application-settings-new/models/ApnSettingsModel.cpp +2 -2
@@ 10,7 10,7 @@ ApnSettingsModel::ApnSettingsModel(app::Application *application) : application{

void ApnSettingsModel::requestAPNList()
{
    sys::Bus::SendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName, application);
    application->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName);
}

void ApnSettingsModel::saveAPN(std::shared_ptr<packet_data::APN::Config> apn)


@@ 31,5 31,5 @@ void ApnSettingsModel::removeAPN(std::shared_ptr<packet_data::APN::Config> apn)
void ApnSettingsModel::setAsDefaultAPN(std::shared_ptr<packet_data::APN::Config> apn)
{
    apn->apnType = packet_data::APN::APNType::Default;
    sys::Bus::SendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName, application);
    application->bus.sendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName);
}

M module-apps/application-settings-new/models/LanguagesModel.cpp => module-apps/application-settings-new/models/LanguagesModel.cpp +2 -3
@@ 7,7 7,6 @@

void LanguagesModel::requestCurrentDisplayLanguage()
{
    sys::Bus::SendUnicast(std::make_shared<app::manager::GetCurrentDisplayLanguageRequest>(),
                          app::manager::ApplicationManager::ServiceName,
                          application);
    application->bus.sendUnicast(std::make_shared<app::manager::GetCurrentDisplayLanguageRequest>(),
                                 app::manager::ApplicationManager::ServiceName);
}

M module-apps/application-settings-new/windows/AddDeviceWindow.cpp => module-apps/application-settings-new/windows/AddDeviceWindow.cpp +5 -6
@@ 33,10 33,9 @@ namespace gui
                device.name,
                [=](gui::Item &item) {
                    LOG_DEBUG("Device: %s", device.name.c_str());
                    sys::Bus::SendUnicast(std::make_shared<BluetoothAddrMessage>(bd_addr_to_str(device.address)),
                                          "ServiceBluetooth",
                                          application,
                                          5000);
                    application->bus.sendUnicast(std::make_shared<BluetoothAddrMessage>(bd_addr_to_str(device.address)),
                                                 "ServiceBluetooth",
                                                 5000);
                    return true;
                },
                nullptr,


@@ 44,8 43,8 @@ namespace gui
                gui::option::SettingRightItem::Bt));
        }

        sys::Bus::SendUnicast(
            std::make_shared<BluetoothMessage>(BluetoothMessage::Request::StopScan), "ServiceBluetooth", application);
        application->bus.sendUnicast(std::make_shared<BluetoothMessage>(BluetoothMessage::Request::StopScan),
                                     "ServiceBluetooth");

        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::add));


M module-apps/application-settings-new/windows/AllDevicesWindow.cpp => module-apps/application-settings-new/windows/AllDevicesWindow.cpp +4 -5
@@ 21,8 21,8 @@ namespace gui
    AllDevicesWindow::AllDevicesWindow(app::Application *app) : OptionWindow(app, gui::window::name::all_devices)
    {
        setTitle(utils::localize.get("app_settings_bluetooth_all_devices"));
        sys::Bus::SendUnicast(
            std::make_shared<::message::bluetooth::RequestBondedDevices>(), service::name::bluetooth, application);
        application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestBondedDevices>(),
                                     service::name::bluetooth);
    }

    void AllDevicesWindow::onBeforeShow(ShowMode mode, SwitchData *data)


@@ 38,9 38,8 @@ namespace gui

        if (inputEvent.state == InputEvent::State::keyReleasedShort) {
            if (inputEvent.keyCode == KeyCode::KEY_LEFT) {
                sys::Bus::SendUnicast(std::make_shared<BluetoothMessage>(BluetoothMessage::Request::Scan),
                                      "ServiceBluetooth",
                                      application);
                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");

M module-apps/application-settings-new/windows/BluetoothWindow.cpp => module-apps/application-settings-new/windows/BluetoothWindow.cpp +5 -8
@@ 15,8 15,7 @@ namespace gui

    BluetoothWindow::BluetoothWindow(app::Application *app) : OptionWindow(app, gui::window::name::bluetooth)
    {
        sys::Bus::SendUnicast(
            std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth, application);
        application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth);
    }

    void BluetoothWindow::onBeforeShow(ShowMode mode, SwitchData *data)


@@ 111,17 110,15 @@ namespace gui
    void BluetoothWindow::changeBluetoothState(bool currentState)
    {
        ::message::bluetooth::SetStatus setStatus(makeDesiredStatus(!currentState, isPhoneVisibilitySwitchOn));
        sys::Bus::SendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
                              service::name::bluetooth,
                              application);
        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));
        sys::Bus::SendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
                              service::name::bluetooth,
                              application);
        application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)),
                                     service::name::bluetooth);
    }

    BluetoothStatus BluetoothWindow::makeDesiredStatus(bool desiredBluetoothState, bool desiredVisibility) noexcept

M module-apps/application-settings-new/windows/DisplayLightWindow.cpp => module-apps/application-settings-new/windows/DisplayLightWindow.cpp +0 -1
@@ 10,7 10,6 @@

#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>
#include <i18n/i18n.hpp>
#include <Service/Bus.hpp>

namespace gui
{

M module-apps/application-settings-new/windows/PhoneNameWindow.cpp => module-apps/application-settings-new/windows/PhoneNameWindow.cpp +3 -3
@@ 33,8 33,8 @@ namespace gui
        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::save));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));

        sys::Bus::SendUnicast(
            std::make_shared<::message::bluetooth::RequestDeviceName>(), service::name::bluetooth, application);
        application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestDeviceName>(),
                                     service::name::bluetooth);

        setFocusItem(inputField);
    }


@@ 59,7 59,7 @@ namespace gui

        if (inputEvent.is(gui::KeyCode::KEY_ENTER) && !inputField->isEmpty()) {
            auto result = std::make_shared<::message::bluetooth::SetDeviceName>(inputField->getText());
            sys::Bus::SendUnicast(std::move(result), service::name::bluetooth, application);
            application->bus.sendUnicast(std::move(result), service::name::bluetooth);
            return true;
        }


M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +1 -1
@@ 43,7 43,7 @@ namespace app
    ApplicationSettings::ApplicationSettings(std::string name, std::string parent, StartInBackground startInBackground)
        : Application(name, parent, startInBackground)
    {
        busChannels.push_back(sys::BusChannels::AntennaNotifications);
        bus.channels.push_back(sys::BusChannel::AntennaNotifications);
        addActionReceiver(manager::actions::SelectSimCard, [this](auto &&data) {
            switchWindow(app::sim_select);
            return msgHandled();

M module-apps/application-settings/windows/BtScanWindow.cpp => module-apps/application-settings/windows/BtScanWindow.cpp +2 -2
@@ 43,7 43,7 @@ namespace gui
    sys::ReturnCodes message_bt2(app::Application *app, BluetoothMessage::Request req)
    {
        std::shared_ptr<BluetoothMessage> msg = std::make_shared<BluetoothMessage>(req);
        auto ret                              = sys::Bus::SendUnicast(msg, "ServiceBluetooth", app);
        auto ret                              = app->bus.sendUnicast(msg, "ServiceBluetooth");
        if (!ret) {
            LOG_ERROR("err: %d", static_cast<int>(ret));
        }


@@ 68,7 68,7 @@ namespace gui

                std::shared_ptr<BluetoothAddrMessage> msg =
                    std::make_shared<BluetoothAddrMessage>(bd_addr_to_str(device.address));
                sys::Bus::SendUnicast(msg, "ServiceBluetooth", application, 5000);
                application->bus.sendUnicast(msg, "ServiceBluetooth", 5000);

                message_bt2(application, BluetoothMessage::Request::StopScan);
                // message_bt2(application, BluetoothMessage::Request::Start);

M module-apps/application-settings/windows/BtWindow.cpp => module-apps/application-settings/windows/BtWindow.cpp +1 -1
@@ 45,7 45,7 @@ namespace gui
    sys::ReturnCodes message_bt(app::Application *app, BluetoothMessage::Request req)
    {
        std::shared_ptr<BluetoothMessage> msg = std::make_shared<BluetoothMessage>(req);
        auto ret                              = sys::Bus::SendUnicast(msg, "ServiceBluetooth", app);
        auto ret                              = app->bus.sendUnicast(msg, "ServiceBluetooth");
        if (!ret) {
            LOG_ERROR("err: %d", static_cast<int>(ret));
        }

M module-apps/application-settings/windows/ColorTestWindow.cpp => module-apps/application-settings/windows/ColorTestWindow.cpp +2 -4
@@ 78,10 78,8 @@ namespace gui
    {
        if (scheme != currentColorScheme) {
            currentColorScheme = scheme;
            sys::Bus::SendUnicast(std::make_shared<service::gui::ChangeColorScheme>(std::move(scheme)),
                                  service::name::gui,
                                  this->application,
                                  100);
            application->bus.sendUnicast(
                std::make_shared<service::gui::ChangeColorScheme>(std::move(scheme)), service::name::gui, 100);
            LOG_INFO("Updated color scheme");

            application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);

M module-apps/application-settings/windows/EinkModeWindow.cpp => module-apps/application-settings/windows/EinkModeWindow.cpp +2 -4
@@ 39,10 39,8 @@ namespace gui
                last_mode = service::eink::EinkModeMessage::Mode::Normal;
            }

            sys::Bus::SendUnicast(std::make_shared<service::eink::EinkModeMessage>(last_mode),
                                  service::name::eink,
                                  this->application,
                                  5000);
            application->bus.sendUnicast(
                std::make_shared<service::eink::EinkModeMessage>(last_mode), service::name::eink, 5000);
            return true;
        };
        setFocusItem(label);

M module-apps/application-settings/windows/Fota.cpp => module-apps/application-settings/windows/Fota.cpp +2 -8
@@ 19,19 19,13 @@ Fota::Fota(gui::FotaWindow *parent) : currentState(State::Disconnected), parent(
{
    app = std::shared_ptr<app::Application>(parent->getApplication(),
                                            [](app::Application *) {}); /// with deleter that doesn't delete.
    app->busChannels.push_back(sys::BusChannels::ServiceFotaNotifications);
    app->bus.channels.push_back(sys::BusChannel::ServiceFotaNotifications);
    registerHandlers();
    sys::Bus::Add(std::static_pointer_cast<sys::Service>(app));

    getCurrentVersion();
    parent->statusLabel->setText(getStateString());
}

Fota::~Fota()
{
    sys::Bus::Remove(std::static_pointer_cast<sys::Service>(app));
}

void Fota::next()
{
    switch (currentState) {


@@ 200,7 194,7 @@ void Fota::reboot()
    currentState = State::Reboot;
    parent->statusLabel->setText(getStateString());
    auto msg = std::make_shared<sys::SystemManagerCmd>(sys::Code::Reboot);
    sys::Bus::SendUnicast(std::move(msg), service::name::system_manager, app.get());
    app->bus.sendUnicast(std::move(msg), service::name::system_manager);
}

void Fota::registerHandlers()

M module-apps/application-settings/windows/Fota.hpp => module-apps/application-settings/windows/Fota.hpp +0 -1
@@ 40,7 40,6 @@ class Fota
    };
    using VersionMap = std::unordered_map<std::string, VersionInfo>;
    Fota(gui::FotaWindow *parent);
    virtual ~Fota();
    void next();
    std::string getCurrentFirmwareVersion()
    {

M module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp => module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp +2 -2
@@ 12,7 12,6 @@
#include <Bluetooth/Device.hpp>
#include <Bluetooth/Error.hpp>
#include <log/log.hpp>
#include <Service/Bus.hpp>
#include <service-bluetooth/BluetoothMessage.hpp>
#include <Audio/AudioCommon.hpp>
#include <service-audio/AudioMessage.hpp>


@@ 595,7 594,8 @@ namespace bluetooth
    {
        auto evt = std::make_shared<audio::Event>(event, state);
        auto msg = std::make_shared<AudioEventRequest>(std::move(evt));
        sys::Bus::SendUnicast(std::move(msg), service::name::evt_manager, const_cast<sys::Service *>(ownerService));
        auto &busProxy = const_cast<sys::Service *>(ownerService)->bus;
        busProxy.sendUnicast(std::move(msg), service::name::evt_manager);
    }

} // namespace Bt

M module-bluetooth/Bluetooth/interface/profiles/GAP.cpp => module-bluetooth/Bluetooth/interface/profiles/GAP.cpp +4 -6
@@ 3,7 3,6 @@

#include "BluetoothWorker.hpp"
#include "Device.hpp"
#include "Service/Bus.hpp"
#include <Bluetooth/Device.hpp>
#include <Bluetooth/Error.hpp>
#include <log/log.hpp>


@@ 217,9 216,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
            }
            bluetooth::GAP::devices.push_back(dev);
            auto msg = std::make_shared<BluetoothScanResultMessage>(bluetooth::GAP::devices);
            sys::Bus::SendUnicast(msg, "ApplicationSettings", bluetooth::GAP::ownerService);
            sys::Bus::SendUnicast(msg, "ApplicationSettingsNew", bluetooth::GAP::ownerService);

            bluetooth::GAP::ownerService->bus.sendUnicast(msg, "ApplicationSettings");
            bluetooth::GAP::ownerService->bus.sendUnicast(msg, "ApplicationSettingsNew");
        } break;

        case GAP_EVENT_INQUIRY_COMPLETE:


@@ 255,8 253,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
        case GAP_EVENT_DEDICATED_BONDING_COMPLETED: {
            auto result = packet[2];
            auto msg    = std::make_shared<BluetoothPairResultMessage>(result == 0u);
            sys::Bus::SendUnicast(msg, "ApplicationSettings", bluetooth::GAP::ownerService);
            sys::Bus::SendUnicast(msg, "ApplicationSettingsNew", bluetooth::GAP::ownerService);
            bluetooth::GAP::ownerService->bus.sendUnicast(msg, "ApplicationSettings");
            bluetooth::GAP::ownerService->bus.sendUnicast(msg, "ApplicationSettingsNew");
        } break;
        default:
            break;

M module-bluetooth/Bluetooth/interface/profiles/HSP/HSP.cpp => module-bluetooth/Bluetooth/interface/profiles/HSP/HSP.cpp +2 -1
@@ 79,7 79,8 @@ namespace bluetooth
    {
        auto evt = std::make_shared<audio::Event>(event, state);
        auto msg = std::make_shared<AudioEventRequest>(std::move(evt));
        sys::Bus::SendUnicast(std::move(msg), service::name::evt_manager, const_cast<sys::Service *>(ownerService));
        auto &busProxy = const_cast<sys::Service *>(ownerService)->bus;
        busProxy.sendUnicast(std::move(msg), service::name::evt_manager);
    }

    void HSP::HSPImpl::packetHandler(uint8_t packetType, uint16_t channel, uint8_t *event, uint16_t eventSize)

M module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.cpp => module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.cpp +2 -1
@@ 106,7 106,8 @@ void SCO::SCOImpl::sendEvent(audio::EventType event, audio::Event::DeviceState s
{
    auto evt = std::make_shared<audio::Event>(event, state);
    auto msg = std::make_shared<AudioEventRequest>(std::move(evt));
    sys::Bus::SendUnicast(std::move(msg), service::name::evt_manager, const_cast<sys::Service *>(ownerService));
    auto &busProxy = const_cast<sys::Service *>(ownerService)->bus;
    busProxy.sendUnicast(std::move(msg), service::name::evt_manager);
}
auto SCO::SCOImpl::audioInitialize(int sampleRate) -> Error
{

M module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.hpp => module-bluetooth/Bluetooth/interface/profiles/HSP/SCO.hpp +0 -1
@@ 5,7 5,6 @@

#include "Profile.hpp"
#include <memory>
#include <module-sys/Service/Bus.hpp>

extern "C"
{

M module-bsp/bsp/battery-charger/battery_charger.hpp => module-bsp/bsp/battery-charger/battery_charger.hpp +2 -2
@@ 58,9 58,9 @@ namespace bsp::battery_charger

	std::uint16_t getStatusRegister();

	void chargingFinishedAction();
    void chargingFinishedAction();

	BaseType_t INOKB_IRQHandler();
    BaseType_t INOKB_IRQHandler();

	BaseType_t INTB_IRQHandler();


M module-cellular/Modem/ATParser.cpp => module-cellular/Modem/ATParser.cpp +1 -2
@@ 2,7 2,6 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ATParser.hpp"
#include "Service/Bus.hpp"
#include <service-fota/FotaServiceAPI.hpp>
#include "bsp/cellular/bsp_cellular.hpp"
#include <service-cellular/CellularMessage.hpp>


@@ 94,7 93,7 @@ int ATParser::ProcessNewData(sys::Service *service)
            cpp_freertos::LockGuard lock(mutex);
            auto msg = std::make_shared<CellularNotificationMessage>(
                CellularNotificationMessage::Type::PowerUpProcedureComplete);
            sys::Bus::SendMulticast(msg, sys::BusChannels::ServiceCellularNotifications, service);
            service->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
            LOG_DEBUG("[!!!] Fucking away data");
            responseBuffer.erase();
            urcs.clear();

M module-cellular/Modem/TS0710/TS0710.cpp => module-cellular/Modem/TS0710/TS0710.cpp +1 -2
@@ 7,7 7,6 @@
#include <service-cellular/ServiceCellular.hpp>
#include <service-cellular/SignalStrength.hpp>
#include <service-cellular/CellularMessage.hpp>
#include <Service/Bus.hpp>
#include <cassert>
#include <memory>
#include <module-os/RTOSWrapper/include/ticks.hpp>


@@ 411,7 410,7 @@ TS0710::ConfState TS0710::StartMultiplexer()
                Store::GSM::get()->setSignalStrength(signalStrength.data);
                auto msg = std::make_shared<CellularNotificationMessage>(
                    CellularNotificationMessage::Type::SignalStrengthUpdate);
                sys::Bus::SendMulticast(msg, sys::BusChannels::ServiceCellularNotifications, pv_parent);
                pv_parent->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
            }
        }
        else {

M module-services/service-antenna/ServiceAntenna.cpp => module-services/service-antenna/ServiceAntenna.cpp +2 -2
@@ 74,8 74,8 @@ ServiceAntenna::ServiceAntenna() : sys::Service(serviceName)

    state = new utils::state::State<antenna::State>(this);

    busChannels.push_back(sys::BusChannels::ServiceCellularNotifications);
    busChannels.push_back(sys::BusChannels::AntennaNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);
    bus.channels.push_back(sys::BusChannel::AntennaNotifications);
}

ServiceAntenna::~ServiceAntenna()

M module-services/service-antenna/api/AntennaServiceAPI.cpp => module-services/service-antenna/api/AntennaServiceAPI.cpp +3 -4
@@ 7,7 7,6 @@
#include <service-antenna/ServiceAntenna.hpp>

#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <Service/Message.hpp>



@@ 25,12 24,12 @@ namespace AntennaServiceAPI
    void CSQChange(sys::Service *serv)
    {
        auto msg = std::make_shared<sys::DataMessage>(MessageType::AntennaCSQChange);
        sys::Bus::SendMulticast(msg, sys::BusChannels::AntennaNotifications, serv);
        serv->bus.sendMulticast(msg, sys::BusChannel::AntennaNotifications);
    }
    bool LockRequest(sys::Service *serv, antenna::lockState request)
    {
        auto msg = std::make_shared<AntennaLockRequestMessage>(MessageType::AntennaLockService, request);
        auto ret = sys::Bus::SendUnicast(msg, ServiceAntenna::serviceName, serv, 5000);
        auto ret = serv->bus.sendUnicast(msg, ServiceAntenna::serviceName, 5000);
        if (ret.first == sys::ReturnCodes::Success) {

            return true;


@@ 41,7 40,7 @@ namespace AntennaServiceAPI
    bool GetLockState(sys::Service *serv, antenna::lockState &response)
    {
        auto msg = std::make_shared<AntennaLockRequestMessage>(MessageType::AntennaGetLockState);
        auto ret = sys::Bus::SendUnicast(msg, ServiceAntenna::serviceName, serv, 5000);
        auto ret = serv->bus.sendUnicast(msg, ServiceAntenna::serviceName, 5000);
        if (ret.first == sys::ReturnCodes::Success) {
            auto responseMsg = dynamic_cast<AntennaLockRequestResponse *>(ret.second.get());
            if (responseMsg != nullptr) {

M module-services/service-appmgr/Controller.cpp => module-services/service-appmgr/Controller.cpp +14 -15
@@ 5,7 5,6 @@

#include "service-appmgr/model/ApplicationManager.hpp"

#include <module-sys/Service/Bus.hpp>
#include <Service/Service.hpp>

#include <utility> // for move


@@ 27,7 26,7 @@ namespace app::manager
                                            StartInBackground startInBackground) -> bool
    {
        auto msg = std::make_shared<app::manager::ApplicationInitialised>(sender->GetName(), status, startInBackground);
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::sendAction(sys::Service *sender,


@@ 37,7 36,7 @@ namespace app::manager
    {
        setOnSwitchBehaviour(data, onSwitchBehaviour);
        auto msg = std::make_shared<app::manager::ActionRequest>(sender->GetName(), actionId, std::move(data));
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::switchBack(sys::Service *sender, std::unique_ptr<SwitchBackRequest> msg) -> bool


@@ 45,72 44,72 @@ namespace app::manager

        std::shared_ptr<SwitchBackRequest> switchMsg =
            msg ? std::move(msg) : std::make_shared<app::manager::SwitchBackRequest>(sender->GetName());
        return sys::Bus::SendUnicast(switchMsg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(switchMsg, ApplicationManager::ServiceName);
    }

    auto Controller::confirmSwitch(sys::Service *sender) -> bool
    {
        auto msg = std::make_shared<app::manager::SwitchConfirmation>(sender->GetName());
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::closeApplication(sys::Service *sender, const ApplicationName &name) -> bool
    {
        auto msg = std::make_shared<app::manager::ApplicationCloseRequest>(sender->GetName(), name);
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::confirmClose(sys::Service *sender) -> bool
    {
        auto msg = std::make_shared<app::manager::CloseConfirmation>(sender->GetName());
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::changeDisplayLanguage(sys::Service *sender, const Language &language) -> bool
    {
        auto msg = std::make_shared<app::manager::DisplayLanguageChangeRequest>(sender->GetName(), language);
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::changeInputLanguage(sys::Service *sender, const Language &language) -> bool
    {
        auto msg = std::make_shared<app::manager::InputLanguageChangeRequest>(sender->GetName(), language);
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::changeAutomaticDateAndTimeIsOn(sys::Service *sender, bool isOn) -> bool
    {
        auto msg = std::make_shared<app::manager::AutomaticDateAndTimeIsOnChangeRequest>(isOn);
        return sys::Bus::SendUnicast(std::move(msg), ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(std::move(msg), ApplicationManager::ServiceName);
    }

    auto Controller::changeAutomaticTimeZoneIsOn(sys::Service *sender, bool isOn) -> bool
    {
        auto msg = std::make_shared<app::manager::AutomaticTimeZoneIsOnChangeRequest>(isOn);
        return sys::Bus::SendUnicast(std::move(msg), ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(std::move(msg), ApplicationManager::ServiceName);
    }

    auto Controller::changeTimeFormat(sys::Service *sender, utils::time::Locale::TimeFormat timeFormat) -> bool
    {
        auto msg = std::make_shared<app::manager::TimeFormatChangeRequest>(timeFormat);
        return sys::Bus::SendUnicast(std::move(msg), ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(std::move(msg), ApplicationManager::ServiceName);
    }

    auto Controller::changeDateFormat(sys::Service *sender, utils::time::Locale::DateFormat dateFormat) -> bool
    {
        auto msg = std::make_shared<app::manager::DateFormatChangeRequest>(dateFormat);
        return sys::Bus::SendUnicast(std::move(msg), ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(std::move(msg), ApplicationManager::ServiceName);
    }

    auto Controller::preventBlockingDevice(sys::Service *sender) -> bool
    {
        auto msg = std::make_shared<app::manager::PreventBlockingRequest>(sender->GetName());
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }

    auto Controller::changePowerSaveMode(sys::Service *sender) -> bool
    {
        auto msg = std::make_shared<app::manager::PowerSaveModeInitRequest>(sender->GetName());
        return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
        return sender->bus.sendUnicast(msg, ApplicationManager::ServiceName);
    }
} // namespace app::manager

M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +1 -2
@@ 6,7 6,6 @@

#include <module-apps/messages/AppMessage.hpp>
#include <Common.hpp>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <Service/Timer.hpp>
#include <SystemManager/SystemManager.hpp>


@@ 571,7 570,7 @@ namespace app::manager
        }

        auto notification = std::make_shared<ApplicationStatusRequest>(GetName(), app->name());
        sys::Bus::SendMulticast(notification, sys::BusChannels::AppManagerNotifications, this);
        bus.sendMulticast(notification, sys::BusChannel::AppManagerNotifications);
        return true;
    }


M module-services/service-audio/AudioServiceAPI.cpp => module-services/service-audio/AudioServiceAPI.cpp +12 -13
@@ 6,7 6,6 @@
#include "service-audio/AudioMessage.hpp"

#include <Audio/decoder/Decoder.hpp>
#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <log/log.hpp>



@@ 26,7 25,7 @@ namespace AudioServiceAPI
        {
            auto msgType = static_cast<int>(msg->type);
            LOG_DEBUG("Msg type %d", msgType);
            auto ret = sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv, sys::defaultCmdTimeout);
            auto ret = serv->bus.sendUnicast(msg, ServiceAudio::serviceName, sys::BusProxy::defaultTimeout);
            if (ret.first == sys::ReturnCodes::Success) {
                if (auto resp = std::dynamic_pointer_cast<AudioResponseMessage>(ret.second)) {
                    LOG_DEBUG("Msg type %d done", msgType);


@@ 43,19 42,19 @@ namespace AudioServiceAPI
    bool PlaybackStart(sys::Service *serv, const audio::PlaybackType &playbackType, const std::string &fileName)
    {
        auto msg = std::make_shared<AudioStartPlaybackRequest>(fileName, playbackType);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool RecordingStart(sys::Service *serv, const std::string &fileName)
    {
        auto msg = std::make_shared<AudioStartRecorderRequest>(fileName);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool RoutingStart(sys::Service *serv)
    {
        auto msg = std::make_shared<AudioStartRoutingRequest>();
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool Stop(sys::Service *serv, const std::vector<audio::PlaybackType> &stopVec)


@@ 64,43 63,43 @@ namespace AudioServiceAPI
            return true;
        }
        auto msg = std::make_shared<AudioStopRequest>(stopVec);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool Stop(sys::Service *serv, const audio::Token &token)
    {
        auto msg = std::make_shared<AudioStopRequest>(token);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool StopAll(sys::Service *serv)
    {
        auto msg = std::make_shared<AudioStopRequest>();
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool Pause(sys::Service *serv, const audio::Token &token)
    {
        auto msg = std::make_shared<AudioPauseRequest>(token);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool Resume(sys::Service *serv, const audio::Token &token)
    {
        auto msg = std::make_shared<AudioResumeRequest>(token);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool SendEvent(sys::Service *serv, std::shared_ptr<audio::Event> evt)
    {
        auto msg = std::make_shared<AudioEventRequest>(std::move(evt));
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    bool SendEvent(sys::Service *serv, audio::EventType eType, audio::Event::DeviceState state)
    {
        auto msg = std::make_shared<AudioEventRequest>(eType, state);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

    template <typename T>


@@ 165,7 164,7 @@ namespace AudioServiceAPI
    bool KeyPressed(sys::Service *serv, const int step)
    {
        auto msg = std::make_shared<AudioKeyPressedRequest>(step);
        return sys::Bus::SendUnicast(msg, ServiceAudio::serviceName, serv);
        return serv->bus.sendUnicast(msg, ServiceAudio::serviceName);
    }

} // namespace AudioServiceAPI

M module-services/service-audio/ServiceAudio.cpp => module-services/service-audio/ServiceAudio.cpp +8 -8
@@ 23,7 23,7 @@ ServiceAudio::ServiceAudio()
      settingsProvider(std::make_unique<settings::Settings>(this))
{
    LOG_INFO("[ServiceAudio] Initializing");
    busChannels.push_back(sys::BusChannels::ServiceAudioNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceAudioNotifications);
}

ServiceAudio::~ServiceAudio()


@@ 112,7 112,7 @@ std::optional<std::string> ServiceAudio::AudioServicesCallback(const sys::Messag
    if (const auto *eof = dynamic_cast<const AudioServiceMessage::EndOfFile *>(msg); eof) {
        auto newMsg =
            std::make_shared<AudioNotificationMessage>(AudioNotificationMessage::Type::EndOfFile, eof->GetToken());
        sys::Bus::SendMulticast(newMsg, sys::BusChannels::ServiceAudioNotifications, this);
        bus.sendMulticast(std::move(newMsg), sys::BusChannel::ServiceAudioNotifications);
    }
    else if (const auto *dbReq = dynamic_cast<const AudioServiceMessage::DbRequest *>(msg); dbReq) {
        LOG_DEBUG("ServiceAudio::DBbCallback(%s)", dbReq->GetPath().c_str());


@@ 144,7 144,7 @@ std::optional<std::string> ServiceAudio::AudioServicesCallback(const sys::Messag
            LOG_DEBUG("BluetoothProxyMessage not supported.");
            return std::nullopt;
        }
        sys::Bus::SendUnicast(request, service::name::bluetooth, this);
        bus.sendUnicast(request, service::name::bluetooth);
    }
    else {
        LOG_DEBUG("Message received but not handled - no effect.");


@@ 274,7 274,7 @@ std::unique_ptr<AudioResponseMessage> ServiceAudio::HandlePause(std::optional<Au
        retCode = audioInput->audio->Stop();
        auto broadMsg =
            std::make_shared<AudioNotificationMessage>(AudioNotificationMessage::Type::Stop, audioInput->token);
        sys::Bus::SendMulticast(broadMsg, sys::BusChannels::ServiceAudioNotifications, this);
        bus.sendMulticast(std::move(broadMsg), sys::BusChannel::ServiceAudioNotifications);
        audioMux.ResetInput(audioInput);
    }



@@ 345,7 345,7 @@ std::unique_ptr<AudioResponseMessage> ServiceAudio::HandleSendEvent(std::shared_
        evt->getType() == EventType::BlutoothHSPDeviceState || evt->getType() == EventType::BlutoothA2DPDeviceState;
    if (isBT && evt->getDeviceState() == audio::Event::DeviceState::Connected) {
        auto req = std::make_shared<BluetoothRequestStreamMessage>();
        sys::Bus::SendUnicast(req, service::name::bluetooth, this);
        bus.sendUnicast(req, service::name::bluetooth);
        return std::make_unique<AudioEventResponse>(RetCode::Success);
    }



@@ 368,7 368,7 @@ std::unique_ptr<AudioResponseMessage> ServiceAudio::HandleStop(const std::vector
        auto rCode = inp->audio->Stop();
        // Send notification that audio file was stopped
        auto msgStop = std::make_shared<AudioNotificationMessage>(AudioNotificationMessage::Type::Stop, inp->token);
        sys::Bus::SendMulticast(msgStop, sys::BusChannels::ServiceAudioNotifications, this);
        bus.sendMulticast(msgStop, sys::BusChannel::ServiceAudioNotifications);
        audioMux.ResetInput(inp);
        return rCode;
    };


@@ 426,7 426,7 @@ void ServiceAudio::HandleNotification(const AudioNotificationMessage::Type &type
        }
        else {
            auto newMsg = std::make_shared<AudioStopRequest>(token);
            sys::Bus::SendUnicast(newMsg, ServiceAudio::serviceName, this);
            bus.sendUnicast(newMsg, ServiceAudio::serviceName);
        }
        return;
    }


@@ 530,7 530,7 @@ sys::MessagePointer ServiceAudio::DataReceivedHandler(sys::DataMessage *msgl, sy
    if (isBusy != curIsBusy) {
        auto broadMsg = std::make_shared<AudioNotificationMessage>(
            curIsBusy ? AudioNotificationMessage::Type::ServiceWakeUp : AudioNotificationMessage::Type::ServiceSleep);
        sys::Bus::SendMulticast(broadMsg, sys::BusChannels::ServiceAudioNotifications, this);
        bus.sendMulticast(broadMsg, sys::BusChannel::ServiceAudioNotifications);
    }

    if (responseMsg) {

M module-services/service-bluetooth/ServiceBluetooth.cpp => module-services/service-bluetooth/ServiceBluetooth.cpp +2 -3
@@ 5,7 5,6 @@
#include "service-bluetooth/ServiceBluetooth.hpp"
#include "service-bluetooth/BluetoothMessage.hpp"

#include <module-sys/Service/Bus.hpp>

#include <Bluetooth/BluetoothWorker.hpp>
#include <interface/profiles/Profile.hpp>


@@ 89,7 88,7 @@ sys::ReturnCodes ServiceBluetooth::InitHandler()
            auto state   = std::visit(bluetooth::IntVisitor(), settingsHolder->getValue(bluetooth::Settings::State));
            auto event   = std::make_unique<BluetoothStatusRequestEvent>(state);
            auto message = std::make_shared<DeveloperModeRequest>(std::move(event));
            sys::Bus::SendUnicast(std::move(message), service::name::service_desktop, this);
            bus.sendUnicast(std::move(message), service::name::service_desktop);
        }

        return sys::MessageNone{};


@@ 167,7 166,7 @@ sys::MessagePointer ServiceBluetooth::DataReceivedHandler(sys::DataMessage *msg,
        case MessageType::BluetoothRequestStream: {
            auto result =
                std::make_shared<BluetoothRequestStreamResultMessage>(worker->currentProfile->getStreamData());
            sys::Bus::SendUnicast(std::move(result), "ServiceAudio", this);
            bus.sendUnicast(std::move(result), "ServiceAudio");
            LOG_INFO("Queues sent after a request!");
        } break;
        default:

M module-services/service-cellular/CellularRequestHandler.cpp => module-services/service-cellular/CellularRequestHandler.cpp +9 -11
@@ 5,7 5,6 @@
#include "service-cellular/RequestFactory.hpp"
#include "service-cellular/ServiceCellular.hpp"

#include "Service/Bus.hpp"
#include "Service/Message.hpp"
#include "Service/Timer.hpp"



@@ 41,7 40,7 @@ void CellularRequestHandler::handle(cellular::ImeiRequest &request, at::Result &
    }

    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
}

void CellularRequestHandler::handle(cellular::UssdRequest &request, at::Result &result)


@@ 67,10 66,9 @@ void CellularRequestHandler::handle(cellular::CallRequest &request, at::Result &
    // activate call state timer
    cellular.callStateTimer->reload();
    // Propagate "Ringing" notification into system
    sys::Bus::SendMulticast(
    cellular.bus.sendMulticast(
        std::make_shared<CellularCallMessage>(CellularCallMessage::Type::Ringing, request.getNumber()),
        sys::BusChannels::ServiceCellularNotifications,
        &cellular);
        sys::BusChannel::ServiceCellularNotifications);
    request.setHandled(true);
}



@@ 123,7 121,7 @@ void CellularRequestHandler::handle(cellular::ClirRequest &request, at::Result &
        }
    }
    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    request.setHandled(requestHandled);
}



@@ 188,7 186,7 @@ void CellularRequestHandler::handle(cellular::CallForwardingRequest &request, at
        response->addMessage(IMMICustomResultParams::MMIResultMessage::CommonFailure);
    }
    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    request.setHandled(requestHandled);
}



@@ 237,7 235,7 @@ void CellularRequestHandler::handle(cellular::CallBarringRequest &request, at::R
    }

    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    request.setHandled(requestHandled);
}



@@ 275,7 273,7 @@ void CellularRequestHandler::handle(cellular::ClipRequest &request, at::Result &
    }

    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    request.setHandled(requestHandled);
}



@@ 322,7 320,7 @@ void CellularRequestHandler::handle(cellular::CallWaitingRequest &request, at::R
        response->addMessage(IMMICustomResultParams::MMIResultMessage::CommonFailure);
    }
    auto msg = std::make_shared<CellularMMIResultMessage>(MMIResultParams::MMIResult::Success, response);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    request.setHandled(requestHandled);
}



@@ 332,5 330,5 @@ void CellularRequestHandler::sendMmiResult(bool result)

    auto msg = std::make_shared<CellularMMIResultMessage>(result ? MMIResultParams::MMIResult::Success
                                                                 : MMIResultParams::MMIResult::Failed);
    sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular);
    cellular.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
}

M module-services/service-cellular/CellularServiceAPI.cpp => module-services/service-cellular/CellularServiceAPI.cpp +37 -44
@@ 8,7 8,6 @@
#include <MessageType.hpp>
#include <Modem/TS0710/TS0710.h>
#include <PhoneNumber.hpp>
#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <bsp/cellular/bsp_cellular.hpp>
#include <log/log.hpp>


@@ 25,14 24,14 @@ namespace sys
bool CellularServiceAPI::DialNumber(sys::Service *serv, const utils::PhoneNumber &number)
{
    auto msg = std::make_shared<CellularCallRequestMessage>(number.getView());
    return sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

bool CellularServiceAPI::DialEmergencyNumber(sys::Service *serv, const utils::PhoneNumber &number)
{
    auto msg = std::make_shared<CellularCallRequestMessage>(number.getView(),
                                                            CellularCallRequestMessage::RequestMode::Emergency);
    return sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

bool CellularServiceAPI::AnswerIncomingCall(sys::Service *serv)


@@ 40,7 39,7 @@ bool CellularServiceAPI::AnswerIncomingCall(sys::Service *serv)
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularAnswerIncomingCall);

    auto ret                          = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret                          = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    CellularResponseMessage *response = reinterpret_cast<CellularResponseMessage *>(ret.second.get());
    if ((ret.first == sys::ReturnCodes::Success) && (response->retCode == true)) {
        return true;


@@ 56,7 55,7 @@ void CellularServiceAPI::HangupCall(sys::Service *serv)
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularHangupCall);

    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

std::string CellularServiceAPI::GetIMSI(sys::Service *serv, bool getFullIMSINumber)


@@ 65,7 64,7 @@ std::string CellularServiceAPI::GetIMSI(sys::Service *serv, bool getFullIMSINumb
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularGetIMSI);

    auto ret                          = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret                          = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    CellularResponseMessage *response = dynamic_cast<CellularResponseMessage *>(ret.second.get());

    if (response == nullptr) {


@@ 87,7 86,7 @@ std::string CellularServiceAPI::GetOwnNumber(sys::Service *serv)
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularGetOwnNumber);

    auto ret                          = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret                          = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    CellularResponseMessage *response = dynamic_cast<CellularResponseMessage *>(ret.second.get());

    if (response == nullptr) {


@@ 108,26 107,26 @@ void CellularServiceAPI::GetNetworkInfo(sys::Service *serv)
{
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularGetNetworkInfo);
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

void CellularServiceAPI::GetCurrentOperator(sys::Service *serv)
{
    std::shared_ptr<CellularGetCurrentOperatorMessage> msg = std::make_shared<CellularGetCurrentOperatorMessage>();
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

void CellularServiceAPI::StartOperatorsScan(sys::Service *serv, bool fullInfo)
{
    std::shared_ptr<CellularStartOperatorsScanMessage> msg =
        std::make_shared<CellularStartOperatorsScanMessage>(fullInfo);
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

void CellularServiceAPI::SetOperatorAutoSelect(sys::Service *serv)
{
    auto msg = std::make_shared<CellularSetOperatorAutoSelectMessage>();
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

void CellularServiceAPI::SetOperator(sys::Service *serv,


@@ 136,14 135,14 @@ void CellularServiceAPI::SetOperator(sys::Service *serv,
                                     const std::string &name)
{
    auto msg = std::make_shared<CellularSetOperatorMessage>(mode, format, name);
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

bool CellularServiceAPI::SelectAntenna(sys::Service *serv, bsp::cellular::antenna antenna)
{
    auto msg     = std::make_shared<CellularAntennaRequestMessage>(MessageType::CellularSelectAntenna);
    msg->antenna = antenna;
    auto ret     = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret     = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);

    CellularResponseMessage *response = dynamic_cast<CellularResponseMessage *>(ret.second.get());



@@ 161,7 160,7 @@ bool CellularServiceAPI::SetScanMode(sys::Service *serv, std::string mode)
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularSetScanMode);
    msg->data = mode;
    auto ret  = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret  = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);

    CellularResponseMessage *response = dynamic_cast<CellularResponseMessage *>(ret.second.get());



@@ 176,7 175,7 @@ bool CellularServiceAPI::GetScanMode(sys::Service *serv)
{
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularGetScanMode);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 1000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 1000);

    CellularResponseMessage *response = dynamic_cast<CellularResponseMessage *>(ret.second.get());



@@ 192,7 191,7 @@ bool CellularServiceAPI::GetFirmwareVersion(sys::Service *serv, std::string &res
{
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularGetFirmwareVersion);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 1000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 1000);
    if (ret.first == sys::ReturnCodes::Success) {
        auto celResponse = std::dynamic_pointer_cast<CellularResponseMessage>(ret.second);
        if ((celResponse != nullptr) && (celResponse->retCode == true)) {


@@ 207,7 206,7 @@ bool CellularServiceAPI::GetFirmwareVersion(sys::Service *serv, std::string &res
bool CellularServiceAPI::GetChannel(sys::Service *serv, TS0710::Channel channel)
{
    std::shared_ptr<CellularGetChannelMessage> msg = std::make_shared<CellularGetChannelMessage>(channel);
    return sys::Bus::SendUnicast(std::move(msg), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::move(msg), ServiceCellular::serviceName);
}

bool CellularServiceAPI::GetDataChannel(sys::Service *serv)


@@ 219,7 218,7 @@ bool CellularServiceAPI::GetCSQ(sys::Service *serv, std::string &response)
{

    auto msg = std::make_shared<CellularRequestMessage>(MessageType::CellularGetCSQ);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    if (ret.first == sys::ReturnCodes::Success) {
        auto responseMsg = std::dynamic_pointer_cast<CellularResponseMessage>(ret.second);
        if ((responseMsg != nullptr) && (responseMsg->retCode == true)) {


@@ 232,7 231,7 @@ bool CellularServiceAPI::GetCSQ(sys::Service *serv, std::string &response)
bool CellularServiceAPI::GetCREG(sys::Service *serv, std::string &response)
{
    auto msg = std::make_shared<CellularRequestMessage>(MessageType::CellularGetCREG);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    if (ret.first == sys::ReturnCodes::Success) {
        auto responseMsg = std::dynamic_pointer_cast<CellularResponseMessage>(ret.second);
        if ((responseMsg != nullptr) && (responseMsg->retCode == true)) {


@@ 245,7 244,7 @@ bool CellularServiceAPI::GetCREG(sys::Service *serv, std::string &response)
bool CellularServiceAPI::GetQNWINFO(sys::Service *serv, std::string &response)
{
    auto msg = std::make_shared<CellularRequestMessage>(MessageType::CellularGetNWINFO);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    if (ret.first == sys::ReturnCodes::Success) {
        auto responseMsg = std::dynamic_pointer_cast<CellularResponseMessage>(ret.second);
        if ((responseMsg != nullptr) && (responseMsg->retCode == true)) {


@@ 259,7 258,7 @@ bool CellularServiceAPI::GetQNWINFO(sys::Service *serv, std::string &response)
bool CellularServiceAPI::GetAntenna(sys::Service *serv, bsp::cellular::antenna &response)
{
    auto msg = std::make_shared<CellularRequestMessage>(MessageType::CellularGetAntenna);
    auto ret = sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv, 5000);
    auto ret = serv->bus.sendUnicast(msg, ServiceCellular::serviceName, 5000);
    if (ret.first == sys::ReturnCodes::Success) {
        auto responseMsg = std::dynamic_pointer_cast<CellularAntennaResponseMessage>(ret.second);
        if ((responseMsg != nullptr) && (responseMsg->retCode == true)) {


@@ 273,13 272,13 @@ bool CellularServiceAPI::GetAntenna(sys::Service *serv, bsp::cellular::antenna &
bool CellularServiceAPI::TransmitDtmfTones(sys::Service *serv, uint32_t digit)
{
    auto msg = std::make_shared<CellularDtmfRequestMessage>(digit);
    return sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}

bool CellularServiceAPI::USSDRequest(sys::Service *serv, CellularUSSDMessage::RequestType type, std::string data)
{
    auto msg = std::make_shared<CellularUSSDMessage>(type, data);
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv);
    serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
    return true;
}



@@ 288,8 287,8 @@ bool CellularServiceAPI::ChangeSimPin(sys::Service *serv,
                                      const std::vector<unsigned int> &passcode,
                                      const std::vector<unsigned int> &pin)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularSimPukDataMessage>(sim, passcode, pin), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularSimPukDataMessage>(sim, passcode, pin),
                                 ServiceCellular::serviceName);
}

bool CellularServiceAPI::SetSimCardLock(sys::Service *serv,


@@ 297,71 296,65 @@ bool CellularServiceAPI::SetSimCardLock(sys::Service *serv,
                                        CellularSimCardLockDataMessage::SimCardLock lock,
                                        const std::vector<unsigned int> &pin)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularSimCardLockDataMessage>(sim, lock, pin), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularSimCardLockDataMessage>(sim, lock, pin),
                                 ServiceCellular::serviceName);
}

bool CellularServiceAPI::SetSimCard(sys::Service *serv, Store::GSM::SIM sim)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularChangeSimDataMessage>(sim), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularChangeSimDataMessage>(sim), ServiceCellular::serviceName);
}

bool CellularServiceAPI::GetAPN(sys::Service *serv)
{
    return sys::Bus::SendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName);
}

bool CellularServiceAPI::GetAPN(sys::Service *serv, std::uint8_t contextId)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularGetAPNMessage>(contextId), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(contextId), ServiceCellular::serviceName);
}

bool CellularServiceAPI::GetAPN(sys::Service *serv, packet_data::APN::APNType type)
{
    return sys::Bus::SendUnicast(std::make_shared<CellularGetAPNMessage>(type), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(type), ServiceCellular::serviceName);
}

bool CellularServiceAPI::SetAPN(sys::Service *serv, packet_data::APN::Config apnConfig)
{
    auto apn = std::make_shared<packet_data::APN::Config>(std::move(apnConfig));
    return sys::Bus::SendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName);
}

bool CellularServiceAPI::NewAPN(sys::Service *serv, packet_data::APN::Config apnConfig)
{
    auto apn = std::make_shared<packet_data::APN::Config>(std::move(apnConfig));
    return sys::Bus::SendUnicast(std::make_shared<CellularNewAPNMessage>(apn), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularNewAPNMessage>(apn), ServiceCellular::serviceName);
}

bool CellularServiceAPI::DeleteAPN(sys::Service *serv, std::uint8_t contextId)
{
    auto emptyApn       = std::make_shared<packet_data::APN::Config>();
    emptyApn->contextId = contextId;
    return sys::Bus::SendUnicast(std::make_shared<CellularSetAPNMessage>(emptyApn), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularSetAPNMessage>(emptyApn), ServiceCellular::serviceName);
}

bool CellularServiceAPI::SetDataTransfer(sys::Service *serv, packet_data::DataTransfer dt)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularSetDataTransferMessage>(dt), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularSetDataTransferMessage>(dt), ServiceCellular::serviceName);
}

bool CellularServiceAPI::GetDataTransfer(sys::Service *serv)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularGetDataTransferMessage>(), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularGetDataTransferMessage>(), ServiceCellular::serviceName);
}

bool CellularServiceAPI::SetVoLTE(sys::Service *serv, bool voLTE)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularChangeVoLTEDataMessage>(voLTE), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularChangeVoLTEDataMessage>(voLTE), ServiceCellular::serviceName);
}

bool CellularServiceAPI::ChangeModulePowerState(sys::Service *serv, cellular::State::PowerState newState)
{
    return sys::Bus::SendUnicast(
        std::make_shared<CellularPowerStateChange>(newState), ServiceCellular::serviceName, serv);
    return serv->bus.sendUnicast(std::make_shared<CellularPowerStateChange>(newState), ServiceCellular::serviceName);
}

M module-services/service-cellular/CellularUrcHandler.cpp => module-services/service-cellular/CellularUrcHandler.cpp +3 -4
@@ 6,7 6,6 @@
#include "service-cellular/CellularMessage.hpp"
#include "service-cellular/CellularServiceAPI.hpp"

#include <module-sys/Service/Bus.hpp>
#include <service-antenna/AntennaServiceAPI.hpp>
#include <service-evtmgr/Constants.hpp>
#include <service-appmgr/Controller.hpp>


@@ 79,7 78,7 @@ void CellularUrcHandler::Handle(Cusd &urc)
            cellularService.ussdState = ussd::State::pullResponseReceived;
            cellularService.setUSSDTimer();
            auto msg = std::make_shared<CellularMMIResponseMessage>(*message);
            sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellularService);
            cellularService.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
        }
    }
    else {


@@ 87,7 86,7 @@ void CellularUrcHandler::Handle(Cusd &urc)
        cellularService.ussdState = ussd::State::sesionAborted;
        cellularService.setUSSDTimer();
        auto msg = std::make_shared<CellularMMIPushMessage>(*message);
        sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellularService);
        cellularService.bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
    }

    urc.setHandled(true);


@@ 102,7 101,7 @@ void CellularUrcHandler::Handle(Ctze &urc)
    if (isSettingsAutomaticTimeSyncEnabled()) {
        auto msg = std::make_shared<CellularTimeNotificationMessage>(
            urc.getGMTTime(), urc.getTimeZoneOffset(), urc.getTimeZoneString());
        sys::Bus::SendUnicast(msg, service::name::evt_manager, &cellularService);
        cellularService.bus.sendUnicast(msg, service::name::evt_manager);
    }
    else {
        LOG_DEBUG("Timezone sync disabled.");

M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +24 -26
@@ 30,7 30,6 @@
#include <NotificationsRecord.hpp>
#include <PhoneNumber.hpp>
#include <Result.hpp>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>
#include <Service/Timer.hpp>


@@ 151,7 150,7 @@ void State::set(ServiceCellular *owner, ST state)
    LOG_DEBUG("GSM state: (%s) -> (%s)", c_str(this->state), c_str(state));
    this->state = state;
    auto msg    = std::make_shared<StateChange>(state);
    sys::Bus::SendMulticast(msg, sys::BusChannels::ServiceCellularNotifications, owner);
    owner->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
}

State::ST State::get() const


@@ 164,9 163,9 @@ ServiceCellular::ServiceCellular() : sys::Service(serviceName, "", cellularStack

    LOG_INFO("[ServiceCellular] Initializing");

    busChannels.push_back(sys::BusChannels::ServiceCellularNotifications);
    busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
    busChannels.push_back(sys::BusChannels::ServiceEvtmgrNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceEvtmgrNotifications);

    callStateTimer = std::make_unique<sys::Timer>("call_state", this, 1000);
    callStateTimer->connect([&](sys::Timer &) { CallStateTimerHandler(); });


@@ 203,7 202,7 @@ ServiceCellular::ServiceCellular() : sys::Service(serviceName, "", cellularStack
            return;
        }

        sys::Bus::SendMulticast(msg.value(), sys::BusChannels::ServiceCellularNotifications, this);
        bus.sendMulticast(msg.value(), sys::BusChannel::ServiceCellularNotifications);
    };

    packetData = std::make_unique<packet_data::PacketData>(*this); /// call in apnListChanged handler


@@ 229,7 228,7 @@ void ServiceCellular::CallStateTimerHandler()
    LOG_DEBUG("CallStateTimerHandler");
    std::shared_ptr<CellularRequestMessage> msg =
        std::make_shared<CellularRequestMessage>(MessageType::CellularListCurrentCalls);
    sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, this);
    bus.sendUnicast(msg, ServiceCellular::serviceName);
}

sys::ReturnCodes ServiceCellular::InitHandler()


@@ 486,7 485,7 @@ bool ServiceCellular::handle_idle()
bool ServiceCellular::handle_wait_for_start_permission()
{
    auto msg = std::make_shared<CellularCheckIfStartAllowedMessage>();
    sys::Bus::SendUnicast(msg, service::name::system_manager, this);
    bus.sendUnicast(msg, service::name::system_manager);

    return true;
}


@@ 828,7 827,7 @@ sys::MessagePointer ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl,
                if (call.state == ModemCall::CallState::Active) {
                    auto msg =
                        std::make_shared<CellularNotificationMessage>(CellularNotificationMessage::Type::CallActive);
                    sys::Bus::SendMulticast(msg, sys::BusChannels::ServiceCellularNotifications, this);
                    bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
                    callStateTimer->stop();
                }
            }


@@ 873,10 872,9 @@ sys::MessagePointer ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl,
            auto response = channel->cmd(at::AT::ATA);
            if (response) {
                // Propagate "CallActive" notification into system
                sys::Bus::SendMulticast(
                bus.sendMulticast(
                    std::make_shared<CellularNotificationMessage>(CellularNotificationMessage::Type::CallActive),
                    sys::BusChannels::ServiceCellularNotifications,
                    this);
                    sys::BusChannel::ServiceCellularNotifications);
                ret = true;
            }
        }


@@ 960,7 958,7 @@ sys::MessagePointer ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl,

        auto msg  = std::make_shared<cellular::RawCommandRespAsync>(MessageType::CellularNetworkInfoResult);
        msg->data = getNetworkInfo();
        sys::Bus::SendUnicast(msg, msgl->sender, this);
        bus.sendUnicast(msg, msgl->sender);
    } break;
    case MessageType::CellularSelectAntenna: {
        auto msg = dynamic_cast<CellularAntennaRequestMessage *>(msgl);


@@ 973,7 971,7 @@ sys::MessagePointer ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl,
            responseMsg         = std::make_shared<CellularResponseMessage>(changedAntenna);

            auto notification = std::make_shared<AntennaChangedMessage>();
            sys::Bus::SendMulticast(notification, sys::BusChannels::AntennaNotifications, this);
            bus.sendMulticast(notification, sys::BusChannel::AntennaNotifications);
        }
        else {
            responseMsg = std::make_shared<CellularResponseMessage>(false);


@@ 997,7 995,7 @@ sys::MessagePointer ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl,
            responseMsg = std::make_shared<CellularResponseMessage>(true);
            auto msg    = std::make_shared<cellular::RawCommandRespAsync>(MessageType::CellularGetScanModeResult);
            msg->data.push_back(response);
            sys::Bus::SendUnicast(msg, msgl->sender, this);
            bus.sendUnicast(msg, msgl->sender);
            break;
        }
        responseMsg = std::make_shared<CellularResponseMessage>(false);


@@ 1167,7 1165,7 @@ std::optional<std::shared_ptr<CellularMessage>> ServiceCellular::identifyNotific
bool ServiceCellular::requestPin(unsigned int attempts, const std::string msg)
{
    auto message = std::make_shared<CellularSimRequestPinMessage>(Store::GSM::get()->selected, attempts, msg);
    sys::Bus::SendUnicast(message, app::manager::ApplicationManager::ServiceName, this);
    bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
    LOG_DEBUG("REQUEST PIN");
    return true;
}


@@ 1175,7 1173,7 @@ bool ServiceCellular::requestPin(unsigned int attempts, const std::string msg)
bool ServiceCellular::requestPuk(unsigned int attempts, const std::string msg)
{
    auto message = std::make_shared<CellularSimRequestPukMessage>(Store::GSM::get()->selected, attempts, msg);
    sys::Bus::SendUnicast(message, app::manager::ApplicationManager::ServiceName, this);
    bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
    LOG_DEBUG("REQUEST PUK");
    return true;
}


@@ 1183,7 1181,7 @@ bool ServiceCellular::requestPuk(unsigned int attempts, const std::string msg)
bool ServiceCellular::sendSimUnlocked()
{
    auto message = std::make_shared<CellularUnlockSimMessage>(Store::GSM::get()->selected);
    sys::Bus::SendUnicast(message, app::manager::ApplicationManager::ServiceName, this);
    bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
    LOG_DEBUG("SIM UNLOCKED");
    return true;
}


@@ 1191,7 1189,7 @@ bool ServiceCellular::sendSimUnlocked()
bool ServiceCellular::sendSimBlocked()
{
    auto message = std::make_shared<CellularBlockSimMessage>(Store::GSM::get()->selected);
    sys::Bus::SendUnicast(message, app::manager::ApplicationManager::ServiceName, this);
    bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
    LOG_ERROR("SIM BLOCKED");
    return true;
}


@@ 1199,7 1197,7 @@ bool ServiceCellular::sendSimBlocked()
bool ServiceCellular::sendUnhandledCME(unsigned int cme_error)
{
    auto message = std::make_shared<CellularDisplayCMEMessage>(Store::GSM::get()->selected, cme_error);
    sys::Bus::SendUnicast(message, app::manager::ApplicationManager::ServiceName, this);
    bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
    LOG_ERROR("UNHANDLED CME %d", cme_error);
    return true;
}


@@ 1317,7 1315,7 @@ bool ServiceCellular::handleSimState(at::SimState state, const std::string messa
        // SIM causes SIM INIT, only on ready
        response =
            std::move(std::make_unique<CellularNotificationMessage>(CellularNotificationMessage::Type::SIM_READY));
        sys::Bus::SendMulticast(response, sys::BusChannels::ServiceCellularNotifications, this);
        bus.sendMulticast(response, sys::BusChannel::ServiceCellularNotifications);
        sendSimUnlocked();
        break;
    case at::SimState::NotReady:


@@ 1325,7 1323,7 @@ bool ServiceCellular::handleSimState(at::SimState state, const std::string messa
        Store::GSM::get()->sim = Store::GSM::SIM::SIM_FAIL;
        response =
            std::move(std::make_unique<CellularNotificationMessage>(CellularNotificationMessage::Type::SIM_NOT_READY));
        sys::Bus::SendMulticast(response, sys::BusChannels::ServiceCellularNotifications, this);
        bus.sendMulticast(response, sys::BusChannel::ServiceCellularNotifications);
        break;
    case at::SimState::SimPin: {
        SimCard simCard(*this);


@@ 1381,7 1379,7 @@ bool ServiceCellular::handleSimState(at::SimState state, const std::string messa
        break;
    }
    auto simMessage = std::make_shared<sevm::SIMMessage>();
    sys::Bus::SendUnicast(simMessage, service::name::evt_manager, this);
    bus.sendUnicast(simMessage, service::name::evt_manager);

    return true;
}


@@ 1802,7 1800,7 @@ bool ServiceCellular::handle_select_sim()
            // NO SIM IN
            Store::GSM::get()->sim = Store::GSM::SIM::SIM_FAIL;
        }
        sys::Bus::SendUnicast(std::make_shared<sevm::SIMMessage>(), service::name::evt_manager, this);
        bus.sendUnicast(std::make_shared<sevm::SIMMessage>(), service::name::evt_manager);
        bool ready = false;
        while (!ready) {
            auto response = channel->cmd("AT+CPIN?");


@@ 2025,7 2023,7 @@ void ServiceCellular::handle_CellularGetChannelMessage()
        std::shared_ptr<CellularGetChannelResponseMessage> channelResponsMessage =
            std::make_shared<CellularGetChannelResponseMessage>(cmux->get(getChannelMsg->dataChannel));
        LOG_DEBUG("channel ptr: %p", channelResponsMessage->dataChannelPtr);
        sys::Bus::SendUnicast(std::move(channelResponsMessage), req->sender, this);
        bus.sendUnicast(std::move(channelResponsMessage), req->sender);
        return sys::MessageNone{};
    });
}


@@ 2189,7 2187,7 @@ std::shared_ptr<cellular::RawCommandRespAsync> ServiceCellular::handleCellularSt
    auto ret = std::make_shared<cellular::RawCommandRespAsync>(MessageType::CellularOperatorsScanResult);
    NetworkSettings networkSettings(*this);
    ret->data = networkSettings.scanOperators(msg->getFullInfo());
    sys::Bus::SendUnicast(ret, msg->sender, this);
    bus.sendUnicast(ret, msg->sender);
    return ret;
}


M module-services/service-db/DBServiceAPI.cpp => module-services/service-db/DBServiceAPI.cpp +15 -19
@@ 16,8 16,8 @@
#include <MessageType.hpp>
#include <PhoneNumber.hpp>
#include <SMSTemplateRecord.hpp>
#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <Service/Service.hpp>
#include <Tables/CountryCodesTable.hpp>
#include <ThreadRecord.hpp>
#include <Utils.hpp>


@@ 27,10 27,6 @@
#include <utility>
#include <cassert>

namespace sys
{
    class Service;
} // namespace sys
struct NotesRecord;

auto DBServiceAPI::ThreadGetByNumber(sys::Service *serv,


@@ 58,7 54,7 @@ auto DBServiceAPI::ThreadGetCount(sys::Service *serv, EntryState state) -> uint3
{
    auto msg = std::make_shared<DBThreadGetCountMessage>(state);

    auto ret            = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret            = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto threadResponse = dynamic_cast<DBThreadResponseMessage *>(ret.second.get());
    if (threadResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 92,7 88,7 @@ auto DBServiceAPI::ContactGetByIDWithTemporary(sys::Service *serv, uint32_t cont
auto DBServiceAPI::ContactGetByIDCommon(sys::Service *serv, std::shared_ptr<DBContactMessage> contactMsg)
    -> std::unique_ptr<std::vector<ContactRecord>>
{
    auto ret             = sys::Bus::SendUnicast(contactMsg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(contactMsg, service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 137,7 133,7 @@ auto DBServiceAPI::MatchContactByPhoneNumber(sys::Service *serv, const utils::Ph
{
    auto msg = std::make_shared<DBContactNumberMessage>(numberView);

    auto ret             = sys::Bus::SendUnicast(std::move(msg), service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(std::move(msg), service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactNumberResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr || contactResponse->retCode != sys::ReturnCodes::Success) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 187,7 183,7 @@ auto DBServiceAPI::ContactAdd(sys::Service *serv, const ContactRecord &rec) -> b
{
    std::shared_ptr<DBContactMessage> msg = std::make_shared<DBContactMessage>(MessageType::DBContactAdd, rec);

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 204,7 200,7 @@ auto DBServiceAPI::ContactRemove(sys::Service *serv, uint32_t id) -> bool
    std::shared_ptr<DBContactMessage> msg = std::make_shared<DBContactMessage>(MessageType::DBContactRemove);
    msg->id                               = id;

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 220,7 216,7 @@ auto DBServiceAPI::ContactUpdate(sys::Service *serv, const ContactRecord &rec) -
{
    std::shared_ptr<DBContactMessage> msg = std::make_shared<DBContactMessage>(MessageType::DBContactUpdate, rec);

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 241,7 237,7 @@ auto DBServiceAPI::ContactSearch(sys::Service *serv, UTF8 primaryName, UTF8 alte
                                                 (alternativeName.length() > 0) ? alternativeName.c_str() : "",
                                                 (number.length() > 0) ? number.c_str() : "");

    auto ret             = sys::Bus::SendUnicast(std::move(msg), service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(std::move(msg), service::name::db, DefaultTimeoutInMs);
    auto contactResponse = dynamic_cast<DBContactResponseMessage *>(ret.second.get());
    if (contactResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 259,7 255,7 @@ auto DBServiceAPI::CalllogAdd(sys::Service *serv, const CalllogRecord &rec) -> C

    LOG_DEBUG("CalllogAdd %s", utils::to_string(rec).c_str());

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto calllogResponse = dynamic_cast<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 280,7 276,7 @@ auto DBServiceAPI::CalllogRemove(sys::Service *serv, uint32_t id) -> bool
    std::shared_ptr<DBCalllogMessage> msg = std::make_shared<DBCalllogMessage>(MessageType::DBCalllogRemove);
    msg->id                               = id;

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto calllogResponse = dynamic_cast<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 298,7 294,7 @@ auto DBServiceAPI::CalllogUpdate(sys::Service *serv, const CalllogRecord &rec) -

    LOG_DEBUG("CalllogUpdate %s", utils::to_string(rec).c_str());

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto calllogResponse = dynamic_cast<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 314,7 310,7 @@ auto DBServiceAPI::CalllogGetCount(sys::Service *serv, EntryState state) -> uint
{
    std::shared_ptr<DBCalllogMessage> msg = std::make_shared<DBCalllogGetCount>(state);

    auto ret             = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret             = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto calllogResponse = dynamic_cast<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 332,7 328,7 @@ auto DBServiceAPI::CalllogGetLimitOffset(sys::Service *serv, uint32_t offset, ui
    msg->offset                           = offset;
    msg->limit                            = limit;

    sys::Bus::SendUnicast(msg, service::name::db, serv);
    serv->bus.sendUnicast(msg, service::name::db);
    return true;
}



@@ 341,7 337,7 @@ auto DBServiceAPI::GetCountryCodeByMCC(sys::Service *serv, uint32_t mcc) -> uint
    std::shared_ptr<DBCountryCodeMessage> msg =
        std::make_shared<DBCountryCodeMessage>(MessageType::DBCountryCode, mcc, 0);

    auto ret      = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret      = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    auto response = dynamic_cast<DBCountryCodeResponseMessage *>(ret.second.get());
    if (response == nullptr) {
        LOG_ERROR("DB response error, return code: %s", c_str(ret.first));


@@ 360,7 356,7 @@ auto DBServiceAPI::DBBackup(sys::Service *serv, std::string backupPath) -> bool
    std::shared_ptr<DBServiceMessageBackup> msg =
        std::make_shared<DBServiceMessageBackup>(MessageType::DBServiceBackup, backupPath);

    auto ret = sys::Bus::SendUnicast(msg, service::name::db, serv, DefaultTimeoutInMs);
    auto ret = serv->bus.sendUnicast(msg, service::name::db, DefaultTimeoutInMs);
    if (ret.first == sys::ReturnCodes::Success) {
        return true;
    }

M module-services/service-db/DBServiceAPI_GetByQuery.cpp => module-services/service-db/DBServiceAPI_GetByQuery.cpp +3 -7
@@ 6,8 6,8 @@
#include "service-db/QueryMessage.hpp"

#include <BaseInterface.hpp>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>

#include <cstdint>
#include <memory>


@@ 17,17 17,13 @@ namespace db
{
    class Query;
} // namespace db
namespace sys
{
    class Service;
} // namespace sys

std::pair<bool, std::uint64_t> DBServiceAPI::GetQuery(sys::Service *serv,
                                                      db::Interface::Name database,
                                                      std::unique_ptr<db::Query> query)
{
    auto msg = std::make_shared<db::QueryMessage>(database, std::move(query));
    const auto isSuccess = sys::Bus::SendUnicast(msg, service::name::db, serv);
    const auto isSuccess = serv->bus.sendUnicast(msg, service::name::db);
    return std::make_pair(isSuccess, msg->uniID);
}



@@ 37,5 33,5 @@ sys::SendResult DBServiceAPI::GetQueryWithReply(sys::Service *serv,
                                                std::uint32_t timeout)
{
    auto msg = std::make_shared<db::QueryMessage>(database, std::move(query));
    return sys::Bus::SendUnicast(msg, service::name::db, serv, timeout);
    return serv->bus.sendUnicast(msg, service::name::db, timeout);
}

M module-services/service-db/ServiceDB.cpp => module-services/service-db/ServiceDB.cpp +1 -2
@@ 37,7 37,6 @@
#include <purefs/filesystem_paths.hpp>
#include <SMSRecord.hpp>
#include <SMSTemplateRecord.hpp>
#include <Service/Bus.hpp>
#include <Tables/Record.hpp>
#include <ThreadRecord.hpp>
#include <log/log.hpp>


@@ 574,7 573,7 @@ sys::ReturnCodes ServiceDB::SwitchPowerModeHandler(const sys::ServicePowerMode m
void ServiceDB::sendUpdateNotification(db::Interface::Name interface, db::Query::Type type)
{
    auto notificationMessage = std::make_shared<db::NotificationMessage>(interface, type);
    sys::Bus::SendMulticast(notificationMessage, sys::BusChannels::ServiceDBNotifications, this);
    bus.sendMulticast(notificationMessage, sys::BusChannel::ServiceDBNotifications);
}

bool ServiceDB::StoreIntoBackup(const std::string &backupPath)

M module-services/service-db/agents/file_indexer/FileIndexerAgent.cpp => module-services/service-db/agents/file_indexer/FileIndexerAgent.cpp +9 -10
@@ 5,7 5,6 @@
#include "FileIndexer_queries.hpp"

#include <log/log.hpp>
#include <module-sys/Service/Bus.hpp>
#include <purefs/filesystem_paths.hpp>
#include <Application.hpp>
#include <memory>


@@ 329,13 328,13 @@ auto FileIndexerAgent::handleSetRecord(sys::Message *req) -> sys::MessagePointer
            auto updateMsg = std::make_shared<FileIndexer::Messages::RecordChangedMessage>(
                std::move(recordPtr), std::make_unique<FileIndexer::FileRecord>(msg->dbRecord));

            sys::Bus::SendUnicast(std::move(updateMsg), msg->sender, parentService);
            parentService->bus.sendUnicast(std::move(updateMsg), msg->sender);
            dbSetRecord(std::make_unique<FileIndexer::FileRecord>(record));

            for (auto recipient : fileChangeRecipents[record.directory]) {
                auto notifyMsg = std::make_shared<FileIndexer::Messages::DirectoryContentChangedMessage>(
                    std::make_unique<std::string>(record.directory));
                sys::Bus::SendUnicast(std::move(notifyMsg), recipient, parentService);
                parentService->bus.sendUnicast(std::move(notifyMsg), recipient);
            }
        }
    }


@@ 351,13 350,13 @@ auto FileIndexerAgent::handleDeleteFile(sys::Message *req) -> sys::MessagePointe

        auto deleteMsg = std::make_shared<FileIndexer::Messages::FileDeletedMessage>(std::move(recordPtr));

        sys::Bus::SendUnicast(std::move(deleteMsg), msg->sender, parentService);
        parentService->bus.sendUnicast(std::move(deleteMsg), msg->sender);
        dbDeleteFile(std::make_unique<FileIndexer::FileRecord>(record));

        for (auto recipient : fileChangeRecipents[record.directory]) {
            auto notifyMsg = std::make_shared<FileIndexer::Messages::DirectoryContentChangedMessage>(
                std::make_unique<std::string>(record.directory));
            sys::Bus::SendUnicast(std::move(notifyMsg), recipient, parentService);
            parentService->bus.sendUnicast(std::move(notifyMsg), recipient);
        }
    }
    return app::msgHandled();


@@ 373,13 372,13 @@ auto FileIndexerAgent::handleDeleteAllFilesInDir(sys::Message *req) -> sys::Mess
        auto deleteMsg =
            std::make_shared<FileIndexer::Messages::AllFilesInDirDeletedDeletedMessage>(std::move(recordPtr));

        sys::Bus::SendUnicast(std::move(deleteMsg), msg->sender, parentService);
        parentService->bus.sendUnicast(std::move(deleteMsg), msg->sender);
        dbDeleteAllFilesInDir(std::make_unique<FileIndexer::FileRecord>(record));

        for (auto recipient : fileChangeRecipents[record.directory]) {
            auto notifyMsg = std::make_shared<FileIndexer::Messages::DirectoryContentChangedMessage>(
                std::make_unique<std::string>(record.directory));
            sys::Bus::SendUnicast(std::move(notifyMsg), recipient, parentService);
            parentService->bus.sendUnicast(std::move(notifyMsg), recipient);
        }
    }
    return app::msgHandled();


@@ 541,7 540,7 @@ auto FileIndexerAgent::handleSetProperty(sys::Message *req) -> sys::MessagePoint
        if (dbValue != value) {
            auto updateMsg = std::make_shared<FileIndexer::Messages::PropertyChangedMessage>(
                std::move(metaDataPtr), std::make_unique<FileIndexer::FileMetadata>(msg->dbMetaData));
            sys::Bus::SendUnicast(std::move(updateMsg), msg->sender, parentService);
            parentService->bus.sendUnicast(std::move(updateMsg), msg->sender);
            dbSetProperty(std::make_unique<FileIndexer::FileMetadata>(metaData));
        }
    }


@@ 556,13 555,13 @@ auto FileIndexerAgent::handleSetProperties(sys::Message *req) -> sys::MessagePoi
        msg->dbMetaData                    = dbGetAllProperties(std::make_unique<FileIndexer::FileMetadata>(metaData));
        auto updateMsg                     = std::make_shared<FileIndexer::Messages::PropertyChangedMessage>(
            std::move(metaDataPtr), std::make_unique<FileIndexer::FileMetadata>(msg->dbMetaData));
        sys::Bus::SendUnicast(std::move(updateMsg), msg->sender, parentService);
        parentService->bus.sendUnicast(std::move(updateMsg), msg->sender);
        dbSetProperties(std::make_unique<FileIndexer::FileMetadata>(metaData));

        for (auto recipient : fileChangeRecipents[metaData.directory]) {
            auto notifyMsg = std::make_shared<FileIndexer::Messages::DirectoryContentChangedMessage>(
                std::make_unique<std::string>(metaData.directory));
            sys::Bus::SendUnicast(std::move(notifyMsg), recipient, parentService);
            parentService->bus.sendUnicast(std::move(notifyMsg), recipient);
        }
    }
    return app::msgHandled();

M module-services/service-db/agents/settings/Settings.cpp => module-services/service-db/agents/settings/Settings.cpp +2 -5
@@ 4,7 4,6 @@
#include <service-db/Settings.hpp>
#include <service-db/SettingsMessages.hpp>

#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>


@@ 18,20 17,18 @@ namespace settings
    Settings::Settings(sys::Service *app, const std::string &dbAgentName) : dbAgentName(dbAgentName)
    {
        this->app = std::shared_ptr<sys::Service>(app, [](sys::Service *) {}); /// with deleter that doesn't delete.
        this->app->busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        sys::Bus::Add(std::static_pointer_cast<sys::Service>(this->app));
        this->app->bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
        registerHandlers();
    }

    Settings::~Settings()
    {
        LOG_DEBUG("Settings::~Settings on %s", app->GetName().c_str());
        sys::Bus::Remove(std::static_pointer_cast<sys::Service>(app));
    }

    void Settings::sendMsg(std::shared_ptr<settings::Messages::SettingsMessage> &&msg)
    {
        sys::Bus::SendUnicast(std::move(msg), dbAgentName, app.get());
        app->bus.sendUnicast(std::move(msg), dbAgentName);
    }

    void Settings::registerHandlers()

M module-services/service-db/agents/settings/SettingsAgent.cpp => module-services/service-db/agents/settings/SettingsAgent.cpp +12 -13
@@ 6,7 6,6 @@

#include <Database/Database.hpp>
#include <Service/Service.hpp>
#include <module-sys/Service/Bus.hpp>
#include <purefs/filesystem_paths.hpp>

namespace settings::DbPaths


@@ 215,7 214,7 @@ auto SettingsAgent::handleSetVariable(sys::Message *req) -> sys::MessagePointer
                if (regPath.service != path.service) {
                    auto updateMsg =
                        std::make_shared<settings::Messages::VariableChanged>(regPath, value, oldValue.value_or(""));
                    sys::Bus::SendUnicast(std::move(updateMsg), regPath.service, parentService);
                    parentService->bus.sendUnicast(std::move(updateMsg), regPath.service);
                    LOG_DEBUG("[SettingsAgent::handleSetVariable] notified service: %s", regPath.service.c_str());
                }
            }


@@ 234,7 233,7 @@ auto SettingsAgent::handleRegisterOnVariableChange(sys::Message *req) -> sys::Me
                variableChangeRecipents[path.to_string()] = {path};
                auto currentValue                         = dbGetValue(path).value_or("");
                auto msgValue = std::make_shared<::settings::Messages::VariableChanged>(path, currentValue, "");
                sys::Bus::SendUnicast(std::move(msgValue), msg->sender, parentService);
                parentService->bus.sendUnicast(std::move(msgValue), msg->sender);
                LOG_DEBUG("[SettingsAgent::handleRegisterOnVariableChange] %s=%s to %s",
                          path.to_string().c_str(),
                          currentValue.c_str(),


@@ 270,7 269,7 @@ auto SettingsAgent::handleRegisterProfileChange(sys::Message *req) -> sys::Messa
        if (dbRegisterOnProfileChange(msg->sender)) {
            profileChangedRecipents.insert(msg->sender);
            auto msgCurrentProfile = std::make_shared<settings::Messages::CurrentProfileChanged>(dbGetCurrentProfile());
            sys::Bus::SendUnicast(std::move(msgCurrentProfile), msg->sender, parentService);
            parentService->bus.sendUnicast(std::move(msgCurrentProfile), msg->sender);
        }
    }
    return std::make_shared<sys::ResponseMessage>();


@@ 292,7 291,7 @@ auto SettingsAgent::handleSetCurrentProfile(sys::Message *req) -> sys::MessagePo
            for (auto service : profileChangedRecipents) {
                if (service != msg->sender) {
                    auto msgProfileChanged = std::make_shared<settings::Messages::CurrentProfileChanged>(profile);
                    sys::Bus::SendUnicast(std::move(msgProfileChanged), service, parentService);
                    parentService->bus.sendUnicast(std::move(msgProfileChanged), service);
                }
            }
        }


@@ 305,7 304,7 @@ auto SettingsAgent::handleGetCurrentProfile(sys::Message *req) -> sys::MessagePo
        auto service = profileChangedRecipents.find(req->sender);
        if (profileChangedRecipents.end() != service) {
            auto msgCurrentProfile = std::make_shared<settings::Messages::CurrentProfileChanged>(dbGetCurrentProfile());
            sys::Bus::SendUnicast(std::move(msgCurrentProfile), *service, parentService);
            parentService->bus.sendUnicast(std::move(msgCurrentProfile), *service);
        }
    }
    return std::make_shared<sys::ResponseMessage>();


@@ 318,7 317,7 @@ auto SettingsAgent::handleAddProfile(sys::Message *req) -> sys::MessagePointer
            for (auto service : profileChangedRecipents) {
                if (service != req->sender) {
                    auto msgAllProfiles = std::make_shared<settings::Messages::ProfileListResponse>(allProfiles);
                    sys::Bus::SendUnicast(std::move(msgAllProfiles), service, parentService);
                    parentService->bus.sendUnicast(std::move(msgAllProfiles), service);
                }
            }
        }


@@ 330,7 329,7 @@ auto SettingsAgent::handleListProfiles(sys::Message *req) -> sys::MessagePointer
    if (nullptr != dynamic_cast<settings::Messages::ListProfiles *>(req)) {
        profileChangedRecipents.insert(req->sender);
        auto msgAllProfiles = std::make_shared<settings::Messages::ProfileListResponse>(dbGetAllProfiles());
        sys::Bus::SendUnicast(std::move(msgAllProfiles), req->sender, parentService);
        parentService->bus.sendUnicast(std::move(msgAllProfiles), req->sender);
    }
    return std::make_shared<sys::ResponseMessage>();
}


@@ 342,7 341,7 @@ auto SettingsAgent::handleRegisterOnModeChange(sys::Message *req) -> sys::Messag
        if (dbRegisterOnModeChange(msg->sender)) {
            modeChangeRecipents.insert(msg->sender);
            auto msgMode = std::make_shared<settings::Messages::CurrentModeChanged>(dbGetCurrentMode());
            sys::Bus::SendUnicast(std::move(msgMode), msg->sender, parentService);
            parentService->bus.sendUnicast(std::move(msgMode), msg->sender);
        }
    }
    return std::make_shared<sys::ResponseMessage>();


@@ 364,7 363,7 @@ auto SettingsAgent::handleSetCurrentMode(sys::Message *req) -> sys::MessagePoint
                for (auto service : modeChangeRecipents) {
                    if (service != msg->sender) {
                        auto msgModeChanged = std::make_shared<settings::Messages::CurrentModeChanged>(newMode);
                        sys::Bus::SendUnicast(std::move(msgModeChanged), service, parentService);
                        parentService->bus.sendUnicast(std::move(msgModeChanged), service);
                    }
                }
            }


@@ 377,7 376,7 @@ auto SettingsAgent::handleGetCurrentMode(sys::Message *req) -> sys::MessagePoint
    if (nullptr != dynamic_cast<settings::Messages::GetCurrentMode *>(req)) {
        if (modeChangeRecipents.end() != modeChangeRecipents.find(req->sender)) {
            auto msgMode = std::make_shared<settings::Messages::CurrentModeChanged>(dbGetCurrentMode());
            sys::Bus::SendUnicast(std::move(msgMode), req->sender, parentService);
            parentService->bus.sendUnicast(std::move(msgMode), req->sender);
        }
    }
    return std::make_shared<sys::ResponseMessage>();


@@ 390,7 389,7 @@ auto SettingsAgent::handleAddMode(sys::Message *req) -> sys::MessagePointer
            for (auto service : modeChangeRecipents) {
                if (service != msg->sender) {
                    auto msgAllModes = std::make_shared<settings::Messages::ModeListResponse>(allModes);
                    sys::Bus::SendUnicast(std::move(msgAllModes), service, parentService);
                    parentService->bus.sendUnicast(std::move(msgAllModes), service);
                }
            }
        }


@@ 402,7 401,7 @@ auto SettingsAgent::handleListModes(sys::Message *req) -> sys::MessagePointer
    if (nullptr != dynamic_cast<settings::Messages::ListModes *>(req)) {
        modeChangeRecipents.insert(req->sender);
        auto msgAllModes = std::make_shared<settings::Messages::ModeListResponse>(dbGetAllModes());
        sys::Bus::SendUnicast(std::move(msgAllModes), req->sender, parentService);
        parentService->bus.sendUnicast(std::move(msgAllModes), req->sender);
    }
    return std::make_shared<sys::ResponseMessage>();
}

M module-services/service-db/service-db/DBServiceAPI.hpp => module-services/service-db/service-db/DBServiceAPI.hpp +0 -1
@@ 12,7 12,6 @@
#include <Interface/SMSTemplateRecord.hpp>
#include <Interface/ThreadRecord.hpp>
#include <PhoneNumber.hpp>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <utf8/UTF8.hpp>


M module-services/service-db/test/test-service-db-settings-messages.cpp => module-services/service-db/test/test-service-db-settings-messages.cpp +15 -19
@@ 4,7 4,6 @@
#include <catch2/catch.hpp>           // for Section, SourceLineInfo, SECTION, SectionInfo, StringRef, TEST_CASE
#include <Service/Service.hpp>        // for Service
#include <Service/Message.hpp>        // for MessagePointer, ResponseMessage, DataMessage
#include <module-sys/Service/Bus.hpp> // for Bus
#include <functional>                 // for _Bind_helper<>::type, _Placeholder, bind, _1, _2
#include <list>                       // for list
#include <memory>                     // for make_shared, allocator, shared_ptr


@@ 80,7 79,7 @@ namespace settings
                auto old_value = setValue(path, msg->getValue().value_or(""));

                auto update_msg = std::make_shared<settings::Messages::VariableChanged>(path, value, old_value);
                sys::Bus::SendUnicast(std::move(update_msg), "db-worker", this);
                bus.sendUnicast(std::move(update_msg), "db-worker");
            }
            return std::make_shared<sys::ResponseMessage>();
        };


@@ 118,15 117,13 @@ TEST_CASE("Settings Messages")
        settings::Service settings("settings");
        settings.InitHandler();

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::RegisterOnVariableChange>(settings::EntryPath(
                                  {"mode", "service", "profile", "variable", settings::SettingsScope::AppLocal})),
                              "db-worker",
                              &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::RegisterOnVariableChange>(settings::EntryPath(
                                     {"mode", "service", "profile", "variable", settings::SettingsScope::AppLocal})),
                                 "db-worker");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::UnregisterOnVariableChange>(settings::EntryPath(
                                  {"mode", "service", "profile", "variable", settings::SettingsScope::AppLocal})),
                              "db-worker",
                              &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::UnregisterOnVariableChange>(settings::EntryPath(
                                     {"mode", "service", "profile", "variable", settings::SettingsScope::AppLocal})),
                                 "db-worker");
    }

    SECTION("Send profile messages")


@@ 134,14 131,13 @@ TEST_CASE("Settings Messages")
        settings::Service settings("settings");
        settings.InitHandler();

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::ListProfiles>(), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::ListProfiles>(), "settings");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::AddProfile>("new-profile"), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::AddProfile>("new-profile"), "settings");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::GetCurrentProfile>(), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::GetCurrentProfile>(), "settings");

        sys::Bus::SendUnicast(
            std::make_shared<settings::Messages::CurrentProfileChanged>("profile"), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::CurrentProfileChanged>("profile"), "settings");
    }

    SECTION("Send mode messages")


@@ 149,12 145,12 @@ TEST_CASE("Settings Messages")
        settings::Service settings("settings");
        settings.InitHandler();

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::ListModes>(), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::ListModes>(), "settings");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::GetCurrentMode>(), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::GetCurrentMode>(), "settings");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::AddMode>("new-mode"), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::AddMode>("new-mode"), "settings");

        sys::Bus::SendUnicast(std::make_shared<settings::Messages::CurrentModeChanged>("mode"), "settings", &settings);
        settings.bus.sendUnicast(std::make_shared<settings::Messages::CurrentModeChanged>("mode"), "settings");
    }
}

M module-services/service-db/test/test-settings/test-service-db-settings-api.cpp => module-services/service-db/test/test-settings/test-service-db-settings-api.cpp +3 -3
@@ 89,13 89,13 @@ TEST_CASE("SettingsApi")
            std::cout << "koniec start thr_id: " << std::this_thread::get_id() << std::endl << std::flush;
            testStart->unlock();
            auto msgStart = std::make_shared<settings::UTMsg::UTMsgStart>();
            sys::Bus::SendUnicast(std::move(msgStart), "appTest", manager.get());
            manager->bus.sendUnicast(std::move(msgStart), "appTest");

            msgStart = std::make_shared<settings::UTMsg::UTMsgStart>();
            sys::Bus::SendUnicast(std::move(msgStart), "appTestProfile", manager.get());
            manager->bus.sendUnicast(std::move(msgStart), "appTestProfile");

            msgStart = std::make_shared<settings::UTMsg::UTMsgStart>();
            sys::Bus::SendUnicast(std::move(msgStart), "appTestMode", manager.get());
            manager->bus.sendUnicast(std::move(msgStart), "appTestMode");

            return ret;
        });

M module-services/service-db/test/test-settings/test-service-db-settings-testapps.hpp => module-services/service-db/test/test-settings/test-service-db-settings-testapps.hpp +12 -12
@@ 89,7 89,7 @@ namespace settings
                else {
                    state    = State::Start;
                    auto msg = std::make_shared<settings::UTMsg::ReqRegValChg>("brightness", "none");
                    sys::Bus::SendUnicast(std::move(msg), getter->GetName(), this);
                    bus.sendUnicast(std::move(msg), getter->GetName());
                }
            }
            else if (nullptr != dynamic_cast<settings::UTMsg::CnfRegValChg *>(msg)) {


@@ 102,13 102,13 @@ namespace settings
                    state = State::RegisterStartVal;
                    v.push_back(m->value);
                    auto msg = std::make_shared<settings::UTMsg::ReqSetVal>("brightness", v[0] + "1");
                    sys::Bus::SendUnicast(std::move(msg), setter->GetName(), this);
                    bus.sendUnicast(std::move(msg), setter->GetName());
                }
                else if (state == State::RegisterSetVal) {
                    if (m->value == v[0] + "1") {
                        v.push_back(m->value);
                        auto msg = std::make_shared<settings::UTMsg::ReqUnRegValChg>("brightness", "empty");
                        sys::Bus::SendUnicast(std::move(msg), getter->GetName(), this);
                        bus.sendUnicast(std::move(msg), getter->GetName());
                        state = State::UnregisterWait;
                    }
                }


@@ 117,7 117,7 @@ namespace settings
                if (state == State::UnregisterWait) {
                    state    = State::Unregister;
                    auto msg = std::make_shared<settings::UTMsg::ReqSetVal>("brightness", v.back() + "2");
                    sys::Bus::SendUnicast(std::move(msg), setter->GetName(), this);
                    bus.sendUnicast(std::move(msg), setter->GetName());
                }
            }
            else if (auto m = dynamic_cast<settings::UTMsg::CnfReqSetVal *>(msg)) {


@@ 128,7 128,7 @@ namespace settings
                    std::this_thread::sleep_for(std::chrono::milliseconds(200));
                    v.push_back(m->value);
                    auto msg = std::make_shared<settings::UTMsg::UTMsgStop>();
                    sys::Bus::SendUnicast(std::move(msg), GetName(), this);
                    bus.sendUnicast(std::move(msg), GetName());
                }
            }
            else if (nullptr != dynamic_cast<settings::UTMsg::UTMsgStop *>(msg)) {


@@ 162,7 162,7 @@ namespace settings
                else {
                    state    = State::Start;
                    auto msg = std::make_shared<settings::UTMsg::ReqRegProfileChg>();
                    sys::Bus::SendUnicast(std::move(msg), getter->GetName(), this);
                    bus.sendUnicast(std::move(msg), getter->GetName());
                }
            }
            else if (nullptr != dynamic_cast<settings::UTMsg::CnfRegProfileChg *>(msg)) {


@@ 175,13 175,13 @@ namespace settings
                    state = State::RegisterStartVal;
                    v.push_back(m->name);
                    auto msg = std::make_shared<settings::UTMsg::ReqSetCurrentProfile>(m->name + "1");
                    sys::Bus::SendUnicast(std::move(msg), setter->GetName(), this);
                    bus.sendUnicast(std::move(msg), setter->GetName());
                }
                else if (state == State::RegisterSetVal) {
                    if (m->name == v[0] + "1") {
                        v.push_back(m->name);
                        auto msg = std::make_shared<settings::UTMsg::ReqUnRegProfileChg>();
                        sys::Bus::SendUnicast(std::move(msg), getter->GetName(), this);
                        bus.sendUnicast(std::move(msg), getter->GetName());
                        state = State::UnregisterWait;
                    }
                }


@@ 190,7 190,7 @@ namespace settings
                if (state == State::UnregisterWait) {
                    state    = State::Unregister;
                    auto msg = std::make_shared<settings::UTMsg::ReqSetCurrentProfile>(v.back() + "2");
                    sys::Bus::SendUnicast(std::move(msg), setter->GetName(), this);
                    bus.sendUnicast(std::move(msg), setter->GetName());
                }
            }
            else if (auto m = dynamic_cast<settings::UTMsg::CnfSetCurrentProfile *>(msg)) {


@@ 200,7 200,7 @@ namespace settings
                else if (state == State::Unregister) {
                    v.push_back(m->name);
                    auto msg = std::make_shared<settings::UTMsg::ReqGetAllProfiles>();
                    sys::Bus::SendUnicast(std::move(msg), getter->GetName(), this);
                    bus.sendUnicast(std::move(msg), getter->GetName());
                }
            }
            else if (nullptr != dynamic_cast<settings::UTMsg::CnfGetAllProfiles *>(msg)) {


@@ 215,7 215,7 @@ namespace settings
                        v.push_back(prof);
                    }
                    auto msg = std::make_shared<settings::UTMsg::ReqAddProfile>("other");
                    sys::Bus::SendUnicast(std::move(msg), setter->GetName(), this);
                    bus.sendUnicast(std::move(msg), setter->GetName());
                }
                else if (state == State::RegisterAllAddWait) {
                    state = State::RegisterAllAdd;


@@ 224,7 224,7 @@ namespace settings
                    }
                    std::this_thread::sleep_for(std::chrono::milliseconds(200));
                    auto msg = std::make_shared<settings::UTMsg::UTMsgStop>();
                    sys::Bus::SendUnicast(std::move(msg), GetName(), this);
                    bus.sendUnicast(std::move(msg), GetName());
                }
            }
            else if (nullptr != dynamic_cast<settings::UTMsg::CnfAddProfile *>(msg)) {

M module-services/service-db/test/test-settings/test-service-db-settings-testservices.hpp => module-services/service-db/test/test-settings/test-service-db-settings-testservices.hpp +18 -19
@@ 32,26 32,25 @@ namespace settings
                                                ([this](std::string value) {
                                                    ValueChanged(value);
                                                    auto cnf = std::make_shared<settings::UTMsg::CnfValChg>("", value);
                                                    sys::Bus::SendUnicast(
                                                        std::move(cnf), whoRequestedNotifyOnChange, this);
                                                    bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
                                                }),
                                                settings::SettingsScope::Global);
                auto cnf = std::make_shared<settings::UTMsg::CnfRegValChg>(msg->name, msg->value);
                sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqUnRegValChg *>(req)) {
                // unregister
                debug("ReqUnRegValChg", msg->name, msg->value);
                mySettings->unregisterValueChange(msg->name, settings::SettingsScope::Global);
                auto cnf = std::make_shared<settings::UTMsg::CnfUnRegValChg>(msg->name, msg->value);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqSetVal *>(req)) {
                // set value
                debug("ReqSetVal", msg->name, msg->value);
                mySettings->setValue(msg->name, msg->value, settings::SettingsScope::Global);
                auto cnf = std::make_shared<settings::UTMsg::CnfReqSetVal>(msg->name, msg->value);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (dynamic_cast<settings::UTMsg::ReqGetVal *>(msg)) {
                debug("ReqGetValChg", msg->name, msg->value);


@@ 89,40 88,40 @@ namespace settings
                mySettings->registerProfileChange(([this](const std::string &profile) {
                    this->profile = profile;
                    auto cnf      = std::make_shared<settings::UTMsg::ProfileChg>(profile);
                    sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                    bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
                }));
                auto cnf = std::make_shared<settings::UTMsg::CnfRegProfileChg>();
                sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqUnRegProfileChg *>(req)) {
                // unregister
                debug("ReqUnRegProfileChg", msg->name, msg->value);
                mySettings->unregisterProfileChange();
                auto cnf = std::make_shared<settings::UTMsg::CnfUnRegProfileChg>();
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqSetCurrentProfile *>(req)) {
                // set value
                debug("ReqSetCurrentProfile", msg->name, msg->value);
                mySettings->setCurrentProfile(msg->name);
                auto cnf = std::make_shared<settings::UTMsg::CnfSetCurrentProfile>(msg->name);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqGetAllProfiles *>(req)) {
                debug("ReqGetAllProfiles", msg->name, msg->value);
                mySettings->getAllProfiles(([this](const settings::Settings::ListOfProfiles &profiles) {
                    this->profiles = profiles;
                    auto cnf       = std::make_shared<settings::UTMsg::ProfilesChg>(profiles);
                    sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                    bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
                }));
                auto cnf = std::make_shared<settings::UTMsg::CnfGetAllProfiles>();
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqAddProfile *>(req)) {
                debug("ReqAddProfile", msg->name, msg->value);
                mySettings->addProfile(msg->name);
                auto cnf = std::make_shared<settings::UTMsg::CnfAddProfile>(msg->name);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }

            return std::make_shared<sys::ResponseMessage>();


@@ 144,40 143,40 @@ namespace settings
                mySettings->registerModeChange(([this](const std::string &mode) {
                    this->mode = mode;
                    auto cnf   = std::make_shared<settings::UTMsg::ProfileChg>(mode);
                    sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                    bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
                }));
                auto cnf = std::make_shared<settings::UTMsg::CnfRegProfileChg>();
                sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqUnRegProfileChg *>(req)) {
                // unregister
                debug("ReqUnRegProfileChg", msg->name, msg->value);
                mySettings->unregisterModeChange();
                auto cnf = std::make_shared<settings::UTMsg::CnfUnRegProfileChg>();
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqSetCurrentProfile *>(req)) {
                // set value
                debug("ReqSetCurrentProfile", msg->name, msg->value);
                mySettings->setCurrentMode(msg->name);
                auto cnf = std::make_shared<settings::UTMsg::CnfSetCurrentProfile>(msg->name);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqGetAllProfiles *>(req)) {
                debug("ReqGetAllProfiles", msg->name, msg->value);
                mySettings->getAllModes(([this](const settings::Settings::ListOfModes &modes) {
                    this->modes = modes;
                    auto cnf    = std::make_shared<settings::UTMsg::ProfilesChg>(modes);
                    sys::Bus::SendUnicast(std::move(cnf), whoRequestedNotifyOnChange, this);
                    bus.sendUnicast(std::move(cnf), whoRequestedNotifyOnChange);
                }));
                auto cnf = std::make_shared<settings::UTMsg::CnfGetAllProfiles>();
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }
            else if (auto msg = dynamic_cast<settings::UTMsg::ReqAddProfile *>(req)) {
                debug("ReqAddProfile", msg->name, msg->value);
                mySettings->addMode(msg->name);
                auto cnf = std::make_shared<settings::UTMsg::CnfAddProfile>(msg->name);
                sys::Bus::SendUnicast(std::move(cnf), msg->sender, this);
                bus.sendUnicast(std::move(cnf), msg->sender);
            }

            return std::make_shared<sys::ResponseMessage>();

M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +1 -2
@@ 11,7 11,6 @@

#include <Common/Query.hpp>
#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Worker.hpp>
#include <json/json11.hpp>
#include <log/log.hpp>


@@ 98,7 97,7 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
                auto msgToSend =
                    std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateFoundOnBoot, file);
                msgToSend->updateStats.versionInformation = UpdateMuditaOS::getVersionInfoFromFile(file);
                sys::Bus::SendUnicast(msgToSend, app::name_desktop, this);
                bus.sendUnicast(msgToSend, app::name_desktop);
            }
        }


M module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp => module-services/service-desktop/endpoints/backup/BackupEndpoint.cpp +1 -2
@@ 9,7 9,6 @@
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>

#include <Service/Bus.hpp>
#include <json/json11.hpp>
#include <purefs/filesystem_paths.hpp>



@@ 45,7 44,7 @@ auto BackupEndpoint::request(Context &context) -> sys::ReturnCodes
    }
    else if (context.getBody()[json::backupRequest] == true) {
        auto msg = std::make_shared<sdesktop::BackupMessage>();
        sys::Bus::SendUnicast(msg, service::name::service_desktop, ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(msg, service::name::service_desktop);
        backupReady = true;

        context.setResponseBody(json11::Json::object({{json::backupRequest, true}}));

M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp +6 -7
@@ 7,7 7,6 @@

#include <service-desktop/parser/MessageHandler.hpp>
#include <service-evtmgr/Constants.hpp>
#include <Service/Bus.hpp>
#include <service-cellular/CellularMessage.hpp>
#include <service-cellular/ServiceCellular.hpp>
#include <service-bluetooth/messages/Status.hpp>


@@ 37,23 36,23 @@ auto DeveloperModeHelper::processPutRequest(Context &context) -> sys::ReturnCode
        auto msg     = std::make_shared<cellular::RawCommand>();
        msg->command = body[json::developerMode::AT].string_value();
        msg->timeout = 3000;
        sys::Bus::SendUnicast(std::move(msg), ServiceCellular::serviceName, ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(std::move(msg), ServiceCellular::serviceName);
    }
    else if (body[json::developerMode::focus].bool_value()) {
        auto event = std::make_unique<sdesktop::developerMode::AppFocusChangeEvent>();
        auto msg   = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
        sys::Bus::SendUnicast(std::move(msg), service::name::evt_manager, ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(std::move(msg), service::name::evt_manager);
    }
    else if (body[json::developerMode::isLocked].bool_value()) {
        auto event = std::make_unique<sdesktop::developerMode::ScreenlockCheckEvent>();
        auto msg   = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
        sys::Bus::SendUnicast(std::move(msg), "ApplicationDesktop", ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(std::move(msg), "ApplicationDesktop");
    }
    else if (body[json::developerMode::btState].bool_value()) {

        auto event = std::make_unique<sdesktop::developerMode::BluetoothStatusRequestEvent>();
        auto msg   = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
        sys::Bus::SendUnicast(std::move(msg), "ServiceBluetooth", ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(std::move(msg), "ServiceBluetooth");
    }
    else if (auto state = body[json::developerMode::btCommand].string_value(); !state.empty()) {
        BluetoothMessage::Request request;


@@ 66,7 65,7 @@ auto DeveloperModeHelper::processPutRequest(Context &context) -> sys::ReturnCode
            LOG_INFO("turning off BT from harness!");
        }
        std::shared_ptr<BluetoothMessage> msg = std::make_shared<BluetoothMessage>(request);
        sys::Bus::SendUnicast(std::move(msg), "ServiceBluetooth", ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(std::move(msg), "ServiceBluetooth");

        MessageHandler::putToSendQueue(context.createSimpleResponse());
    }


@@ 171,7 170,7 @@ void DeveloperModeHelper::sendKeypress(bsp::KeyCodes keyCode, gui::InputEvent::S
    LOG_INFO("Sending %s", event.str().c_str());
    auto message = std::make_shared<app::AppInputEventMessage>(std::move(event));

    sys::Bus::SendUnicast(std::move(message), service::name::evt_manager, ownerServicePtr);
    ownerServicePtr->bus.sendUnicast(std::move(message), service::name::evt_manager);
}

void DeveloperModeHelper::requestSimChange(const int simSelected)

M module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp => module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp +1 -2
@@ 8,7 8,6 @@
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>

#include <Service/Bus.hpp>
#include <json/json11.hpp>

#include <memory>


@@ 19,7 18,7 @@ auto FactoryResetEndpoint::handle(parserFSM::Context &context) -> void

        if (context.getBody()[parserFSM::json::factoryRequest] == true) {
            auto msg = std::make_shared<sdesktop::FactoryMessage>();
            sys::Bus::SendUnicast(msg, service::name::service_desktop, ownerServicePtr);
            ownerServicePtr->bus.sendUnicast(msg, service::name::service_desktop);

            context.setResponseBody(json11::Json::object({{parserFSM::json::factoryRequest, true}}));
        }

M module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp => module-services/service-desktop/endpoints/restore/RestoreEndpoint.cpp +1 -2
@@ 9,7 9,6 @@
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>

#include <Service/Bus.hpp>
#include <json/json11.hpp>

#include <memory>


@@ 22,7 21,7 @@ auto RestoreEndpoint::handle(Context &context) -> void

        if (context.getBody()[parserFSM::json::restoreRequest] == true) {
            auto msg = std::make_shared<sdesktop::RestoreMessage>();
            sys::Bus::SendUnicast(msg, service::name::service_desktop, ownerServicePtr);
            ownerServicePtr->bus.sendUnicast(msg, service::name::service_desktop);

            context.setResponseBody(json11::Json::object({{parserFSM::json::restoreRequest, true}}));
        }

M module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp => module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp +1 -2
@@ 9,7 9,6 @@
#include <endpoints/Context.hpp>
#include <endpoints/messages/MessageHelper.hpp>

#include <Service/Bus.hpp>
#include <json/json11.hpp>
#include <purefs/filesystem_paths.hpp>
#include <vfs.hpp>


@@ 61,7 60,7 @@ auto UpdateEndpoint::run(Context &context) -> sys::ReturnCodes
        context.setResponseBody(json11::Json::object({{parserFSM::json::updateReady, true}}));

        auto msg = std::make_shared<sdesktop::UpdateOsMessage>(fileName, context.getUuid());
        sys::Bus::SendUnicast(msg, service::name::service_desktop, ownerServicePtr);
        ownerServicePtr->bus.sendUnicast(msg, service::name::service_desktop);
        MessageHandler::putToSendQueue(context.createSimpleResponse());
        return sys::ReturnCodes::Success;
    }

M module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp => module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp +2 -3
@@ 5,7 5,6 @@
#include <service-desktop/ServiceDesktop.hpp>
#include <service-desktop/DesktopMessages.hpp>

#include <Service/Bus.hpp>
#include <SystemManager/SystemManager.hpp>
#include <crc32/crc32.h>
#include <json/json11.hpp>


@@ 737,7 736,7 @@ updateos::UpdateError UpdateMuditaOS::informError(const updateos::UpdateError er
    auto msgToSend         = std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateError);
    messageText            = std::string(readBuf.get());
    msgToSend->updateStats = (updateos::UpdateStats)(*this);
    sys::Bus::SendUnicast(msgToSend, app::name_desktop, owner);
    owner->bus.sendUnicast(msgToSend, app::name_desktop);

    parserFSM::Context responseContext;
    responseContext.setResponseStatus(parserFSM::http::Code::InternalServerError);


@@ 780,7 779,7 @@ void UpdateMuditaOS::informUpdate(const updateos::UpdateState statusCode, const 
    if (owner == nullptr) {
        return;
    }
    sys::Bus::SendUnicast(msgToSend, app::name_desktop, owner);
    owner->bus.sendUnicast(msgToSend, app::name_desktop);

    parserFSM::Context responseContext;
    responseContext.setResponseStatus(parserFSM::http::Code::Accepted);

M module-services/service-eink/ServiceEink.cpp => module-services/service-eink/ServiceEink.cpp +1 -3
@@ 11,7 11,6 @@
#include <log/log.hpp>
#include <messages/EinkMessage.hpp>
#include <messages/ImageMessage.hpp>
#include <Service/Bus.hpp>

#include <cstring>
#include <memory>


@@ 52,8 51,7 @@ namespace service::eink
        display.powerOn();

        auto msg = std::make_shared<service::gui::EinkInitialized>(display.getSize());
        sys::Bus::SendUnicast(msg, service::name::gui, this);

        bus.sendUnicast(msg, service::name::gui);
        return sys::ReturnCodes::Success;
    }


M module-services/service-evtmgr/EventManager.cpp => module-services/service-evtmgr/EventManager.cpp +14 -15
@@ 14,7 14,6 @@

#include <BaseInterface.hpp>
#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Worker.hpp>
#include <SystemManager/Constants.hpp>
#include <SystemManager/SystemManager.hpp>


@@ 47,7 46,7 @@ EventManager::EventManager(const std::string &name)
    LOG_INFO("[%s] Initializing", name.c_str());
    alarmTimestamp = 0;
    alarmID        = 0;
    busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
    bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
}

EventManager::~EventManager()


@@ 77,7 76,7 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy

        auto event   = std::make_unique<sdesktop::developerMode::ATResponseEvent>(msg->response);
        auto message = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
        sys::Bus::SendUnicast(message, service::name::service_desktop, this);
        bus.sendUnicast(message, service::name::service_desktop);

        handled = true;
    }


@@ 104,12 103,12 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy

        if (message->key.state == RawKey::State::Pressed && message->key.key_code == bsp::KeyCodes::FnRight) {
            // and state == ShutDown
            sys::Bus::SendUnicast(message, service::name::system_manager, this);
            bus.sendUnicast(message, service::name::system_manager);
        }

        // send key to focused application
        if (!targetApplication.empty()) {
            sys::Bus::SendUnicast(message, targetApplication, this);
            bus.sendUnicast(message, targetApplication);
        }
        // notify application manager to prevent screen locking
        app::manager::Controller::preventBlockingDevice(this);


@@ 129,7 128,7 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy
        auto message = std::make_shared<sevm::BatteryLevelMessage>(msg->levelPercents, msg->fullyCharged);

        if (!targetApplication.empty()) {
            sys::Bus::SendUnicast(message, targetApplication, this);
            bus.sendUnicast(message, targetApplication);
        }

        handled = true;


@@ 141,11 140,11 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy
        message->plugged = msg->plugged;

        if (!message->plugged) {
            sys::Bus::SendUnicast(message, service::name::system_manager, this);
            bus.sendUnicast(message, service::name::system_manager);
        }

        if (!targetApplication.empty()) {
            sys::Bus::SendUnicast(message, targetApplication, this);
            bus.sendUnicast(message, targetApplication);
        }
        handled = true;
    }


@@ 160,7 159,7 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy
        handled = true;
    }
    else if (!targetApplication.empty() && dynamic_cast<sevm::SIMMessage *>(msgl) != nullptr) {
        sys::Bus::SendUnicast(std::make_shared<sevm::SIMMessage>(), targetApplication, this);
        bus.sendUnicast(std::make_shared<sevm::SIMMessage>(), targetApplication);
    }
    else if (msgl->messageType == MessageType::EVMGetBoard) {
        using namespace bsp;


@@ 177,7 176,7 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy
        if (msg != nullptr) {
            auto message   = std::make_shared<sevm::StatusStateMessage>(MessageType::EVMModemStatus);
            message->state = msg->state;
            sys::Bus::SendUnicast(message, "ServiceCellular", this);
            bus.sendUnicast(message, "ServiceCellular");
        }
        handled = true;
    }


@@ 213,12 212,12 @@ sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sy
                utils::time::Time::setTimeZoneOffset(msg->getTimeZoneOffset().value());
            }
            auto notification = std::make_shared<sys::DataMessage>(MessageType::EVMTimeUpdated);
            sys::Bus::SendMulticast(notification, sys::BusChannels::ServiceEvtmgrNotifications, this);
            bus.sendMulticast(notification, sys::BusChannel::ServiceEvtmgrNotifications);
        }
    }
    else if (msgl->messageType == MessageType::EVMRingIndicator) {
        auto msg = std::make_shared<sys::CpuFrequencyMessage>(sys::CpuFrequencyMessage::Action::Increase);
        sys::Bus::SendUnicast(msg, service::name::system_manager, this);
        bus.sendUnicast(msg, service::name::system_manager);
    }

    if (handled) {


@@ 239,7 238,7 @@ sys::ReturnCodes EventManager::InitHandler()
        if (typeid(*req->event.get()) == typeid(AppFocusChangeEvent)) {
            auto event   = std::make_unique<AppFocusChangeEvent>(targetApplication);
            auto message = std::make_shared<DeveloperModeRequest>(std::move(event));
            sys::Bus::SendUnicast(message, service::name::service_desktop, this);
            bus.sendUnicast(message, service::name::service_desktop);
        }

        return std::make_shared<sys::ResponseMessage>();


@@ 251,7 250,7 @@ sys::ReturnCodes EventManager::InitHandler()

        auto message = std::make_shared<app::AppInputEventMessage>(msg->getEvent());
        if (!targetApplication.empty()) {
            sys::Bus::SendUnicast(std::move(message), targetApplication, this);
            bus.sendUnicast(std::move(message), targetApplication);
        }

        return std::make_shared<sys::ResponseMessage>();


@@ 356,7 355,7 @@ sys::ReturnCodes EventManager::SwitchPowerModeHandler(const sys::ServicePowerMod
bool EventManager::messageSetApplication(sys::Service *sender, const std::string &applicationName)
{
    auto msg = std::make_shared<sevm::EVMFocusApplication>(applicationName);
    return sys::Bus::SendUnicast(msg, service::name::evt_manager, sender);
    return sender->bus.sendUnicast(msg, service::name::evt_manager);
}

bool EventManager::processKeypadBacklightRequest(bsp::keypad_backlight::Action act)

M module-services/service-evtmgr/WorkerEvent.cpp => module-services/service-evtmgr/WorkerEvent.cpp +8 -9
@@ 10,7 10,6 @@

#include <Audio/AudioCommon.hpp>
#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Worker.hpp>
#include <bsp/battery-charger/battery_charger.hpp>
#include <bsp/cellular/bsp_cellular.hpp>


@@ 82,7 81,7 @@ bool WorkerEvent::handleMessage(uint32_t queueID)
            auto message = std::make_shared<AudioEventRequest>(audio::EventType::JackState,
                                                               state ? audio::Event::DeviceState::Connected
                                                                     : audio::Event::DeviceState::Disconnected);
            sys::Bus::SendUnicast(message, service::name::evt_manager, this->service);
            service->bus.sendUnicast(message, service::name::evt_manager);
        }
    }



@@ 95,12 94,12 @@ bool WorkerEvent::handleMessage(uint32_t queueID)
            const auto status = bsp::battery_charger::getStatusRegister();
            if (status & static_cast<std::uint16_t>(bsp::battery_charger::batteryINTBSource::minVAlert)) {
                auto messageBrownout = std::make_shared<sevm::BatteryBrownoutMessage>();
                sys::Bus::SendUnicast(messageBrownout, service::name::system_manager, this->service);
                service->bus.sendUnicast(messageBrownout, service::name::system_manager);
            }
            if (status & static_cast<std::uint16_t>(bsp::battery_charger::batteryINTBSource::SOCOnePercentChange)) {
                bsp::battery_charger::StateOfCharge battLevel = bsp::battery_charger::getBatteryLevel();
                auto message = std::make_shared<sevm::BatteryLevelMessage>(battLevel, false);
                sys::Bus::SendUnicast(message, service::name::evt_manager, this->service);
                service->bus.sendUnicast(message, service::name::evt_manager);
                battery_level_check::checkBatteryLevelCritical();
            }
            bsp::battery_charger::clearAllIRQs();


@@ 112,7 111,7 @@ bool WorkerEvent::handleMessage(uint32_t queueID)
            if (!message->plugged) {
                bsp::battery_charger::chargingFinishedAction();
            }
            sys::Bus::SendUnicast(message, service::name::evt_manager, this->service);
            service->bus.sendUnicast(message, service::name::evt_manager);
        }
    }



@@ 132,7 131,7 @@ bool WorkerEvent::handleMessage(uint32_t queueID)

        auto message       = std::make_shared<sevm::RtcMinuteAlarmMessage>(MessageType::EVMMinuteUpdated);
        message->timestamp = timestamp;
        sys::Bus::SendUnicast(message, service::name::evt_manager, this->service);
        service->bus.sendUnicast(message, service::name::evt_manager);
    }

    if (queueID == static_cast<uint32_t>(WorkerEventQueues::queueCellular)) {


@@ 148,7 147,7 @@ bool WorkerEvent::handleMessage(uint32_t queueID)

            auto message   = std::make_shared<sevm::StatusStateMessage>(MessageType::EVMModemStatus);
            message->state = GSMstatus;
            sys::Bus::SendUnicast(message, "EventManager", this->service);
            service->bus.sendUnicast(message, "EventManager");
        }

        if (notification == bsp::cellular::trayPin) {


@@ 159,7 158,7 @@ bool WorkerEvent::handleMessage(uint32_t queueID)

        if (notification == bsp::cellular::ringIndicatorPin) {
            auto message = std::make_shared<sevm::StatusStateMessage>(MessageType::EVMRingIndicator);
            sys::Bus::SendUnicast(message, "EventManager", this->service);
            service->bus.sendUnicast(message, "EventManager");
        }
    }



@@ 269,7 268,7 @@ void WorkerEvent::processKeyEvent(bsp::KeyEvents event, bsp::KeyCodes code)
            message->key.time_release = xTaskGetTickCount();
        }
    }
    sys::Bus::SendUnicast(message, service::name::evt_manager, this->service);
    service->bus.sendUnicast(message, service::name::evt_manager);
}

void WorkerEvent::checkBatteryLevelCritical()

M module-services/service-evtmgr/alarm/EventManagerAlarm.cpp => module-services/service-evtmgr/alarm/EventManagerAlarm.cpp +1 -2
@@ 6,7 6,6 @@

#include <AlarmsRecord.hpp>
#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <SwitchData.hpp>
#include <service-appmgr/Controller.hpp>
#include <service-db/DBServiceAPI.hpp>     // for DBServiceAPI


@@ 30,7 29,7 @@ void EventManager::HandleAlarmTrigger(sys::DataMessage *msgl)
    message->timestamp = msg->timestamp;

    if (targetApplication.empty() == false) {
        sys::Bus::SendUnicast(message, targetApplication, this);
        bus.sendUnicast(message, targetApplication);
    }

    time_t currentTime = message->timestamp;

M module-services/service-evtmgr/api/EventManagerServiceAPI.cpp => module-services/service-evtmgr/api/EventManagerServiceAPI.cpp +2 -3
@@ 6,7 6,6 @@
#include <service-evtmgr/Constants.hpp>

#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Common.hpp>
#include <Service/Message.hpp>



@@ 24,7 23,7 @@ bsp::Board EventManagerServiceAPI::GetBoard(sys::Service *serv)
    constexpr uint32_t timeout = 1000;

    std::shared_ptr<sys::DataMessage> msg = std::make_shared<sys::DataMessage>(MessageType::EVMGetBoard);
    auto ret                              = sys::Bus::SendUnicast(msg, service::name::evt_manager, serv, timeout);
    auto ret                              = serv->bus.sendUnicast(msg, service::name::evt_manager, timeout);

    sevm::EVMBoardResponseMessage *response = dynamic_cast<sevm::EVMBoardResponseMessage *>(ret.second.get());



@@ 39,5 38,5 @@ bsp::Board EventManagerServiceAPI::GetBoard(sys::Service *serv)
void EventManagerServiceAPI::checkBatteryLevelCriticalState(sys::Service *serv)
{
    auto msg = std::make_shared<sevm::BatteryLevelCriticalCheckMessage>();
    sys::Bus::SendUnicast(msg, service::name::evt_manager, serv);
    serv->bus.sendUnicast(msg, service::name::evt_manager);
}

M module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.cpp => module-services/service-evtmgr/battery-level-check/BatteryLevelCheck.cpp +2 -3
@@ 5,7 5,6 @@
#include "service-evtmgr/BatteryMessages.hpp"
#include "SystemManager/Constants.hpp"

#include <Service/Bus.hpp>
#include <common_data/EventStore.hpp>

namespace battery_level_check


@@ 35,13 34,13 @@ namespace battery_level_check
        void sendCriticalLevelMessage()
        {
            auto levelCriticalMessage = std::make_shared<sevm::BatteryLevelCriticalMessage>();
            sys::Bus::SendUnicast(levelCriticalMessage, service::name::system_manager, parentService);
            parentService->bus.sendUnicast(levelCriticalMessage, service::name::system_manager);
        }

        void sendNormalLevelMessage()
        {
            auto levelNormalMessage = std::make_shared<sevm::BatteryLevelNormalMessage>();
            sys::Bus::SendUnicast(levelNormalMessage, service::name::system_manager, parentService);
            parentService->bus.sendUnicast(levelNormalMessage, service::name::system_manager);
        }
    } // namespace


M module-services/service-fileindexer/ServiceFileIndexer.cpp => module-services/service-fileindexer/ServiceFileIndexer.cpp +1 -2
@@ 7,7 7,6 @@
#include "notesIndexer.hpp"
#include "messages/FileChangeMessage.hpp"
#include "Constants.hpp"
#include <Service/Bus.hpp>
#include <fileref.h>
#include <tag.h>



@@ 60,7 59,7 @@ namespace service
                namespace fs       = std::filesystem;
                const auto new_ext = fs::path(new_path).extension().string();
                auto msg           = std::make_shared<msg::FileChangeMessage>(new_path, event, old_path);
                sys::Bus::SendUnicast(msg, std::string(service::name::file_indexer), _this.get());
                _this->bus.sendUnicast(msg, std::string(service::name::file_indexer));
            });
        mStartupIndexer.start(shared_from_this(), service::name::file_indexer);
        return sys::ReturnCodes::Success;

M module-services/service-fileindexer/StartupIndexer.cpp => module-services/service-fileindexer/StartupIndexer.cpp +1 -2
@@ 6,7 6,6 @@
#include <filesystem>
#include <ff_stdio_listdir_recursive.h>
#include <purefs/filesystem_paths.hpp>
#include <Service/Bus.hpp>
#include "Constants.hpp"

namespace service::detail


@@ 61,7 60,7 @@ namespace service::detail
            mIdxTimer = std::make_unique<sys::Timer>("file_indexing", svc.get(), timer_indexing_time);
            mIdxTimer->connect([this, svc](sys::Timer &) {
                if (!mMsgs.empty()) {
                    sys::Bus::SendUnicast(mMsgs.front(), std::string(service::name::file_indexer), svc.get());
                    svc->bus.sendUnicast(mMsgs.front(), std::string(service::name::file_indexer));
                    mMsgs.pop_front();
                }
                else {

M module-services/service-fota/FotaServiceAPI.cpp => module-services/service-fota/FotaServiceAPI.cpp +6 -7
@@ 5,7 5,6 @@
#include "service-fota/FotaServiceAPI.hpp"
#include "service-fota/ServiceFota.hpp"

#include <Service/Bus.hpp>
#include <MessageType.hpp>
#include <log/log.hpp>



@@ 20,21 19,21 @@ namespace FotaService
    {
        LOG_DEBUG("FOTA - Internet Config called");
        std::shared_ptr<ConfigureAPNMessage> msg = std::make_shared<ConfigureAPNMessage>(config);
        return sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        return serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    bool API::Connect(sys::Service *serv)
    {
        LOG_DEBUG("FOTA - Internet connection called");
        auto msg = std::make_shared<ConnectMessage>();
        return sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        return serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    bool API::Disconnect(sys::Service *serv)
    {
        std::shared_ptr<InternetRequestMessage> msg =
            std::make_shared<InternetRequestMessage>(MessageType::FotaInternetDisconnect);
        return sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        return serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    void API::HTTPGET(sys::Service *serv, const std::string &url)


@@ 43,7 42,7 @@ namespace FotaService
        std::shared_ptr<HTTPRequestMessage> msg = std::make_shared<HTTPRequestMessage>();
        msg->url                                = url;
        msg->method                             = FotaService::HTTPMethod::GET;
        sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    void API::FotaStart(sys::Service *serv, const std::string &url)


@@ 53,7 52,7 @@ namespace FotaService

        msg->url = url;

        sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    void API::sendRawProgress(sys::Service *serv, const std::string &rawQind)


@@ 61,7 60,7 @@ namespace FotaService
        LOG_DEBUG("Fota sending Raw progress");
        std::shared_ptr<FotaService::FOTARawProgress> msg = std::make_shared<FotaService::FOTARawProgress>();
        msg->qindRaw                                      = rawQind;
        sys::Bus::SendUnicast(std::move(msg), FotaService::Service::serviceName, serv);
        serv->bus.sendUnicast(std::move(msg), FotaService::Service::serviceName);
    }

    std::string APN::toString(APN::AuthMethod authMethod)

M module-services/service-fota/ServiceFota.cpp => module-services/service-fota/ServiceFota.cpp +11 -15
@@ 9,7 9,6 @@
#include <Commands.hpp>
#include <MessageType.hpp>
#include <Modem/TS0710/DLC_channel.h>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>
#include <Service/Timer.hpp>


@@ 47,14 46,14 @@ namespace FotaService
    {
        LOG_INFO("[ServiceFota] Initializing");

        busChannels.push_back(sys::BusChannels::ServiceFotaNotifications);
        busChannels.push_back(sys::BusChannels::ServiceCellularNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceFotaNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);

        connectionTimer = std::make_unique<sys::Timer>("Fota", this, defaultTimer);
        connectionTimer->connect([&](sys::Timer &) {
            std::shared_ptr<InternetRequestMessage> msg =
                std::make_shared<InternetRequestMessage>(MessageType::CellularListCurrentCalls);
            sys::Bus::SendUnicast(msg, Service::serviceName, this);
            bus.sendUnicast(msg, Service::serviceName);
        });
        registerMessageHandlers();
    }


@@ 149,10 148,8 @@ namespace FotaService
                }

                if (atResult) {
                    sys::Bus::SendMulticast(
                        std::make_shared<NotificationMessage>(NotificationMessage::Type::Configured),
                        sys::BusChannels::ServiceFotaNotifications,
                        this);
                    bus.sendMulticast(std::make_shared<NotificationMessage>(NotificationMessage::Type::Configured),
                                      sys::BusChannel::ServiceFotaNotifications);
                    LOG_DEBUG("Internet Cofiguration OK");
                }
                return std::make_shared<FotaResponseMessage>(true);


@@ 172,10 169,9 @@ namespace FotaService
                }
            }
            LOG_DEBUG("InternetConnect OK");
            sys::Bus::SendMulticast(std::make_shared<NotificationMessage>(
                                        static_cast<NotificationMessage::Type>(NotificationMessage::Type::Connected)),
                                    sys::BusChannels::ServiceFotaNotifications,
                                    this);
            bus.sendMulticast(std::make_shared<NotificationMessage>(
                                  static_cast<NotificationMessage::Type>(NotificationMessage::Type::Connected)),
                              sys::BusChannel::ServiceFotaNotifications);
            return std::make_shared<FotaResponseMessage>(true);
        }
        return std::make_shared<FotaResponseMessage>(false);


@@ 574,7 570,7 @@ namespace FotaService
        msg->httpServerResponseError             = httpErrorCodeValue200;
        msg->responseHeaders                     = std::move(headers);
        msg->body                                = std::move(body);
        sys::Bus::SendUnicast(msg, receiverServiceName, this);
        bus.sendUnicast(msg, receiverServiceName);
    }

    void Service::parseQIND(const std::string &message)


@@ 588,13 584,13 @@ namespace FotaService
    {
        auto progressMsg      = std::make_shared<FOTAProgres>();
        progressMsg->progress = progress;
        sys::Bus::SendUnicast(progressMsg, receiver, this);
        bus.sendUnicast(progressMsg, receiver);
    }

    void Service::sendFotaFinshed(const std::string &receiver)
    {
        auto msg = std::make_shared<FOTAFinished>();
        sys::Bus::SendUnicast(std::move(msg), receiver, this);
        bus.sendUnicast(std::move(msg), receiver);
    }

    sys::MessagePointer Service::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage * /*resp*/)

M module-services/service-gui/ServiceGUI.cpp => module-services/service-gui/ServiceGUI.cpp +2 -2
@@ 144,7 144,7 @@ namespace service::gui
    void ServiceGUI::prepareDisplayEarly(::gui::RefreshModes refreshMode)
    {
        auto msg = std::make_shared<service::eink::PrepareDisplayEarlyRequest>(refreshMode);
        sys::Bus::SendUnicast(msg, service::name::eink, this);
        bus.sendUnicast(msg, service::name::eink);
    }

    void ServiceGUI::notifyRenderer(std::list<std::unique_ptr<::gui::DrawCommand>> &&commands,


@@ 195,7 195,7 @@ namespace service::gui
    {
        setState(State::Busy);
        auto imageMsg = std::make_shared<service::eink::ImageMessage>(contextId, context, refreshMode);
        sys::Bus::SendUnicast(imageMsg, service::name::eink, this);
        bus.sendUnicast(imageMsg, service::name::eink);
        scheduleContextRelease(contextId);
    }


M module-services/service-gui/WorkerGUI.cpp => module-services/service-gui/WorkerGUI.cpp +1 -2
@@ 6,7 6,6 @@
#include <DrawCommand.hpp>
#include <log/log.hpp>
#include <Renderer.hpp>
#include <Service/Bus.hpp>
#include <Service/Worker.hpp>
#include <service-gui/ServiceGUI.hpp>



@@ 68,6 67,6 @@ namespace service::gui
    void WorkerGUI::onRenderingFinished(int contextId, ::gui::RefreshModes refreshMode)
    {
        auto msg = std::make_shared<service::gui::RenderingFinished>(contextId, refreshMode);
        sys::Bus::SendUnicast(std::move(msg), guiService->GetName(), guiService);
        guiService->bus.sendUnicast(std::move(msg), guiService->GetName());
    }
} // namespace service::gui

M module-services/service-lwip/ServiceLwIP.cpp => module-services/service-lwip/ServiceLwIP.cpp +1 -2
@@ 4,7 4,6 @@
#include "service-lwip/ServiceLwIP.hpp"

#include <MessageType.hpp>
#include <Service/Bus.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>
#include <log/log.hpp>


@@ 45,7 44,7 @@ extern "C"
sys::ReturnCodes message_lwip(sys::Service *app, LwIP_message::Request req)
{
    std::shared_ptr<LwIP_message> msg = std::make_shared<LwIP_message>(req);
    auto ret                          = sys::Bus::SendUnicast(msg, "ServiceLwIP", app, 5000);
    auto ret                          = app->bus.sendUnicast(msg, "ServiceLwIP", 5000);
    if (ret.first != sys::ReturnCodes::Success) {
        LOG_ERROR("err: %s", c_str(ret.first));
    }

M module-services/service-time/ServiceTime.cpp => module-services/service-time/ServiceTime.cpp +1 -1
@@ 22,7 22,7 @@ namespace stm
    ServiceTime::ServiceTime() : sys::Service(service::name::service_time), calendarEvents(this)
    {
        LOG_INFO("[ServiceTime] Initializing");
        busChannels.push_back(sys::BusChannels::ServiceDBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
    }

    ServiceTime::~ServiceTime()

M module-sys/CMakeLists.txt => module-sys/CMakeLists.txt +18 -3
@@ 3,9 3,12 @@
project(module-sys VERSION 1.0
        DESCRIPTION "Core module library")

set(SOURCES
set(BUS_IMPL_SOURCES
        ${CMAKE_CURRENT_SOURCE_DIR}/Service/details/bus/Bus.cpp
)

        ${CMAKE_CURRENT_SOURCE_DIR}/Service/Bus.cpp
set(SOURCES
        ${CMAKE_CURRENT_SOURCE_DIR}/Service/BusProxy.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Service/Worker.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Service/Message.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Service/Service.cpp


@@ 24,11 27,23 @@ else()
    message(FATAL_ERROR "Invalid target!")
endif()

add_library(${PROJECT_NAME} STATIC ${SOURCES} ${BOARD_SOURCES})
add_library(bus STATIC ${BUS_IMPL_SOURCES})
target_link_libraries(bus PRIVATE module-os)

target_compile_definitions(bus PRIVATE ${PROJECT_CONFIG_DEFINITIONS})
target_compile_definitions(bus PRIVATE ${PROJECT_TARGET})
target_compile_definitions(bus PRIVATE ${TARGET_COMPILE_DEFINITIONS})
target_compile_features(bus PRIVATE ${TARGET_COMPILE_FEATURES})
target_compile_options(bus PRIVATE ${TARGET_COMPILE_OPTIONS})
target_include_directories(bus PRIVATE ${BOARD_DIR_INCLUDES})
target_include_directories(bus PRIVATE ${PROJECT_INCLUDES})
target_link_options(bus PRIVATE ${TARGET_LINK_OPTIONS})

add_library(${PROJECT_NAME} STATIC ${SOURCES} ${BOARD_SOURCES})

target_link_libraries(${PROJECT_NAME}
    PRIVATE
        bus
        service-evtmgr
    PUBLIC
        module-os)

D module-sys/Service/Bus.cpp => module-sys/Service/Bus.cpp +0 -223
@@ 1,223 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Bus.hpp"
#include "thread.hpp"
#include "ticks.hpp"
#include "critical.hpp"
#include "Service.hpp"
#include "Message.hpp"
#include <algorithm>
#include <cassert>

namespace sys
{

    using namespace cpp_freertos;
    using namespace std;

    Bus::Bus()
    {}

    Bus::~Bus()
    {}

    void Bus::Add(std::shared_ptr<Service> service)
    {
        CriticalSection::Enter();
        for (auto &w : service->busChannels) {
            channels[w].m_services.insert(service);
        }
        servicesRegistered[service->GetName()] = service;
        CriticalSection::Exit();
    }

    void Bus::Remove(std::shared_ptr<Service> service)
    {
        CriticalSection::Enter();
        for (auto &w : service->busChannels) {

            auto it = std::find_if(channels[w].m_services.begin(),
                                   channels[w].m_services.end(),
                                   [&](std::shared_ptr<Service> const &s) { return s == service; });
            if (it != channels[w].m_services.end()) {
                channels[w].m_services.erase(it);
            }
            else {
            }
        }

        auto ele = servicesRegistered.find(service->GetName());
        if (ele != servicesRegistered.end()) {
            servicesRegistered.erase(service->GetName());
        }
        else {
            // error!, trying to remove non-existing service
        }

        CriticalSection::Exit();
    }

    void Bus::SendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request, Service *sender)
    {
        assert(response != nullptr);
        assert(request != nullptr);
        assert(sender != nullptr);

        response->id        = uniqueMsgId++;
        response->uniID     = request->uniID;
        response->sender    = sender->GetName();
        response->transType = Message::TransmissionType ::Unicast;
        if (servicesRegistered.find(request->sender) != servicesRegistered.end()) {
            servicesRegistered[request->sender]->mailbox.push(response);
        }
        else {
            // silently drop it
        }
    }

    bool Bus::SendUnicast(std::shared_ptr<Message> msg, const std::string &service, Service *s)
    {
        CriticalSection::Enter();
        msg->id    = uniqueMsgId++;
        msg->uniID = unicastMsgId++;
        CriticalSection::Exit();

        msg->sender    = s->GetName();
        msg->transType = Message::TransmissionType ::Unicast;

        auto ele = servicesRegistered.find(service);
        if (ele != servicesRegistered.end()) {
            servicesRegistered[service]->mailbox.push(msg);
        }
        else {
            LOG_ERROR("Service %s doesn't exist", service.c_str());
            return false;
        }

        return true;
    }

    SendResult Bus::SendUnicast(std::shared_ptr<Message> msg, const std::string &service, Service *s, uint32_t timeout)
    {
        std::vector<std::shared_ptr<Message>> tempMsg;
        tempMsg.reserve(4); // reserve space for 4 elements to avoid costly memory allocations

        CriticalSection::Enter();
        uint64_t unicastID = unicastMsgId;
        msg->id            = uniqueMsgId++;
        msg->uniID         = unicastMsgId++;
        CriticalSection::Exit();

        msg->sender    = s->GetName();
        msg->transType = Message::TransmissionType ::Unicast;

        auto ele = servicesRegistered.find(service);
        if (ele != servicesRegistered.end()) {
            servicesRegistered[service]->mailbox.push(msg);
        }
        else {
            LOG_ERROR("Service %s doesn't exist", service.c_str());
            return std::make_pair(ReturnCodes::ServiceDoesntExist, nullptr);
        }

        uint32_t currentTime   = cpp_freertos::Ticks::GetTicks();
        uint32_t timeoutNeeded = currentTime + timeout;
        uint32_t timeElapsed   = currentTime;

        while (1) {
            // timeout
            if (timeElapsed >= timeoutNeeded) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    s->mailbox.push(w);
                }

                // Register that we didn't receive response. Even if it arrives it will be dropped
                s->staleUniqueMsg.push_back(std::make_pair(unicastID, cpp_freertos::Ticks::GetTicks()));
                return std::make_pair(ReturnCodes::Timeout, nullptr);
            }

            // Immediately block on rx queue
            auto rxmsg = s->mailbox.pop(timeoutNeeded - timeElapsed);

            timeElapsed = cpp_freertos::Ticks::GetTicks();

            // check for timeout
            if (rxmsg == nullptr) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    s->mailbox.push(w);
                }

                // Register that we didn't receive response. Even if it arrives it will be dropped
                s->staleUniqueMsg.push_back(std::make_pair(unicastID, cpp_freertos::Ticks::GetTicks()));
                return CreateSendResult(ReturnCodes::Timeout, nullptr);
            }

            // Received response
            if ((rxmsg->uniID == unicastID) && (msg->sender == s->GetName())) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    s->mailbox.push(w);
                }

                return CreateSendResult(ReturnCodes::Success, rxmsg);
            }
            // Check for system messages
            else if (rxmsg->type == Message::Type::System) {

                SystemMessage *sysmsg = static_cast<SystemMessage *>(rxmsg.get());

                if (sysmsg->systemMessageType == SystemMessageType::Ping) {
                    rxmsg->Execute(s);
                }
                else {
                    tempMsg.push_back(rxmsg);
                }
            }
            // Plain data message, save it for later
            else {
                tempMsg.push_back(rxmsg);
            }
        }
    }

    void Bus::SendMulticast(std::shared_ptr<Message> msg, BusChannels channel, Service *source)
    {
        CriticalSection::Enter();
        msg->id      = uniqueMsgId++;
        msg->channel = channel;
        CriticalSection::Exit();

        msg->transType = Message::TransmissionType ::Multicast;
        msg->sender    = source->GetName();

        for (auto const &w : channels[channel].m_services) {
            w->mailbox.push(msg);
        }
    }

    void Bus::SendBroadcast(std::shared_ptr<Message> msg, Service *source)
    {
        CriticalSection::Enter();
        msg->id = uniqueMsgId++;
        CriticalSection::Exit();

        msg->transType = Message::TransmissionType ::Broadcast;
        msg->sender    = source->GetName();

        for (auto const &w : servicesRegistered) {
            w.second->mailbox.push(msg);
        }
    }

    std::map<BusChannels, Channel> Bus::channels;
    std::map<std::string, std::shared_ptr<Service>> Bus::servicesRegistered;
    uint64_t Bus::uniqueMsgId;
    uint64_t Bus::unicastMsgId;

} // namespace sys

D module-sys/Service/Bus.hpp => module-sys/Service/Bus.hpp +0 -57
@@ 1,57 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include <map>
#include <queue>
#include "Channel.hpp"
#include "Common.hpp"
#include "Message.hpp"

namespace sys
{
    class Service;
    class Message;

    constexpr uint32_t defaultCmdTimeout = 5000;
    class Bus
    {

      public:
        // Send message directly to specified service (unicast type)
        static bool SendUnicast(std::shared_ptr<Message> msg, const std::string &service, Service *s);

        // Send message directly to specified service with timeout
        static SendResult SendUnicast(std::shared_ptr<Message> msg,
                                      const std::string &service,
                                      Service *s,
                                      uint32_t timeout);

        // Send message to specific channel
        static void SendMulticast(std::shared_ptr<Message> msg, BusChannels channel, Service *source);

        // Send message to all registered services ()
        static void SendBroadcast(std::shared_ptr<Message> msg, Service *source);

        // Register new service
        static void Add(std::shared_ptr<Service> service);

        // Unregister specified service
        static void Remove(std::shared_ptr<Service> service);

        static void SendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request, Service *sender);

      private:
        Bus();
        ~Bus();

        static std::map<BusChannels, Channel> channels;
        static std::map<std::string, std::shared_ptr<Service>> servicesRegistered;

        static uint64_t uniqueMsgId;
        static uint64_t unicastMsgId;
    };

} // namespace sys

A module-sys/Service/BusProxy.cpp => module-sys/Service/BusProxy.cpp +51 -0
@@ 0,0 1,51 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BusProxy.hpp"

#include "details/bus/Bus.hpp"

namespace sys
{
    BusProxy::BusProxy(Service *owner) : owner{owner}, busImpl{std::make_unique<Bus>()}
    {
        channels.push_back(BusChannel::System); // Mandatory for each service.
    }

    BusProxy::~BusProxy() noexcept = default;

    bool BusProxy::sendUnicast(std::shared_ptr<Message> message, const std::string &targetName)
    {
        return busImpl->SendUnicast(std::move(message), targetName, owner);
    }

    SendResult BusProxy::sendUnicast(std::shared_ptr<Message> message, const std::string &targetName, uint32_t timeout)
    {
        return busImpl->SendUnicast(std::move(message), targetName, owner, timeout);
    }

    void BusProxy::sendMulticast(std::shared_ptr<Message> message, BusChannel channel)
    {
        busImpl->SendMulticast(std::move(message), channel, owner);
    }

    void BusProxy::sendBroadcast(std::shared_ptr<Message> message)
    {
        busImpl->SendBroadcast(std::move(message), owner);
    }

    void BusProxy::sendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request)
    {
        busImpl->SendResponse(std::move(response), std::move(request), owner);
    }

    void BusProxy::connect()
    {
        Bus::Add(owner);
    }

    void BusProxy::disconnect()
    {
        Bus::Remove(owner);
    }
} // namespace sys

A module-sys/Service/BusProxy.hpp => module-sys/Service/BusProxy.hpp +43 -0
@@ 0,0 1,43 @@
// 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 "Message.hpp"

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

namespace sys
{
    class Service; // Forward declaration
    class Bus;     // Forward declaration

    class BusProxy
    {
      public:
        static constexpr auto defaultTimeout = 5000U;

        ~BusProxy() noexcept;

        bool sendUnicast(std::shared_ptr<Message> message, const std::string &targetName);
        SendResult sendUnicast(std::shared_ptr<Message> message, const std::string &targetName, std::uint32_t timeout);
        void sendMulticast(std::shared_ptr<Message> message, BusChannel channel);
        void sendBroadcast(std::shared_ptr<Message> message);

        std::vector<BusChannel> channels;

      private:
        friend class Service;
        explicit BusProxy(Service *owner);

        void sendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request);
        void connect();
        void disconnect();

        Service *owner;
        std::unique_ptr<Bus> busImpl;
    };
} // namespace sys

D module-sys/Service/Channel.hpp => module-sys/Service/Channel.hpp +0 -24
@@ 1,24 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include <set>

namespace sys
{

    class Service;

    class Channel
    {

      public:
        Channel()
        {}

        std::set<std::shared_ptr<Service>> m_services;
    };

} // namespace sys

M module-sys/Service/Common.hpp => module-sys/Service/Common.hpp +14 -14
@@ 8,7 8,7 @@
namespace sys
{

    enum class BusChannels
    enum class BusChannel
    {
        System,
        SystemManagerRequests,


@@ 84,32 84,32 @@ inline const char *c_str(sys::ServicePowerMode code)
    return "";
}

inline const char *c_str(sys::BusChannels channel)
inline const char *c_str(sys::BusChannel channel)
{
    switch (channel) {
    case sys::BusChannels::System:
    case sys::BusChannel::System:
        return "System";
    case sys::BusChannels::SystemManagerRequests:
    case sys::BusChannel::SystemManagerRequests:
        return "SystemManagerRequests";
    case sys::BusChannels::PowerManagerRequests:
    case sys::BusChannel::PowerManagerRequests:
        return "PowerManagerRequests";
    case sys::BusChannels::ServiceCellularNotifications:
    case sys::BusChannel::ServiceCellularNotifications:
        return "ServiceCellularNotifications,";
    case sys::BusChannels::Test2CustomBusChannel:
    case sys::BusChannel::Test2CustomBusChannel:
        return "Test2CustomBusChannel,";
    case sys::BusChannels::ServiceDBNotifications:
    case sys::BusChannel::ServiceDBNotifications:
        return "ServiceDBNotifications,";
    case sys::BusChannels::ServiceAudioNotifications:
    case sys::BusChannel::ServiceAudioNotifications:
        return "ServiceAudioNotifications";
    case sys::BusChannels::AppManagerNotifications:
    case sys::BusChannel::AppManagerNotifications:
        return "AppManagerNotifications,";
    case sys::BusChannels::ServiceFotaNotifications:
    case sys::BusChannel::ServiceFotaNotifications:
        return "ServiceFotaNotifications";
    case sys::BusChannels::AntennaNotifications:
    case sys::BusChannel::AntennaNotifications:
        return "AntennaNotifications";
    case sys::BusChannels::ServiceEvtmgrNotifications:
    case sys::BusChannel::ServiceEvtmgrNotifications:
        return "ServiceEvtmgrNotifications";
    case sys::BusChannels::CalendarNotifications:
    case sys::BusChannel::CalendarNotifications:
        return "CalendarNotifications";
    }
    return "";

M module-sys/Service/Message.cpp => module-sys/Service/Message.cpp +3 -8
@@ 3,11 3,6 @@

#include "Message.hpp"
#include "Service.hpp"
#include "Bus.hpp"
#include "Channel.hpp"
#include "ticks.hpp"

#include <string.h>

namespace sys
{


@@ 16,7 11,7 @@ namespace sys
        return std::make_pair(retCode, msg);
    }

    Message::Message(BusChannels channel) : channel{channel}
    Message::Message(BusChannel channel) : channel{channel}
    {}

    MessagePointer Message::Execute(Service *service)


@@ 25,7 20,7 @@ namespace sys
    }

    SystemMessage::SystemMessage(SystemMessageType systemMessageType, ServicePowerMode pwrMode)
        : Message(BusChannels::System), systemMessageType(systemMessageType), powerMode(pwrMode)
        : Message(BusChannel::System), systemMessageType(systemMessageType), powerMode(pwrMode)
    {
        type = Type::System;
    }


@@ 40,7 35,7 @@ namespace sys
        type = Type::Data;
    }

    DataMessage::DataMessage(BusChannels channel) : Message(channel)
    DataMessage::DataMessage(BusChannel channel) : Message(channel)
    {
        type = Type::Data;
    }

M module-sys/Service/Message.hpp => module-sys/Service/Message.hpp +3 -3
@@ 36,7 36,7 @@ namespace sys
        };

        Message() = default;
        explicit Message(BusChannels channel);
        explicit Message(BusChannel channel);
        virtual ~Message() noexcept = default;

        virtual MessagePointer Execute(Service *service);


@@ 50,7 50,7 @@ namespace sys
        std::uint64_t uniID;
        Type type;
        TransmissionType transType;
        BusChannels channel;
        BusChannel channel;
        std::string sender;
    };



@@ 79,7 79,7 @@ namespace sys
    {
      public:
        explicit DataMessage(MessageType messageType);
        explicit DataMessage(BusChannels channel);
        explicit DataMessage(BusChannel channel);

        // This field must by provided by the class that inherits DataMessage
        MessageType messageType = MessageType::MessageTypeUninitialized;

M module-sys/Service/Service.cpp => module-sys/Service/Service.cpp +9 -9
@@ 2,7 2,6 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Service.hpp"
#include "Bus.hpp"             // for Bus
#include "FreeRTOSConfig.h"    // for configASSERT
#include "MessageType.hpp"     // for MessageType, MessageType::MessageType...
#include "Service/Common.hpp"  // for BusChannels, ReturnCodes, ReturnCodes...


@@ 47,17 46,13 @@ void debug_msg(sys::Service *srvc, const sys::Message *ptr)

namespace sys
{

    using namespace cpp_freertos;
    using namespace std;

    Service::Service(std::string name, std::string parent, uint32_t stackDepth, ServicePriority priority)
        : cpp_freertos::Thread(name, stackDepth / 4 /* Stack depth in bytes */, static_cast<UBaseType_t>(priority)),
          parent(parent), mailbox(this), pingTimestamp(UINT32_MAX), isReady(false), enableRunLoop(false)

          parent(parent), bus{this}, mailbox(this), pingTimestamp(UINT32_MAX), isReady(false), enableRunLoop(false)
    {
        // System channel is mandatory for each service
        busChannels = {BusChannels::System};
    }

    Service::~Service()


@@ 68,7 63,7 @@ namespace sys

    void Service::StartService()
    {
        Bus::Add(shared_from_this());
        bus.connect();
        enableRunLoop = true;
        if (!Start()) {
            LOG_FATAL("FATAL ERROR: Start service failed!:%s", GetName().c_str());


@@ 76,6 71,11 @@ namespace sys
        }
    }

    void Service::CloseService()
    {
        bus.disconnect();
    }

    void Service::Run()
    {
        while (enableRunLoop) {


@@ 100,9 100,9 @@ namespace sys
                continue;
            }

            Bus::SendResponse(response, msg, this);
            bus.sendResponse(response, msg);
        }
        Bus::Remove(shared_from_this());
        CloseService();
    };

    auto Service::MessageEntry(Message *message, ResponseMessage *response) -> MessagePointer

M module-sys/Service/Service.hpp => module-sys/Service/Service.hpp +3 -1
@@ 3,6 3,7 @@

#pragma once

#include "BusProxy.hpp"
#include "Common.hpp"  // for ReturnCodes, ServicePriority, BusChannels
#include "Mailbox.hpp" // for Mailbox
#include "Message.hpp" // for MessagePointer


@@ 43,6 44,7 @@ namespace sys
        ~Service() override;

        void StartService();
        void CloseService();

        // Invoked for not processed already messages
        // override should in in either callback, function or whatever...


@@ 69,7 71,7 @@ namespace sys

        std::string parent;

        std::vector<BusChannels> busChannels;
        BusProxy bus;

        Mailbox<std::shared_ptr<Message>> mailbox;


M module-sys/Service/Timer.cpp => module-sys/Service/Timer.cpp +2 -3
@@ 4,7 4,6 @@
#include "Timer.hpp"
#include "Service.hpp"
#include "TimerMessage.hpp"
#include "Service/Bus.hpp"
#include <log/log.hpp>
#include <projdefs.h>
#include <limits>


@@ 61,8 60,8 @@ namespace sys
            log_error("Timer %s error: no parent service", name.c_str());
            return;
        }
        if (!Bus::SendUnicast(msg, parent->GetName(), parent)) {
            log_error("Timer %s error: bus error", name.c_str());
        if (!parent->bus.sendUnicast(msg, parent->GetName())) {
            LOG_ERROR("Timer %s error: bus error", name.c_str());
            return;
        }
    }

A module-sys/Service/details/bus/Bus.cpp => module-sys/Service/details/bus/Bus.cpp +210 -0
@@ 0,0 1,210 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Bus.hpp"

#include "module-sys/Service/Service.hpp"
#include "module-os/CriticalSectionGuard.hpp"

#include "ticks.hpp"

#include <algorithm>
#include <cassert>
#include <set>

namespace sys
{
    namespace
    {
        std::uint64_t uniqueMsgId  = 0;
        std::uint64_t unicastMsgId = 0;

        std::map<BusChannel, std::set<Service *>> channels;
        std::map<std::string, Service *> servicesRegistered;
    } // namespace

    void Bus::Add(Service *service)
    {
        cpp_freertos::CriticalSectionGuard guard;

        for (auto channel : service->bus.channels) {
            channels[channel].insert(service);
        }
        servicesRegistered[service->GetName()] = service;
    }

    void Bus::Remove(Service *service)
    {
        cpp_freertos::CriticalSectionGuard guard;

        for (auto channel : service->bus.channels) {
            auto &services = channels[channel];
            services.erase(service);
        }
        servicesRegistered.erase(service->GetName());
    }

    void Bus::SendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request, Service *sender)
    {
        assert(response != nullptr);
        assert(request != nullptr);
        assert(sender != nullptr);

        {
            cpp_freertos::CriticalSectionGuard guard;
            response->id    = uniqueMsgId++;
            response->uniID = request->uniID;
        }
        response->sender    = sender->GetName();
        response->transType = Message::TransmissionType::Unicast;
        if (auto it = servicesRegistered.find(request->sender); it != servicesRegistered.end()) {
            const auto targetService = it->second;
            targetService->mailbox.push(response);
        }
    }

    bool Bus::SendUnicast(std::shared_ptr<Message> message, const std::string &targetName, Service *sender)
    {
        {
            cpp_freertos::CriticalSectionGuard guard;
            message->id    = uniqueMsgId++;
            message->uniID = unicastMsgId++;
        }
        message->sender    = sender->GetName();
        message->transType = Message::TransmissionType::Unicast;

        if (auto it = servicesRegistered.find(targetName); it != servicesRegistered.end()) {
            const auto targetService = it->second;
            targetService->mailbox.push(message);
            return true;
        }

        LOG_ERROR("Service %s doesn't exist", targetName.c_str());
        return false;
    }

    SendResult Bus::SendUnicast(std::shared_ptr<Message> message,
                                const std::string &targetName,
                                Service *sender,
                                std::uint32_t timeout)
    {
        std::vector<std::shared_ptr<Message>> tempMsg;
        tempMsg.reserve(4); // reserve space for 4 elements to avoid costly memory allocations

        uint64_t unicastID = unicastMsgId;
        {
            cpp_freertos::CriticalSectionGuard guard;
            message->id    = uniqueMsgId++;
            message->uniID = unicastMsgId++;
        }
        message->sender    = sender->GetName();
        message->transType = Message::TransmissionType ::Unicast;

        auto ele = servicesRegistered.find(targetName);
        if (ele != servicesRegistered.end()) {
            const auto targetService = servicesRegistered[targetName];
            targetService->mailbox.push(message);
        }
        else {
            LOG_ERROR("Service %s doesn't exist", targetName.c_str());
            return std::make_pair(ReturnCodes::ServiceDoesntExist, nullptr);
        }

        uint32_t currentTime   = cpp_freertos::Ticks::GetTicks();
        uint32_t timeoutNeeded = currentTime + timeout;
        uint32_t timeElapsed   = currentTime;

        while (1) {
            // timeout
            if (timeElapsed >= timeoutNeeded) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    sender->mailbox.push(w);
                }

                // Register that we didn't receive response. Even if it arrives it will be dropped
                sender->staleUniqueMsg.push_back(std::make_pair(unicastID, cpp_freertos::Ticks::GetTicks()));
                return std::make_pair(ReturnCodes::Timeout, nullptr);
            }

            // Immediately block on rx queue
            auto rxmsg = sender->mailbox.pop(timeoutNeeded - timeElapsed);

            timeElapsed = cpp_freertos::Ticks::GetTicks();

            // check for timeout
            if (rxmsg == nullptr) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    sender->mailbox.push(w);
                }

                // Register that we didn't receive response. Even if it arrives it will be dropped
                sender->staleUniqueMsg.push_back(std::make_pair(unicastID, cpp_freertos::Ticks::GetTicks()));
                return CreateSendResult(ReturnCodes::Timeout, nullptr);
            }

            // Received response
            if ((rxmsg->uniID == unicastID) && (message->sender == sender->GetName())) {

                // Push messages collected during waiting for response to processing queue
                for (const auto &w : tempMsg) {
                    sender->mailbox.push(w);
                }

                return CreateSendResult(ReturnCodes::Success, rxmsg);
            }
            // Check for system messages
            else if (rxmsg->type == Message::Type::System) {

                SystemMessage *sysmsg = static_cast<SystemMessage *>(rxmsg.get());

                if (sysmsg->systemMessageType == SystemMessageType::Ping) {
                    rxmsg->Execute(sender);
                }
                else {
                    tempMsg.push_back(rxmsg);
                }
            }
            // Plain data message, save it for later
            else {
                tempMsg.push_back(rxmsg);
            }
        }
    }

    void Bus::SendMulticast(std::shared_ptr<Message> message, BusChannel channel, Service *sender)
    {
        {
            cpp_freertos::CriticalSectionGuard guard;
            message->id = uniqueMsgId++;
        }

        message->channel   = channel;
        message->transType = Message::TransmissionType::Multicast;
        message->sender    = sender->GetName();
        for (const auto &target : channels[channel]) {
            target->mailbox.push(message);
        }
    }

    void Bus::SendBroadcast(std::shared_ptr<Message> message, Service *sender)
    {
        {
            cpp_freertos::CriticalSectionGuard guard;
            message->id = uniqueMsgId++;
        }

        message->transType = Message::TransmissionType ::Broadcast;
        message->sender    = sender->GetName();
        for (const auto &target : servicesRegistered) {
            const auto targetService = target.second;
            targetService->mailbox.push(message);
        }
    }
} // namespace sys

A module-sys/Service/details/bus/Bus.hpp => module-sys/Service/details/bus/Bus.hpp +81 -0
@@ 0,0 1,81 @@
// 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 "module-sys/Service/Common.hpp"
#include "module-sys/Service/Message.hpp"

#include <cstdint>
#include <memory>
#include <string>

namespace sys
{
    class Service; // forward declaration

    class Bus
    {
        // Because of incorrect linking of CMake targets Bus methods are accessible from any point of the project.
        // In order to fix this, only BusProxy is able to access the methods of the Bus class.
        friend class BusProxy;

      private:
        /**
         * Sends a message directly to the specified target service.
         * @param message       Message to be sent
         * @param targetName    Target service
         * @param sender        Sender context
         * @return true on success, false otherwise
         */
        bool SendUnicast(std::shared_ptr<Message> message, const std::string &targetName, Service *sender);

        /**
         * Sends a message directly to the specified target service with timeout.
         * @param message       Message to be sent
         * @param targetName    Target service
         * @param sender        Sender context
         * @param timeout       Timeout
         * @return Return code and a response.
         */
        SendResult SendUnicast(std::shared_ptr<Message> message,
                               const std::string &targetName,
                               Service *sender,
                               std::uint32_t timeout);

        /**
         * Sends a message to the specified channel.
         * @param message   Message to be sent
         * @param channel   Target channel
         * @param sender    Sender context
         */
        void SendMulticast(std::shared_ptr<Message> message, BusChannel channel, Service *sender);

        /**
         * Sends a message to all registered services.
         * @param message   Message to be sent
         * @param sender    Sender context
         */
        void SendBroadcast(std::shared_ptr<Message> message, Service *sender);

        /**
         * Sends a response to the specified request.
         * @param response  Response to be sent
         * @param request   Request
         * @param sender    Sender context
         */
        void SendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request, Service *sender);

        /**
         * Registers a service.
         * @param service   Service to be registered
         */
        static void Add(Service *service);

        /**
         * Unregisters a service.
         * @param service   Service to be unregistered
         */
        static void Remove(Service *service);
    };
} // namespace sys

M module-sys/SystemManager/SystemManager.cpp => module-sys/SystemManager/SystemManager.cpp +14 -18
@@ 36,7 36,7 @@ namespace sys
    SystemManager::SystemManager() : Service(service::name::system_manager, "", systemManagerStack)
    {
        // Specify list of channels which System Manager is registered to
        busChannels = {BusChannels::SystemManagerRequests};
        bus.channels = {BusChannel::SystemManagerRequests};
    }

    SystemManager::~SystemManager()


@@ 81,7 81,8 @@ namespace sys

        DestroyService(service::name::evt_manager, this);

        Bus::Remove(shared_from_this());
        CloseService();

        EndScheduler();

        // Power off system


@@ 118,22 119,21 @@ namespace sys

    bool SystemManager::CloseSystem(Service *s)
    {
        Bus::SendUnicast(std::make_shared<SystemManagerCmd>(Code::CloseSystem), service::name::system_manager, s);
        s->bus.sendUnicast(std::make_shared<SystemManagerCmd>(Code::CloseSystem), service::name::system_manager);
        return true;
    }

    bool SystemManager::Reboot(Service *s)
    {
        Bus::SendUnicast(std::make_shared<SystemManagerCmd>(Code::Reboot), service::name::system_manager, s);
        s->bus.sendUnicast(std::make_shared<SystemManagerCmd>(Code::Reboot), service::name::system_manager);
        return true;
    }

    bool SystemManager::SuspendService(const std::string &name, sys::Service *caller)
    {
        auto ret = Bus::SendUnicast(
        auto ret = caller->bus.sendUnicast(
            std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode, ServicePowerMode::SuspendToRAM),
            name,
            caller,
            1000);
        auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);



@@ 145,11 145,8 @@ namespace sys

    bool SystemManager::ResumeService(const std::string &name, sys::Service *caller)
    {
        auto ret = Bus::SendUnicast(
            std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode, ServicePowerMode::Active),
            name,
            caller,
            1000);
        auto ret = caller->bus.sendUnicast(
            std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode, ServicePowerMode::Active), name, 1000);
        auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);

        if (ret.first != ReturnCodes::Success && (resp->retCode != ReturnCodes::Success)) {


@@ 168,7 165,7 @@ namespace sys
        service->StartService();

        auto msg  = std::make_shared<SystemMessage>(SystemMessageType::Start);
        auto ret  = Bus::SendUnicast(msg, service->GetName(), caller, timeout);
        auto ret  = caller->bus.sendUnicast(msg, service->GetName(), timeout);
        auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);

        if (ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)) {


@@ 183,7 180,7 @@ namespace sys
    {

        auto msg  = std::make_shared<SystemMessage>(SystemMessageType::Exit);
        auto ret  = Bus::SendUnicast(msg, name, caller, timeout);
        auto ret  = caller->bus.sendUnicast(msg, name, timeout);
        auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);

        if (ret.first == ReturnCodes::Success && (resp->retCode == ReturnCodes::Success)) {


@@ 222,7 219,7 @@ namespace sys
        isReady = true;

        connect(SystemManagerCmd(), [&](Message *msg) {
            if (msg->channel == BusChannels::SystemManagerRequests) {
            if (msg->channel == BusChannel::SystemManagerRequests) {
                auto *data = static_cast<SystemManagerCmd *>(msg);

                switch (data->type) {


@@ 258,7 255,7 @@ namespace sys
            LOG_INFO("Battery Brownout voltage level reached!");

            auto msg = std::make_shared<SystemBrownoutMesssage>();
            Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, this);
            bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);

            return MessageNone{};
        });


@@ 273,7 270,7 @@ namespace sys
            CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::Off);

            auto msg = std::make_shared<CriticalBatteryLevelNotification>(true);
            Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, this);
            bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);

            return MessageNone{};
        });


@@ 283,8 280,7 @@ namespace sys
            CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::On);

            auto msg = std::make_shared<CriticalBatteryLevelNotification>(false);
            Bus::SendUnicast(std::move(msg), app::manager::ApplicationManager::ServiceName, this);

            bus.sendUnicast(msg, app::manager::ApplicationManager::ServiceName);
            return MessageNone{};
        });


M module-sys/SystemManager/SystemManager.hpp => module-sys/SystemManager/SystemManager.hpp +1 -2
@@ 16,7 16,6 @@
#include "condition_variable.hpp"
#include "mutex.hpp"
#include "Service/Mailbox.hpp"
#include "Service/Bus.hpp"
#include "Service/Service.hpp"
#include "Service/Message.hpp"
#include "PowerManager.hpp"


@@ 43,7 42,7 @@ namespace sys
    class SystemManagerCmd : public DataMessage
    {
      public:
        SystemManagerCmd(Code type = Code::None) : DataMessage(BusChannels::SystemManagerRequests), type(type)
        SystemManagerCmd(Code type = Code::None) : DataMessage(BusChannel::SystemManagerRequests), type(type)
        {}

        Code type;

M module-utils/state/ServiceState.hpp => module-utils/state/ServiceState.hpp +1 -2
@@ 3,7 3,6 @@

#pragma once

#include <Service/Bus.hpp>
#include <algorithm>
#include <cassert>



@@ 32,7 31,7 @@ namespace utils
            {
                auto msg = std::make_shared<sys::DataMessage>(MessageType::StateChange);
                if (owner != nullptr) {
                    sys::Bus::SendUnicast(msg, owner->GetName(), owner);
                    owner->bus.sendUnicast(msg, owner->GetName());
                    return true;
                }
                return false;