AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
BluetoothDeviceInterface.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_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_
18 
19 #include <future>
20 #include <memory>
21 #include <ostream>
22 #include <string>
23 #include <vector>
24 
29 
30 namespace alexaClientSDK {
31 namespace avsCommon {
32 namespace sdkInterfaces {
33 namespace bluetooth {
34 
48 enum class DeviceState {
49  // A device has been discovered.
50  FOUND,
51  // [Transitional] The device has been unpaired.
52  UNPAIRED,
53  // [Transitional] The device has successfully paired.
54  PAIRED,
55  // A paired device.
56  IDLE,
57  // [Transitional] A device has successfully disconnected.
59  // A device that has successfully connected.
60  CONNECTED
61 };
62 
70  switch (state) {
71  case DeviceState::FOUND:
72  return "FOUND";
74  return "UNPAIRED";
76  return "PAIRED";
77  case DeviceState::IDLE:
78  return "IDLE";
80  return "DISCONNECTED";
82  return "CONNECTED";
83  }
84 
85  return "UNKNOWN";
86 }
87 
95 inline std::ostream& operator<<(std::ostream& stream, const DeviceState state) {
96  return stream << deviceStateToString(state);
97 }
98 
101 public:
105  struct MetaData {
107  static const int UNDEFINED_CLASS_VALUE = 0;
108 
114 
124  utils::Optional<int> vendorId,
125  utils::Optional<int> productId,
126  int classOfDevice,
127  utils::Optional<int> vendorDeviceSigId,
128  utils::Optional<std::string> vendorDeviceId) :
129  vendorId(vendorId),
130  productId(productId),
131  classOfDevice(classOfDevice),
132  vendorDeviceSigId(vendorDeviceSigId),
133  vendorDeviceId(vendorDeviceId) {
134  }
135  };
136 
138  virtual ~BluetoothDeviceInterface() = default;
139 
145  virtual std::string getMac() const = 0;
146 
152  virtual std::string getFriendlyName() const = 0;
153 
159  virtual DeviceState getDeviceState() = 0;
160 
166  virtual MetaData getDeviceMetaData() = 0;
167 
174  virtual bool isPaired() = 0;
175 
181  virtual std::future<bool> pair() = 0;
182 
188  virtual std::future<bool> unpair() = 0;
189 
196  virtual bool isConnected() = 0;
197 
203  virtual std::future<bool> connect() = 0;
204 
210  virtual std::future<bool> disconnect() = 0;
211 
221  virtual bool setPairingPin(const std::string& pin) = 0;
222 
224  virtual std::vector<std::shared_ptr<services::SDPRecordInterface>> getSupportedServices() = 0;
225 
232  virtual std::shared_ptr<services::BluetoothServiceInterface> getService(std::string uuid) = 0;
233 
235  virtual utils::bluetooth::MediaStreamingState getStreamingState() = 0;
236 
244  virtual bool toggleServiceConnection(
245  bool enabled,
246  std::shared_ptr<services::BluetoothServiceInterface> service) = 0;
247 };
248 
249 } // namespace bluetooth
250 } // namespace sdkInterfaces
251 } // namespace avsCommon
252 } // namespace alexaClientSDK
253 
254 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_
std::ostream & operator<<(std::ostream &stream, const DeviceState state)
Definition: BluetoothDeviceInterface.h:95
::std::string string
Definition: gtest-port.h:1097
MediaStreamingState
An Enum representing the current state of the stream.
Definition: MediaStreamingState.h:25
MetaData(utils::Optional< int > vendorId, utils::Optional< int > productId, int classOfDevice, utils::Optional< int > vendorDeviceSigId, utils::Optional< std::string > vendorDeviceId)
Definition: BluetoothDeviceInterface.h:123
Represents a Bluetooth Device.
Definition: BluetoothDeviceInterface.h:100
utils::Optional< int > vendorId
Definition: BluetoothDeviceInterface.h:109
utils::Optional< int > vendorDeviceSigId
Definition: BluetoothDeviceInterface.h:112
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
DeviceState
Definition: BluetoothDeviceInterface.h:48
utils::Optional< int > productId
Definition: BluetoothDeviceInterface.h:110
utils::Optional< std::string > vendorDeviceId
Definition: BluetoothDeviceInterface.h:113
std::string deviceStateToString(DeviceState state)
Definition: BluetoothDeviceInterface.h:69

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