From 08a71027acdb4532ad5d2f32728436cac7773281 Mon Sep 17 00:00:00 2001 From: Adam Dobrowolski Date: Thu, 26 May 2022 15:28:05 +0200 Subject: [PATCH] [MOS-487] Review required renames as in description --- .../Bluetooth/AbstractController.hpp | 56 +++---- .../Bluetooth/BluetoothStateMachine.hpp | 104 +++++++------ .../Bluetooth/BluetoothWorker.cpp | 6 +- .../Bluetooth/WorkerController.cpp | 52 +++---- .../Bluetooth/WorkerController.hpp | 52 +++---- .../Bluetooth/command/Command.hpp | 2 +- .../Bluetooth/command/event/Events.hpp | 4 +- .../Bluetooth/doc/bluetooth_states.svg | 142 +++++++++--------- .../Bluetooth/interface/BluetoothDriver.hpp | 8 +- .../interface/profiles/ProfileManager.hpp | 2 +- .../tests/tests-StatefulController.cpp | 80 +++++----- .../service-bluetooth/ServiceBluetooth.cpp | 66 ++++---- .../service-bluetooth/ServiceBluetooth.hpp | 2 +- 13 files changed, 291 insertions(+), 285 deletions(-) diff --git a/module-bluetooth/Bluetooth/AbstractController.hpp b/module-bluetooth/Bluetooth/AbstractController.hpp index ad2eb70c11ceb3449100a7a2b3d11d04e277fd63..1ab11ef2b1ee88ebe0a6c7530ca54575a4089cad 100644 --- a/module-bluetooth/Bluetooth/AbstractController.hpp +++ b/module-bluetooth/Bluetooth/AbstractController.hpp @@ -3,7 +3,7 @@ #pragma once -namespace bt::evt +namespace bluetooth::event { struct Base; struct StartScan; @@ -31,7 +31,7 @@ namespace bt::evt struct OperatorNameData; struct BatteryLevelData; struct NetworkStatusData; -} // namespace bt::evt +} // namespace bluetooth::event namespace bluetooth { @@ -41,31 +41,31 @@ namespace bluetooth public: virtual ~AbstractController() noexcept = default; - virtual void handle(const bt::evt::Base &evt) = 0; - virtual void handle(const bt::evt::StartScan &evt) = 0; - virtual void handle(const bt::evt::StopScan &evt) = 0; - virtual void handle(const bt::evt::GetDevicesAvailable &evt) = 0; - virtual void handle(const bt::evt::VisibilityOn &evt) = 0; - virtual void handle(const bt::evt::VisibilityOff &evt) = 0; - virtual void handle(const bt::evt::ConnectAudio &evt) = 0; - virtual void handle(const bt::evt::DisconnectAudio &evt) = 0; - virtual void handle(const bt::evt::PowerOn &evt) = 0; - virtual void handle(const bt::evt::PowerOff &evt) = 0; - virtual void handle(const bt::evt::ShutDown &evt) = 0; - virtual void handle(const bt::evt::Pair &evt) = 0; - virtual void handle(const bt::evt::Unpair &evt) = 0; - virtual void handle(const bt::evt::StartRinging &evt) = 0; - virtual void handle(const bt::evt::StopRinging &evt) = 0; - virtual void handle(const bt::evt::StartRouting &evt) = 0; - virtual void handle(const bt::evt::StartStream &evt) = 0; - virtual void handle(const bt::evt::StopStream &evt) = 0; - virtual void handle(const bt::evt::CallAnswered &evt) = 0; - virtual void handle(const bt::evt::CallTerminated &evt) = 0; - virtual void handle(const bt::evt::CallStarted &evt) = 0; - virtual void handle(const bt::evt::IncomingCallNumber &evt) = 0; - virtual void handle(const bt::evt::SignalStrengthData &evt) = 0; - virtual void handle(const bt::evt::OperatorNameData &evt) = 0; - virtual void handle(const bt::evt::BatteryLevelData &evt) = 0; - virtual void handle(const bt::evt::NetworkStatusData &evt) = 0; + virtual void handle(const bluetooth::event::Base &evt) = 0; + virtual void handle(const bluetooth::event::StartScan &evt) = 0; + virtual void handle(const bluetooth::event::StopScan &evt) = 0; + virtual void handle(const bluetooth::event::GetDevicesAvailable &evt) = 0; + virtual void handle(const bluetooth::event::VisibilityOn &evt) = 0; + virtual void handle(const bluetooth::event::VisibilityOff &evt) = 0; + virtual void handle(const bluetooth::event::ConnectAudio &evt) = 0; + virtual void handle(const bluetooth::event::DisconnectAudio &evt) = 0; + virtual void handle(const bluetooth::event::PowerOn &evt) = 0; + virtual void handle(const bluetooth::event::PowerOff &evt) = 0; + virtual void handle(const bluetooth::event::ShutDown &evt) = 0; + virtual void handle(const bluetooth::event::Pair &evt) = 0; + virtual void handle(const bluetooth::event::Unpair &evt) = 0; + virtual void handle(const bluetooth::event::StartRinging &evt) = 0; + virtual void handle(const bluetooth::event::StopRinging &evt) = 0; + virtual void handle(const bluetooth::event::StartRouting &evt) = 0; + virtual void handle(const bluetooth::event::StartStream &evt) = 0; + virtual void handle(const bluetooth::event::StopStream &evt) = 0; + virtual void handle(const bluetooth::event::CallAnswered &evt) = 0; + virtual void handle(const bluetooth::event::CallTerminated &evt) = 0; + virtual void handle(const bluetooth::event::CallStarted &evt) = 0; + virtual void handle(const bluetooth::event::IncomingCallNumber &evt) = 0; + virtual void handle(const bluetooth::event::SignalStrengthData &evt) = 0; + virtual void handle(const bluetooth::event::OperatorNameData &evt) = 0; + virtual void handle(const bluetooth::event::BatteryLevelData &evt) = 0; + virtual void handle(const bluetooth::event::NetworkStatusData &evt) = 0; }; }; // namespace bluetooth diff --git a/module-bluetooth/Bluetooth/BluetoothStateMachine.hpp b/module-bluetooth/Bluetooth/BluetoothStateMachine.hpp index 53abba651c97eb23f1c92fd1c6a69017c3f35798..f28972adeea3a85477d356439e637232e188f346 100644 --- a/module-bluetooth/Bluetooth/BluetoothStateMachine.hpp +++ b/module-bluetooth/Bluetooth/BluetoothStateMachine.hpp @@ -110,7 +110,7 @@ namespace bluetooth struct HandlePair { - void operator()(std::shared_ptr handler, const bt::evt::Pair &event) + void operator()(std::shared_ptr handler, const bluetooth::event::Pair &event) { handler->pair(event.device); } @@ -118,7 +118,7 @@ namespace bluetooth struct Connected { - bool operator()(std::shared_ptr settings, bt::evt::Unpair evt) + bool operator()(std::shared_ptr settings, bluetooth::event::Unpair evt) { auto deviceAddr = std::visit(bluetooth::StringVisitor(), settings->getValue(bluetooth::Settings::ConnectedDevice)); @@ -128,7 +128,7 @@ namespace bluetooth struct HandleUnpair { - void operator()(std::shared_ptr handler, const bt::evt::Unpair &event) + void operator()(std::shared_ptr handler, const bluetooth::event::Unpair &event) { handler->unpair(event.device); } @@ -136,7 +136,7 @@ namespace bluetooth struct HandleDrop { - void operator()(const bt::evt::Unpair &event, + void operator()(const bluetooth::event::Unpair &event, std::shared_ptr settings, std::shared_ptr> pairedDevices) { @@ -180,7 +180,7 @@ namespace bluetooth struct EstablishAudioConnection { - void operator()(std::shared_ptr handler, bt::evt::ConnectAudio evt) + void operator()(std::shared_ptr handler, bluetooth::event::ConnectAudio evt) { handler->establishAudioConnection(evt.device); } @@ -229,7 +229,8 @@ namespace bluetooth struct CallStarted { - void operator()(std::shared_ptr profileManager, bt::evt::CallStarted evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::CallStarted evt) { profileManager->callStarted(evt.number); } @@ -237,7 +238,8 @@ namespace bluetooth struct IncomingCall { - void operator()(std::shared_ptr profileManager, bt::evt::IncomingCallNumber evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::IncomingCallNumber evt) { profileManager->setIncomingCallNumber(evt.number); } @@ -245,7 +247,8 @@ namespace bluetooth struct SignalStrength { - void operator()(std::shared_ptr profileManager, bt::evt::SignalStrengthData evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::SignalStrengthData evt) { profileManager->setSignalStrengthData(evt.strength); } @@ -253,7 +256,8 @@ namespace bluetooth struct SetOperatorName { - void operator()(std::shared_ptr profileManager, bt::evt::OperatorNameData evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::OperatorNameData evt) { profileManager->setOperatorNameData(bluetooth::OperatorName(evt.name)); } @@ -261,7 +265,8 @@ namespace bluetooth struct SetBatteryLevel { - void operator()(std::shared_ptr profileManager, bt::evt::BatteryLevelData evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::BatteryLevelData evt) { profileManager->setBatteryLevelData(evt.level); } @@ -269,7 +274,8 @@ namespace bluetooth struct SetNetworkStatus { - void operator()(std::shared_ptr profileManager, bt::evt::NetworkStatusData evt) + void operator()(std::shared_ptr profileManager, + bluetooth::event::NetworkStatusData evt) { profileManager->setNetworkStatusData(evt.status); } @@ -309,21 +315,21 @@ namespace bluetooth using namespace sml; // clang-format off return make_transition_table( - *"CallSetup"_s + event / StartRinging = "CallRinging"_s, - "CallSetup"_s + event / InitializeCall = "CallInitiated"_s, - "CallSetup"_s + event / CallStarted = "CallInitiated"_s, - "CallSetup"_s + event / (StartRinging, IncomingCall) = "CallRinging"_s, + *"CallSetup"_s + sml::event / StartRinging = "CallRinging"_s, + "CallSetup"_s + sml::event / InitializeCall = "CallInitiated"_s, + "CallSetup"_s + sml::event / CallStarted = "CallInitiated"_s, + "CallSetup"_s + sml::event / (StartRinging, IncomingCall) = "CallRinging"_s, - "CallRinging"_s + event / StopRinging = "CallDropped"_s, - "CallRinging"_s + event / CallAnswered = "CallInProgress"_s, - "CallRinging"_s + event / TerminateCall = "CallDropped"_s, + "CallRinging"_s + sml::event / StopRinging = "CallDropped"_s, + "CallRinging"_s + sml::event / CallAnswered = "CallInProgress"_s, + "CallRinging"_s + sml::event / TerminateCall = "CallDropped"_s, - "CallInitiated"_s + event / CallAnswered = "CallInProgress"_s, - "CallInitiated"_s + event / StopRinging = "CallDropped"_s, - "CallInitiated"_s + event / TerminateCall = "CallDropped"_s, - "CallInitiated"_s + event / IncomingCall= "CallInitiated"_s, + "CallInitiated"_s + sml::event / CallAnswered = "CallInProgress"_s, + "CallInitiated"_s + sml::event / StopRinging = "CallDropped"_s, + "CallInitiated"_s + sml::event / TerminateCall = "CallDropped"_s, + "CallInitiated"_s + sml::event / IncomingCall= "CallInitiated"_s, - "CallInProgress"_s + event / TerminateCall = "CallDropped"_s, + "CallInProgress"_s + sml::event / TerminateCall = "CallDropped"_s, "CallDropped"_s = X @@ -340,27 +346,27 @@ namespace bluetooth using namespace sml; // clang-format off return make_transition_table( - *state + event / HandleOn = state, - state + event / HandleOff = state, - state + event / HandlePair = state, - state + event[Connected] / (HandleDisconnect, HandleUnpair) = state, - state + event[not Connected] / (HandleUnpair, HandleDrop) = state, - - state + event / HandleSetVisibility = state, - state + event / HandleUnsetVisibility = state, - state + event / EstablishAudioConnection = state, - - state + event / SignalStrength = state, - state + event/ SetOperatorName = state, - state + event/ SetBatteryLevel = state, - state + event / SetNetworkStatus = state, - state + event/ StartAudio = state, - state + event/ StopAudio = state, - - state + event / forwardEvent= state, - - state + event / forwardEvent = state, - state + event / forwardEvent= state, + *state + sml::event / HandleOn = state, + state + sml::event / HandleOff = state, + state + sml::event / HandlePair = state, + state + sml::event[Connected] / (HandleDisconnect, HandleUnpair) = state, + state + sml::event[not Connected] / (HandleUnpair, HandleDrop) = state, + + state + sml::event / HandleSetVisibility = state, + state + sml::event / HandleUnsetVisibility = state, + state + sml::event / EstablishAudioConnection = state, + + state + sml::event / SignalStrength = state, + state + sml::event/ SetOperatorName = state, + state + sml::event/ SetBatteryLevel = state, + state + sml::event / SetNetworkStatus = state, + state + sml::event/ StartAudio = state, + state + sml::event/ StopAudio = state, + + state + sml::event / forwardEvent= state, + + state + sml::event / forwardEvent = state, + state + sml::event / forwardEvent= state, state = state // this one is needed to go out from Call substate properly! ); @@ -396,22 +402,22 @@ namespace bluetooth using namespace sml; // clang-format off - return make_transition_table(*"Off"_s + event = state, + return make_transition_table(*"Off"_s + sml::event = state, state[isInit] = state, state[not isInit] = "Restart"_s, state + exception / printInitError = "Off"_s, - state + event / TurnOff = "Off"_s, + state + sml::event / TurnOff = "Off"_s, state + exception / ( printProcessingError, TurnOff ) = "Restart"_s, - state + event / TurnOff = X, + state + sml::event / TurnOff = X, "Restart"_s = state, - "Restart"_s + event /TurnOff = X, + "Restart"_s + sml::event /TurnOff = X, *("ExceptionsHandling"_s) + exception / ExceptionHandler = "Off"_s, "ExceptionsHandling"_s + exception / ExceptionHandler = "Off"_s, - "Off"_s + event = X); + "Off"_s + sml::event = X); // clang-format on } }; diff --git a/module-bluetooth/Bluetooth/BluetoothWorker.cpp b/module-bluetooth/Bluetooth/BluetoothWorker.cpp index 1b95ea1f5ab2ce121f5fd59aaa69ca79dd9f2dfc..48be68c42a6a804534ab4fefcc96907a97349075 100644 --- a/module-bluetooth/Bluetooth/BluetoothWorker.cpp +++ b/module-bluetooth/Bluetooth/BluetoothWorker.cpp @@ -136,7 +136,7 @@ void BluetoothWorker::onLinkKeyAdded(const std::string &deviceAddress) BluetoothWorker::~BluetoothWorker() { - controller->handle(bt::evt::ShutDown{}); + controller->handle(bluetooth::event::ShutDown{}); } auto BluetoothWorker::run() -> bool @@ -163,7 +163,7 @@ auto BluetoothWorker::handleCommand(QueueHandle_t queue) -> bool LOG_ERROR("There was no data even with notification"); break; } - if ((*command).event != nullptr) { + if (command->event != nullptr) { controller->handle(*command->event); } } @@ -262,7 +262,7 @@ auto BluetoothWorker::handleMessage(uint32_t queueID) -> bool void BluetoothWorker::closeWorker() { - controller->handle(bt::evt::PowerOff{}); + controller->handle(bluetooth::event::PowerOff{}); this->close(); } diff --git a/module-bluetooth/Bluetooth/WorkerController.cpp b/module-bluetooth/Bluetooth/WorkerController.cpp index e442c237c6406ebd1da12e5b2f76efe3f6754b5a..095ec714493d908c8395f8e25200a317875a674a 100644 --- a/module-bluetooth/Bluetooth/WorkerController.cpp +++ b/module-bluetooth/Bluetooth/WorkerController.cpp @@ -31,7 +31,7 @@ namespace bluetooth //-------------------------------------------------------------------- // entry to dispatch to call handle (double visitor -> double dispatch) - void StatefulController::handle(const bt::evt::Base &evt) + void StatefulController::handle(const bluetooth::event::Base &evt) { evt.dispatch(this); } @@ -39,103 +39,103 @@ namespace bluetooth //----------------------------------------- // all `handle` code below is casual visitor - void StatefulController::handle(const bt::evt::StartScan &evt) + void StatefulController::handle(const bluetooth::event::StartScan &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StopScan &evt) + void StatefulController::handle(const bluetooth::event::StopScan &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::GetDevicesAvailable &evt) + void StatefulController::handle(const bluetooth::event::GetDevicesAvailable &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::VisibilityOn &evt) + void StatefulController::handle(const bluetooth::event::VisibilityOn &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::VisibilityOff &evt) + void StatefulController::handle(const bluetooth::event::VisibilityOff &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::ConnectAudio &evt) + void StatefulController::handle(const bluetooth::event::ConnectAudio &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::DisconnectAudio &evt) + void StatefulController::handle(const bluetooth::event::DisconnectAudio &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::PowerOn &evt) + void StatefulController::handle(const bluetooth::event::PowerOn &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::PowerOff &evt) + void StatefulController::handle(const bluetooth::event::PowerOff &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::ShutDown &evt) + void StatefulController::handle(const bluetooth::event::ShutDown &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::Pair &evt) + void StatefulController::handle(const bluetooth::event::Pair &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::Unpair &evt) + void StatefulController::handle(const bluetooth::event::Unpair &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StartRinging &evt) + void StatefulController::handle(const bluetooth::event::StartRinging &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StopRinging &evt) + void StatefulController::handle(const bluetooth::event::StopRinging &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StartRouting &evt) + void StatefulController::handle(const bluetooth::event::StartRouting &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StartStream &evt) + void StatefulController::handle(const bluetooth::event::StartStream &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::StopStream &evt) + void StatefulController::handle(const bluetooth::event::StopStream &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::CallAnswered &evt) + void StatefulController::handle(const bluetooth::event::CallAnswered &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::CallTerminated &evt) + void StatefulController::handle(const bluetooth::event::CallTerminated &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::CallStarted &evt) + void StatefulController::handle(const bluetooth::event::CallStarted &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::IncomingCallNumber &evt) + void StatefulController::handle(const bluetooth::event::IncomingCallNumber &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::SignalStrengthData &evt) + void StatefulController::handle(const bluetooth::event::SignalStrengthData &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::OperatorNameData &evt) + void StatefulController::handle(const bluetooth::event::OperatorNameData &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::BatteryLevelData &evt) + void StatefulController::handle(const bluetooth::event::BatteryLevelData &evt) { pimpl->sm.process_event(evt); }; - void StatefulController::handle(const bt::evt::NetworkStatusData &evt) + void StatefulController::handle(const bluetooth::event::NetworkStatusData &evt) { pimpl->sm.process_event(evt); }; diff --git a/module-bluetooth/Bluetooth/WorkerController.hpp b/module-bluetooth/Bluetooth/WorkerController.hpp index b110f09afb2f0ba364100924eb8edfaec1c527e7..fe284afc0248d31667e817b2a022a9a9e12346f7 100644 --- a/module-bluetooth/Bluetooth/WorkerController.hpp +++ b/module-bluetooth/Bluetooth/WorkerController.hpp @@ -32,32 +32,32 @@ namespace bluetooth ~StatefulController() noexcept override; - void handle(const bt::evt::Base &evt) override; - void handle(const bt::evt::StartScan &evt) override; - void handle(const bt::evt::StopScan &evt) override; - void handle(const bt::evt::GetDevicesAvailable &evt) override; - void handle(const bt::evt::VisibilityOn &evt) override; - void handle(const bt::evt::VisibilityOff &evt) override; - void handle(const bt::evt::ConnectAudio &evt) override; - void handle(const bt::evt::DisconnectAudio &evt) override; - void handle(const bt::evt::PowerOn &evt) override; - void handle(const bt::evt::PowerOff &evt) override; - void handle(const bt::evt::ShutDown &evt) override; - void handle(const bt::evt::Pair &evt) override; - void handle(const bt::evt::Unpair &evt) override; - void handle(const bt::evt::StartRinging &evt) override; - void handle(const bt::evt::StopRinging &evt) override; - void handle(const bt::evt::StartRouting &evt) override; - void handle(const bt::evt::StartStream &evt) override; - void handle(const bt::evt::StopStream &evt) override; - void handle(const bt::evt::CallAnswered &evt) override; - void handle(const bt::evt::CallTerminated &evt) override; - void handle(const bt::evt::CallStarted &evt) override; - void handle(const bt::evt::IncomingCallNumber &evt) override; - void handle(const bt::evt::SignalStrengthData &evt) override; - void handle(const bt::evt::OperatorNameData &evt) override; - void handle(const bt::evt::BatteryLevelData &evt) override; - void handle(const bt::evt::NetworkStatusData &evt) override; + void handle(const bluetooth::event::Base &evt) override; + void handle(const bluetooth::event::StartScan &evt) override; + void handle(const bluetooth::event::StopScan &evt) override; + void handle(const bluetooth::event::GetDevicesAvailable &evt) override; + void handle(const bluetooth::event::VisibilityOn &evt) override; + void handle(const bluetooth::event::VisibilityOff &evt) override; + void handle(const bluetooth::event::ConnectAudio &evt) override; + void handle(const bluetooth::event::DisconnectAudio &evt) override; + void handle(const bluetooth::event::PowerOn &evt) override; + void handle(const bluetooth::event::PowerOff &evt) override; + void handle(const bluetooth::event::ShutDown &evt) override; + void handle(const bluetooth::event::Pair &evt) override; + void handle(const bluetooth::event::Unpair &evt) override; + void handle(const bluetooth::event::StartRinging &evt) override; + void handle(const bluetooth::event::StopRinging &evt) override; + void handle(const bluetooth::event::StartRouting &evt) override; + void handle(const bluetooth::event::StartStream &evt) override; + void handle(const bluetooth::event::StopStream &evt) override; + void handle(const bluetooth::event::CallAnswered &evt) override; + void handle(const bluetooth::event::CallTerminated &evt) override; + void handle(const bluetooth::event::CallStarted &evt) override; + void handle(const bluetooth::event::IncomingCallNumber &evt) override; + void handle(const bluetooth::event::SignalStrengthData &evt) override; + void handle(const bluetooth::event::OperatorNameData &evt) override; + void handle(const bluetooth::event::BatteryLevelData &evt) override; + void handle(const bluetooth::event::NetworkStatusData &evt) override; class Impl; diff --git a/module-bluetooth/Bluetooth/command/Command.hpp b/module-bluetooth/Bluetooth/command/Command.hpp index 211fe08bc040ed95e38f2d8a0f79aa870d8f887e..4b0e08600b02130d4a31ed014fd4c7bad22ad69f 100644 --- a/module-bluetooth/Bluetooth/command/Command.hpp +++ b/module-bluetooth/Bluetooth/command/Command.hpp @@ -10,7 +10,7 @@ namespace bluetooth struct Command { - std::unique_ptr event; + std::unique_ptr event; }; } // namespace bluetooth diff --git a/module-bluetooth/Bluetooth/command/event/Events.hpp b/module-bluetooth/Bluetooth/command/event/Events.hpp index 1b5590f6fab81b817f3749be32f2cfb6d8cbea66..4c8975fbf0acc82cff5ed0409bdc0d7b40f2c469 100644 --- a/module-bluetooth/Bluetooth/command/event/Events.hpp +++ b/module-bluetooth/Bluetooth/command/event/Events.hpp @@ -9,7 +9,7 @@ #include "AbstractController.hpp" #include "log/log.hpp" -namespace bt::evt +namespace bluetooth::event { struct Base { @@ -228,4 +228,4 @@ namespace bt::evt controler->handle(*this); } }; -} // namespace bt::evt +} // namespace bluetooth::event diff --git a/module-bluetooth/Bluetooth/doc/bluetooth_states.svg b/module-bluetooth/Bluetooth/doc/bluetooth_states.svg index e7502a405103f89380cefc558a693360ef14b021..0c6f753d01c359109208deaee58f23f0d6fb8627 100644 --- a/module-bluetooth/Bluetooth/doc/bluetooth_states.svg +++ b/module-bluetooth/Bluetooth/doc/bluetooth_states.svg @@ -1,58 +1,58 @@ Offbluetooth::Setupbluetooth:Setup {:On {:Call {Setupon_entry[!bluetooth::IsInit] /(bluetooth::InitDevicesList,bluetooth::InitDriver,bluetooth::PostInit)bluetooth::Onbluetooth::Idlebluetooth::CallCallSetupCallRingingCallInitiatedCallDroppedCallInProgressRestartExceptionsHandlingbt::evt::PowerOnbluetooth::event::PowerOninternal_event /bluetooth::StateMachine::operator()() const::<lambda(const bluetooth::InitializationError&)>/bluetooth::StartDriver[bluetooth::IsInit]bt::evt::StartScan /bluetooth::HandleOnbt::evt::StopScan /bluetooth::HandleOffbt::evt::Pair /bluetooth::HandlePairbt::evt::Unpair[bluetooth::Connected] /(bluetooth::HandleDisconnect,bluetooth::HandleUnpair)bt::evt::Unpair[!bluetooth::Connected] /(bluetooth::HandleUnpair,bluetooth::HandleDrop)bt::evt::VisibilityOn /bluetooth::HandleSetVisibilitybt::evt::VisibilityOff /bluetooth::HandleUnsetVisibilitybt::evt::ConnectAudio /bluetooth::EstablishAudioConnectionbt::evt::SignalStrengthData /bluetooth::SignalStrengthbt::evt::OperatorNameData /bluetooth::SetOperatorNamebt::evt::BatteryLevelData /bluetooth::SetBatteryLevelbt::evt::NetworkStatusData /bluetooth::SetNetworkStatusbt::evt::StartStream /bluetooth::StartAudiobt::evt::StopStream /bluetooth::StopAudiobt::evt::StartRouting /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bt::evt::StartRinging /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bt::evt::IncomingCallNumber /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bt::evt::CallStarted /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bluetooth::event::StartScan /bluetooth::HandleOnbluetooth::event::StopScan /bluetooth::HandleOffbluetooth::event::Pair /bluetooth::HandlePairbluetooth::event::Unpair[bluetooth::Connected] /(bluetooth::HandleDisconnect,bluetooth::HandleUnpair)bluetooth::event::Unpair[!bluetooth::Connected] /(bluetooth::HandleUnpair,bluetooth::HandleDrop)bluetooth::event::VisibilityOn /bluetooth::HandleSetVisibilitybluetooth::event::VisibilityOff /bluetooth::HandleUnsetVisibilitybluetooth::event::ConnectAudio /bluetooth::EstablishAudioConnectionbluetooth::event::SignalStrengthData /bluetooth::SignalStrengthbluetooth::event::OperatorNameData /bluetooth::SetOperatorNamebluetooth::event::BatteryLevelData /bluetooth::SetBatteryLevelbluetooth::event::NetworkStatusData /bluetooth::SetNetworkStatusbluetooth::event::StartStream /bluetooth::StartAudiobluetooth::event::StopStream /bluetooth::StopAudiobluetooth::event::StartRouting /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bluetooth::event::StartRinging /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bluetooth::event::IncomingCallNumber /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bluetooth::event::CallStarted /bluetooth::On::operator()() const::<lambda(const auto:25&, auto:26&, auto:27&, auto:28&)>bt::evt::StartRinging /bluetooth::StartRingingbt::evt::IncomingCallNumber /(bluetooth::StartRinging,bluetooth::IncomingCall)bt::evt::StartRouting /bluetooth::InitializeCallbt::evt::CallStarted /bluetooth::CallStartedbt::evt::StopRinging /bluetooth::StopRingingbt::evt::CallTerminated /bluetooth::TerminateCallbt::evt::CallAnswered /bluetooth::CallAnsweredbt::evt::CallAnswered /bluetooth::CallAnsweredbt::evt::StopRinging /bluetooth::StopRingingbt::evt::CallTerminated /bluetooth::TerminateCallbt::evt::IncomingCallNumber /bluetooth::IncomingCallbt::evt::CallTerminated /bluetooth::TerminateCallbluetooth::event::StartRinging /bluetooth::StartRingingbluetooth::event::IncomingCallNumber /(bluetooth::StartRinging,bluetooth::IncomingCall)bluetooth::event::StartRouting /bluetooth::InitializeCallbluetooth::event::CallStarted /bluetooth::CallStartedbluetooth::event::StopRinging /bluetooth::StopRingingbluetooth::event::CallTerminated /bluetooth::TerminateCallbluetooth::event::CallAnswered /bluetooth::CallAnsweredbluetooth::event::CallAnswered /bluetooth::CallAnsweredbluetooth::event::StopRinging /bluetooth::StopRingingbluetooth::event::CallTerminated /bluetooth::TerminateCallbluetooth::event::IncomingCallNumber /bluetooth::IncomingCallbluetooth::event::CallTerminated /bluetooth::TerminateCall[!bluetooth::IsInit]bt::evt::PowerOff /bluetooth::TurnOffbluetooth::event::PowerOff /bluetooth::TurnOffinternal_event /(bluetooth::StateMachine::operator()() const::<lambda(const bluetooth::ProcessingError&)>,bluetooth::TurnOff)bt::evt::ShutDown /bluetooth::TurnOffbt::evt::ShutDown /bluetooth::TurnOffbluetooth::event::ShutDown /bluetooth::TurnOffbluetooth::event::ShutDown /bluetooth::TurnOffinternal_event /bluetooth::ExceptionHandlerinternal_event /bluetooth::ExceptionHandlerbt::evt::ShutDownbluetooth::event::ShutDown \ No newline at end of file +--> diff --git a/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp b/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp index d074797d6901189025475c2f919e7dc5f48e63df..205dde18e32a7fe7ed877fbc6c214e4b09bd8a3f 100644 --- a/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp +++ b/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp @@ -17,10 +17,10 @@ namespace bluetooth virtual ~AbstractDriver() noexcept = default; using ErrorCallback = std::function; - [[nodiscard]] virtual auto init() -> Error::Code = 0; - [[nodiscard]] virtual auto run() -> Error::Code = 0; - [[nodiscard]] virtual auto stop() -> Error::Code = 0; - [[nodiscard]] virtual auto scan() -> Error = 0; + [[nodiscard]] virtual auto init() -> Error::Code = 0; + [[nodiscard]] virtual auto run() -> Error::Code = 0; + [[nodiscard]] virtual auto stop() -> Error::Code = 0; + [[nodiscard]] virtual auto scan() -> Error = 0; virtual void stopScan() = 0; virtual void setVisibility(bool visibility) = 0; virtual void pair(Devicei device, std::uint8_t protectionLevel = 0) = 0; diff --git a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp index e4f1c348c56dab72856a0d6197d7fc5420a0b5b2..e1e26361b025c0d84aac87caa6581c3cec577d59 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp +++ b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp @@ -31,7 +31,7 @@ namespace bluetooth public: virtual ~BaseProfileManager() = default; virtual auto init() -> Error::Code = 0; - virtual void deInit() = 0; + virtual void deInit() = 0; virtual auto connect(const Devicei &device) -> Error::Code = 0; virtual auto disconnect() -> Error::Code = 0; virtual auto start() -> Error::Code = 0; diff --git a/module-bluetooth/tests/tests-StatefulController.cpp b/module-bluetooth/tests/tests-StatefulController.cpp index 2daca63e3279bcf029b25da496dca0db23f8ed6d..da7c5b864c0b0c79d804edac0af32875c63415b0 100644 --- a/module-bluetooth/tests/tests-StatefulController.cpp +++ b/module-bluetooth/tests/tests-StatefulController.cpp @@ -128,10 +128,10 @@ TEST_CASE("Given StatefulController when turn on then turned on") auto sm = mock::SM(); auto controller = sm.get(); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(controller.sm.is(state)); - controller.sm.process_event(bt::evt::PowerOff{}); + controller.sm.process_event(bluetooth::event::PowerOff{}); REQUIRE(controller.sm.is("Off"_s)); } @@ -143,13 +143,13 @@ TEST_CASE("pair/unpair") auto controller = sm.get(); auto device = Devicei{"lol"}; - REQUIRE(controller.sm.process_event(bt::evt::PowerOn{})); + REQUIRE(controller.sm.process_event(bluetooth::event::PowerOn{})); REQUIRE(controller.sm.is(state)); - REQUIRE(controller.sm.process_event(bt::evt::Pair{device})); + REQUIRE(controller.sm.process_event(bluetooth::event::Pair{device})); fakeit::Verify(Method(sm.h, pair)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::Unpair{device})); + REQUIRE(controller.sm.process_event(bluetooth::event::Unpair{device})); fakeit::Verify(Method(sm.h, unpair)).Exactly(1); } @@ -159,13 +159,13 @@ TEST_CASE("start/stop scan") auto sm = mock::SM(); auto controller = sm.get(); - REQUIRE(controller.sm.process_event(bt::evt::PowerOn{})); + REQUIRE(controller.sm.process_event(bluetooth::event::PowerOn{})); REQUIRE(controller.sm.is(state)); - REQUIRE(controller.sm.process_event(bt::evt::StartScan{})); + REQUIRE(controller.sm.process_event(bluetooth::event::StartScan{})); fakeit::Verify(Method(sm.h, scan)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::StopScan{})); + REQUIRE(controller.sm.process_event(bluetooth::event::StopScan{})); fakeit::Verify(Method(sm.h, stopScan)).Exactly(1); } @@ -175,18 +175,18 @@ TEST_CASE("call test - incoming call") auto sm = mock::SM(); auto controller = sm.get(); - REQUIRE(controller.sm.process_event(bt::evt::PowerOn{})); + REQUIRE(controller.sm.process_event(bluetooth::event::PowerOn{})); REQUIRE(controller.sm.is(state)); auto number = utils::PhoneNumber::View{}; SECTION("dropped call") { - REQUIRE(controller.sm.process_event(bt::evt::IncomingCallNumber{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::IncomingCallNumber{number})); REQUIRE(controller.sm.is)>("CallRinging"_s)); fakeit::Verify(Method(sm.p, startRinging)).Exactly(1); fakeit::Verify(Method(sm.p, setIncomingCallNumber)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallTerminated{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallTerminated{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, terminateCall)).Exactly(1); @@ -194,16 +194,16 @@ TEST_CASE("call test - incoming call") SECTION("answered call") { - REQUIRE(controller.sm.process_event(bt::evt::IncomingCallNumber{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::IncomingCallNumber{number})); REQUIRE(controller.sm.is)>("CallRinging"_s)); fakeit::Verify(Method(sm.p, startRinging)).Exactly(1); fakeit::Verify(Method(sm.p, setIncomingCallNumber)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallAnswered{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallAnswered{})); REQUIRE(controller.sm.is)>("CallInProgress"_s)); fakeit::Verify(Method(sm.p, callAnswered)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallTerminated{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallTerminated{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, terminateCall)).Exactly(1); @@ -211,12 +211,12 @@ TEST_CASE("call test - incoming call") SECTION("missed call") { - REQUIRE(controller.sm.process_event(bt::evt::IncomingCallNumber{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::IncomingCallNumber{number})); REQUIRE(controller.sm.is)>("CallRinging"_s)); fakeit::Verify(Method(sm.p, startRinging)).Exactly(1); fakeit::Verify(Method(sm.p, setIncomingCallNumber)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::StopRinging{})); + REQUIRE(controller.sm.process_event(bluetooth::event::StopRinging{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, stopRinging)).Exactly(1); @@ -224,22 +224,22 @@ TEST_CASE("call test - incoming call") SECTION("double missed call") { LOG_INFO("Double missed call"); - REQUIRE(controller.sm.process_event(bt::evt::IncomingCallNumber{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::IncomingCallNumber{number})); REQUIRE(controller.sm.is)>("CallRinging"_s)); fakeit::Verify(Method(sm.p, startRinging)).Exactly(1); fakeit::Verify(Method(sm.p, setIncomingCallNumber)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::StopRinging{})); + REQUIRE(controller.sm.process_event(bluetooth::event::StopRinging{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, stopRinging)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::IncomingCallNumber{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::IncomingCallNumber{number})); REQUIRE(controller.sm.is)>("CallRinging"_s)); fakeit::Verify(Method(sm.p, startRinging)).Exactly(2); fakeit::Verify(Method(sm.p, setIncomingCallNumber)).Exactly(2); - REQUIRE(controller.sm.process_event(bt::evt::StopRinging{})); + REQUIRE(controller.sm.process_event(bluetooth::event::StopRinging{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, stopRinging)).Exactly(2); @@ -252,17 +252,17 @@ TEST_CASE("call test - outgoing call") auto sm = mock::SM(); auto controller = sm.get(); - REQUIRE(controller.sm.process_event(bt::evt::PowerOn{})); + REQUIRE(controller.sm.process_event(bluetooth::event::PowerOn{})); REQUIRE(controller.sm.is(state)); auto number = utils::PhoneNumber::View{}; SECTION("dropped call") { - REQUIRE(controller.sm.process_event(bt::evt::CallStarted{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallStarted{number})); REQUIRE(controller.sm.is)>("CallInitiated"_s)); fakeit::Verify(Method(sm.p, callStarted)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallTerminated{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallTerminated{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, terminateCall)).Exactly(1); @@ -270,15 +270,15 @@ TEST_CASE("call test - outgoing call") SECTION("answered call") { - REQUIRE(controller.sm.process_event(bt::evt::CallStarted{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallStarted{number})); REQUIRE(controller.sm.is)>("CallInitiated"_s)); fakeit::Verify(Method(sm.p, callStarted)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallAnswered{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallAnswered{})); REQUIRE(controller.sm.is)>("CallInProgress"_s)); fakeit::Verify(Method(sm.p, callAnswered)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallTerminated{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallTerminated{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, terminateCall)).Exactly(1); @@ -286,11 +286,11 @@ TEST_CASE("call test - outgoing call") SECTION("miss-clicked call") { - REQUIRE(controller.sm.process_event(bt::evt::CallStarted{number})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallStarted{number})); REQUIRE(controller.sm.is)>("CallInitiated"_s)); fakeit::Verify(Method(sm.p, callStarted)).Exactly(1); - REQUIRE(controller.sm.process_event(bt::evt::CallTerminated{})); + REQUIRE(controller.sm.process_event(bluetooth::event::CallTerminated{})); REQUIRE(controller.sm.is)>(sml::X)); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.p, terminateCall)).Exactly(1); @@ -303,7 +303,7 @@ TEST_CASE("Given StatefulController when error during device registration then t auto sm = mock::SM([]() { return bluetooth::Error::Code::SystemError; }); auto controller = sm.get(); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(!controller.sm.is(state)); } @@ -315,7 +315,7 @@ TEST_CASE("Given StatefulController when error during driver init then turned of fakeit::When(Method(sm.d, init)).AlwaysReturn(Error::Code::SystemError); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(!controller.sm.is(state)); } @@ -325,14 +325,14 @@ TEST_CASE("Given StatefulController when restart then don't init twice") auto sm = mock::SM(); auto controller = sm.get(); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(controller.sm.is(state)); fakeit::Verify(Method(sm.d, init)).Exactly(1); - controller.sm.process_event(bt::evt::PowerOff{}); + controller.sm.process_event(bluetooth::event::PowerOff{}); REQUIRE(controller.sm.is("Off"_s)); fakeit::Verify(Method(sm.d, init)).Exactly(1); fakeit::Verify(Method(sm.p, deInit)).Exactly(1); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); fakeit::Verify(Method(sm.d, init)).Exactly(1); REQUIRE(controller.sm.is(state)); } @@ -342,14 +342,14 @@ TEST_CASE("Given StatefulController when turn off in off state then turned off") auto sm = mock::SM(); auto controller = sm.get(); // there is no Off -> Off transition so it won't be handled - REQUIRE(not controller.sm.process_event(bt::evt::PowerOff{})); + REQUIRE(not controller.sm.process_event(bluetooth::event::PowerOff{})); } TEST_CASE("Given StatefulController when shutdown in off state then terminated") { auto sm = mock::SM(); auto controller = sm.get(); - controller.sm.process_event(bt::evt::ShutDown{}); + controller.sm.process_event(bluetooth::event::ShutDown{}); REQUIRE(controller.sm.is(boost::sml::X)); } @@ -358,9 +358,9 @@ TEST_CASE("Given StatefulController when shutdown in on state then terminated") auto sm = mock::SM(); auto controller = sm.get(); // there is no Off -> Off transition so it won't be handled - REQUIRE(controller.sm.process_event(bt::evt::PowerOn{})); - controller.sm.process_event(bt::evt::PowerOff{}); - controller.sm.process_event(bt::evt::ShutDown{}); + REQUIRE(controller.sm.process_event(bluetooth::event::PowerOn{})); + controller.sm.process_event(bluetooth::event::PowerOff{}); + controller.sm.process_event(bluetooth::event::ShutDown{}); REQUIRE(controller.sm.is(boost::sml::X)); } @@ -371,10 +371,10 @@ TEST_CASE("Given StatefulController when processing command failed then restarte auto controller = sm.get(); fakeit::When(Method(sm.d, init)).AlwaysReturn(Error::Code::SystemError); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(!controller.sm.is(state)); fakeit::When(Method(sm.d, init)).AlwaysReturn(Error::Code::Success); - controller.sm.process_event(bt::evt::PowerOn{}); + controller.sm.process_event(bluetooth::event::PowerOn{}); REQUIRE(controller.sm.is(state)); } diff --git a/module-services/service-bluetooth/ServiceBluetooth.cpp b/module-services/service-bluetooth/ServiceBluetooth.cpp index c23ce31efee4b29717b64554f0208404616ed8c0..40c8378d507097714e8f2721df54946021313a20 100644 --- a/module-services/service-bluetooth/ServiceBluetooth.cpp +++ b/module-services/service-bluetooth/ServiceBluetooth.cpp @@ -139,8 +139,8 @@ sys::ReturnCodes ServiceBluetooth::DeinitHandler() void ServiceBluetooth::ProcessCloseReason(sys::CloseReason closeReason) { - sendWorkerCommand(std::make_unique()); - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } sys::MessagePointer ServiceBluetooth::DataReceivedHandler([[maybe_unused]] sys::DataMessage *msg, @@ -193,7 +193,7 @@ auto ServiceBluetooth::handle(message::bluetooth::SetStatus *msg) -> std::shared case BluetoothStatus::State::On: cpuSentinel->HoldMinimumFrequency(bsp::CpuFrequencyMHz::Level_3); - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); bus.sendMulticast( std::make_shared(sys::bluetooth::BluetoothMode::Enabled), sys::BusChannel::BluetoothModeChanges); @@ -213,10 +213,10 @@ auto ServiceBluetooth::handle(message::bluetooth::SetStatus *msg) -> std::shared break; } if (newBtStatus.visibility) { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } else { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } return sys::MessageNone{}; } @@ -226,7 +226,7 @@ auto ServiceBluetooth::handle(BluetoothPairMessage *msg) -> std::shared_ptrgetDevice(); bluetoothDevicesModel->removeDevice(device); - sendWorkerCommand(std::make_unique(device)); + sendWorkerCommand(std::make_unique(device)); device.deviceState = DeviceState::Pairing; bluetoothDevicesModel->insertDevice(device); @@ -255,7 +255,7 @@ auto ServiceBluetooth::handle(BluetoothPairResultMessage *msg) -> std::shared_pt return sys::MessageNone{}; } -void ServiceBluetooth::sendWorkerCommand(std::unique_ptr command) +void ServiceBluetooth::sendWorkerCommand(std::unique_ptr command) { if (workerQueue != nullptr) { workerQueue->push(bluetooth::Command{std::move(command)}); @@ -264,7 +264,7 @@ void ServiceBluetooth::sendWorkerCommand(std::unique_ptr command) auto ServiceBluetooth::handle(message::bluetooth::Unpair *msg) -> std::shared_ptr { - sendWorkerCommand(std::make_unique(msg->getDevice())); + sendWorkerCommand(std::make_unique(msg->getDevice())); bluetoothDevicesModel->removeDevice(msg->getDevice()); return sys::MessageNone{}; } @@ -285,11 +285,11 @@ auto ServiceBluetooth::handle(message::bluetooth::SetDeviceName *msg) -> std::sh auto newName = msg->getName(); bluetooth::set_name(newName); settingsHolder->setValue(bluetooth::Settings::DeviceName, newName); - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); btRestartTimer = sys::TimerFactory::createSingleShotTimer(this, "btRestartTimer", btRestartDelay, [this](sys::Timer &_) { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); }); btRestartTimer.start(); @@ -299,7 +299,7 @@ auto ServiceBluetooth::handle(message::bluetooth::SetDeviceName *msg) -> std::sh auto ServiceBluetooth::handle(message::bluetooth::Connect *msg) -> std::shared_ptr { auto device = msg->getDevice(); - sendWorkerCommand(std::make_unique(device)); + sendWorkerCommand(std::make_unique(device)); bluetoothDevicesModel->setInternalDeviceState(device, DeviceState::Connecting); bluetoothDevicesModel->syncDevicesWithApp(); return sys::MessageNone{}; @@ -349,7 +349,7 @@ auto ServiceBluetooth::handle(message::bluetooth::ConnectResult *msg) -> std::sh auto ServiceBluetooth::handle([[maybe_unused]] message::bluetooth::Disconnect *msg) -> std::shared_ptr { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); return sys::MessageNone{}; } @@ -408,32 +408,32 @@ auto ServiceBluetooth::handle(BluetoothMessage *msg) -> std::shared_ptrreq) { case BluetoothMessage::Scan: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; case BluetoothMessage::StopScan: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; case BluetoothMessage::getDevicesAvailable: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; case BluetoothMessage::Visible: { auto visibility = not std::visit(bluetooth::BoolVisitor(), settingsHolder->getValue(bluetooth::Settings::Visibility)); if (visibility) { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } else { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } } break; case BluetoothMessage::Play: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; case BluetoothMessage::Disconnect: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; case BluetoothMessage::Stop: - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); break; default: break; @@ -444,14 +444,14 @@ auto ServiceBluetooth::handle(BluetoothMessage *msg) -> std::shared_ptr std::shared_ptr { - sendWorkerCommand(std::make_unique(msg->device)); + sendWorkerCommand(std::make_unique(msg->device)); return std::make_shared(); } auto ServiceBluetooth::handle(sdesktop::developerMode::DeveloperModeRequest *msg) -> std::shared_ptr { if (typeid(*msg->event) == typeid(sdesktop::bluetooth::GetAvailableDevicesEvent)) { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); } return sys::MessageNone{}; } @@ -478,7 +478,7 @@ auto ServiceBluetooth::handle(message::bluetooth::HFPVolume *msg) -> std::shared auto ServiceBluetooth::handle(message::bluetooth::StartAudioRouting *msg) -> std::shared_ptr { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); return std::make_shared(); } @@ -490,7 +490,7 @@ auto ServiceBluetooth::handle(CellularCallerIdMessage *msg) -> std::shared_ptr(number)); + sendWorkerCommand(std::make_unique(number)); } return sys::MessageNone{}; @@ -498,7 +498,7 @@ auto ServiceBluetooth::handle(CellularCallerIdMessage *msg) -> std::shared_ptr std::shared_ptr { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); return std::make_shared(); } @@ -506,7 +506,7 @@ auto ServiceBluetooth::handle(CellularSignalStrengthUpdateNotification *msg) -> { auto signalStrength = Store::GSM::get()->getSignalStrength(); LOG_DEBUG("Bluetooth: RSSI %d/5", static_cast(signalStrength.rssiBar)); - sendWorkerCommand(std::make_unique(signalStrength)); + sendWorkerCommand(std::make_unique(signalStrength)); return std::make_shared(); } @@ -514,7 +514,7 @@ auto ServiceBluetooth::handle(CellularCurrentOperatorNameNotification *msg) -> s { auto opName = msg->getCurrentOperatorName(); LOG_DEBUG("Bluetooth: Operator name: %s", opName.c_str()); - sendWorkerCommand(std::make_unique(opName)); + sendWorkerCommand(std::make_unique(opName)); return std::make_shared(); } @@ -542,7 +542,7 @@ void ServiceBluetooth::resetTimeoutTimer() void ServiceBluetooth::handleTurnOff() { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); // NOTE: This should be in bluetooth state machine cpuSentinel->ReleaseMinimumFrequency(); bus.sendMulticast(std::make_shared(sys::bluetooth::BluetoothMode::Disabled), @@ -563,31 +563,31 @@ auto ServiceBluetooth::handle(sevm::BatteryStatusChangeMessage *msg) -> std::sha { auto batteryLevel = Store::Battery::get().level; LOG_DEBUG("Bluetooth: Battery level %d", batteryLevel); - sendWorkerCommand(std::make_unique(batteryLevel)); + sendWorkerCommand(std::make_unique(batteryLevel)); return sys::MessageNone{}; } auto ServiceBluetooth::handle(cellular::CallEndedNotification *msg) -> std::shared_ptr { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); return sys::MessageNone{}; } auto ServiceBluetooth::handle(CellularNetworkStatusUpdateNotification *msg) -> std::shared_ptr { auto status = Store::GSM::get()->getNetwork().status; LOG_DEBUG("Bluetooth: Network status %s", magic_enum::enum_name(status).data()); - sendWorkerCommand(std::make_unique(status)); + sendWorkerCommand(std::make_unique(status)); return sys::MessageNone{}; } auto ServiceBluetooth::handle(cellular::CallStartedNotification *msg) -> std::shared_ptr { if (!msg->isCallIncoming()) { - auto evt = std::make_unique(msg->getNumber()); + auto evt = std::make_unique(msg->getNumber()); sendWorkerCommand(std::move(evt)); } return sys::MessageNone{}; } auto ServiceBluetooth::handle(CellularIncominCallMessage *msg) -> std::shared_ptr { - sendWorkerCommand(std::make_unique()); + sendWorkerCommand(std::make_unique()); return sys::MessageNone{}; } diff --git a/module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp b/module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp index f092ffee8392ebde2a7f3438173bb2cda7b8c80f..25b4c8ed95fbefe7d5a51f59e6960876e10e2c6e 100644 --- a/module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp +++ b/module-services/service-bluetooth/service-bluetooth/ServiceBluetooth.hpp @@ -90,7 +90,7 @@ class ServiceBluetooth : public sys::Service void ProcessCloseReason(sys::CloseReason closeReason) override; virtual sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override; - void sendWorkerCommand(std::unique_ptr command); + void sendWorkerCommand(std::unique_ptr command); void handleTurnOff();