AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
BluetoothEvents.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_BLUETOOTH_BLUETOOTHEVENTS_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_BLUETOOTH_BLUETOOTHEVENTS_H_
18 
24 
25 namespace alexaClientSDK {
26 namespace avsCommon {
27 namespace utils {
28 namespace bluetooth {
29 
31 enum class BluetoothEventType {
34 
37 
40 
43 
46 
49 
52 
55 };
56 
59  template <typename T>
60  std::size_t operator()(T t) const {
61  return static_cast<std::size_t>(t);
62  }
63 };
64 
67 public:
71  virtual ~BluetoothEvent() = default;
72 
77  BluetoothEventType getType() const;
78 
83  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> getDevice() const;
84 
90 
95  MediaStreamingState getMediaStreamingState() const;
96 
101  std::shared_ptr<A2DPRole> getA2DPRole() const;
102 
107  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand> getMediaCommand() const;
108 
114  bool isScanning() const;
115 
121  bool isA2DPEnabled() const;
122 
123 protected:
135  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device = nullptr,
138  MediaStreamingState mediaStreamingState = MediaStreamingState::IDLE,
139  std::shared_ptr<A2DPRole> role = nullptr,
140  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand> mediaCommand = nullptr,
141  bool scanningState = false,
142  bool a2dpEnable = false);
143 
144 private:
146  BluetoothEventType m_type;
147 
149  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> m_device;
150 
153 
155  MediaStreamingState m_mediaStreamingState;
156 
158  std::shared_ptr<A2DPRole> m_a2dpRole;
159 
161  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand> m_mediaCommand;
162 
164  bool m_scanningState;
165 
167  bool m_a2dpEnable;
168 };
169 
172  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device,
174  MediaStreamingState mediaStreamingState,
175  std::shared_ptr<A2DPRole> a2dpRole,
176  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand> mediaCommand,
177  bool scanningState,
178  bool a2dpEnable) :
179  m_type{type},
180  m_device{device},
181  m_deviceState{deviceState},
182  m_mediaStreamingState{mediaStreamingState},
183  m_a2dpRole{a2dpRole},
184  m_mediaCommand{mediaCommand},
185  m_scanningState{scanningState},
186  m_a2dpEnable{a2dpEnable} {
187 }
188 
190  return m_type;
191 }
192 
193 inline std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> BluetoothEvent::getDevice()
194  const {
195  return m_device;
196 }
197 
199  return m_deviceState;
200 }
201 
203  return m_mediaStreamingState;
204 }
205 
206 inline std::shared_ptr<A2DPRole> BluetoothEvent::getA2DPRole() const {
207  return m_a2dpRole;
208 }
209 
210 inline std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand> BluetoothEvent::getMediaCommand()
211  const {
212  return m_mediaCommand;
213 }
214 
215 inline bool BluetoothEvent::isScanning() const {
216  return m_scanningState;
217 }
218 
219 inline bool BluetoothEvent::isA2DPEnabled() const {
220  return m_a2dpEnable;
221 }
222 
228 public:
233  explicit DeviceDiscoveredEvent(
234  const std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>& device);
235 };
236 
238  const std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>& device) :
241  device,
242  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
244 }
245 
253 public:
258  explicit DeviceRemovedEvent(
259  const std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>& device);
260 };
261 
263  const std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>& device) :
266  device,
267  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
269 }
270 
276 public:
283  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device,
285 };
286 
288  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device,
291 }
292 
298 public:
306  MediaStreamingState newState,
307  A2DPRole role,
308  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device);
309 };
310 
312  MediaStreamingState newState,
313  A2DPRole role,
314  std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface> device) :
317  device,
318  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
319  newState,
320  std::make_shared<A2DPRole>(role)){};
321 
326 public:
328 };
329 
334  nullptr,
335  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
337  nullptr,
338  std::make_shared<avsCommon::sdkInterfaces::bluetooth::services::MediaCommand>(command)) {
339 }
340 
345 public:
347 };
348 
351 }
352 
357 public:
358  explicit ScanningStateChangedEvent(bool isScanning);
359 };
360 
364  nullptr,
365  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
367  nullptr,
368  nullptr,
369  isScanning) {
370 }
371 
376 public:
377  explicit ToggleA2DPProfileStateChangedEvent(bool a2dpEnable);
378 };
379 
382  BluetoothEventType::TOGGLE_A2DP_PROFILE_STATE_CHANGED,
383  nullptr,
384  avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE,
386  nullptr,
387  nullptr,
388  false,
389  a2dpEnable) {
390 }
391 
392 } // namespace bluetooth
393 } // namespace utils
394 } // namespace avsCommon
395 } // namespace alexaClientSDK
396 
397 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_BLUETOOTH_BLUETOOTHEVENTS_H_
bool isScanning() const
Definition: BluetoothEvents.h:215
avsCommon::sdkInterfaces::bluetooth::DeviceState getDeviceState() const
Definition: BluetoothEvents.h:198
std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::services::MediaCommand > getMediaCommand() const
Definition: BluetoothEvents.h:210
MediaStreamingState
An Enum representing the current state of the stream.
Definition: MediaStreamingState.h:25
Definition: CapabilityConfiguration.h:190
MediaStreamingStateChangedEvent(MediaStreamingState newState, A2DPRole role, std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > device)
Definition: BluetoothEvents.h:311
std::shared_ptr< A2DPRole > getA2DPRole() const
Definition: BluetoothEvents.h:206
BluetoothEventType
The different Bluetooth event types.
Definition: BluetoothEvents.h:31
DeviceRemovedEvent(const std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > &device)
Definition: BluetoothEvents.h:262
Helper struct to allow enum class to be a key in collections.
Definition: BluetoothEvents.h:58
bool isA2DPEnabled() const
Definition: BluetoothEvents.h:219
DeviceDiscoveredEvent(const std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > &device)
Definition: BluetoothEvents.h:237
MediaCommand
An Enum representing Media commands.
Definition: AVRCPTargetInterface.h:32
ScanningStateChangedEvent(bool isScanning)
Definition: BluetoothEvents.h:361
ToggleA2DPProfileStateChangedEvent(bool a2dpEnable)
Definition: BluetoothEvents.h:380
BluetoothEventType getType() const
Definition: BluetoothEvents.h:189
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::size_t operator()(T t) const
Definition: BluetoothEvents.h:60
A2DPRole
An Enum representing the current A2DP role.
Definition: A2DPRole.h:25
DeviceState
Definition: BluetoothDeviceInterface.h:48
MediaCommandReceivedEvent(avsCommon::sdkInterfaces::bluetooth::services::MediaCommand command)
Definition: BluetoothEvents.h:330
type
Definition: upload.py:443
DeviceStateChangedEvent(std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > device, avsCommon::sdkInterfaces::bluetooth::DeviceState newState)
Definition: BluetoothEvents.h:287
MediaStreamingState getMediaStreamingState() const
Definition: BluetoothEvents.h:202
std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > getDevice() const
Definition: BluetoothEvents.h:193
BluetoothEvent(BluetoothEventType type, std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > device=nullptr, avsCommon::sdkInterfaces::bluetooth::DeviceState deviceState=avsCommon::sdkInterfaces::bluetooth::DeviceState::IDLE, MediaStreamingState mediaStreamingState=MediaStreamingState::IDLE, std::shared_ptr< A2DPRole > role=nullptr, std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::services::MediaCommand > mediaCommand=nullptr, bool scanningState=false, bool a2dpEnable=false)
Definition: BluetoothEvents.h:170
Base class for a BluetoothEvent.
Definition: BluetoothEvents.h:66

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0