OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
14 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 14 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
15 | 15 |
16 @class CBCharacteristic; | 16 @class CBCharacteristic; |
17 @class CBPeripheral; | 17 @class CBPeripheral; |
18 @class CBService; | 18 @class CBService; |
19 | 19 |
20 namespace device { | 20 namespace device { |
21 | 21 |
22 class BluetoothAdapterMac; | 22 class BluetoothAdapterMac; |
23 class BluetoothDevice; | 23 class BluetoothDevice; |
24 class BluetoothRemoteGattCharacteristicMac; | 24 class BluetoothRemoteGattCharacteristicMac; |
25 class BluetoothLowEnergyDeviceMac; | 25 class BluetoothLowEnergyDeviceMac; |
26 class BluetoothTestMac; | |
27 | 26 |
28 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac | 27 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceMac |
29 : public BluetoothRemoteGattService { | 28 : public BluetoothRemoteGattService { |
30 public: | 29 public: |
31 BluetoothRemoteGattServiceMac( | 30 BluetoothRemoteGattServiceMac( |
32 BluetoothLowEnergyDeviceMac* bluetooth_device_mac, | 31 BluetoothLowEnergyDeviceMac* bluetooth_device_mac, |
33 CBService* service, | 32 CBService* service, |
34 bool is_primary); | 33 bool is_primary); |
35 ~BluetoothRemoteGattServiceMac() override; | 34 ~BluetoothRemoteGattServiceMac() override; |
36 | 35 |
37 // BluetoothRemoteGattService override. | 36 // BluetoothRemoteGattService override. |
38 std::string GetIdentifier() const override; | 37 std::string GetIdentifier() const override; |
39 BluetoothUUID GetUUID() const override; | 38 BluetoothUUID GetUUID() const override; |
40 bool IsPrimary() const override; | 39 bool IsPrimary() const override; |
41 BluetoothDevice* GetDevice() const override; | 40 BluetoothDevice* GetDevice() const override; |
42 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics() | 41 std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics() |
43 const override; | 42 const override; |
44 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; | 43 std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; |
45 BluetoothRemoteGattCharacteristic* GetCharacteristic( | 44 BluetoothRemoteGattCharacteristic* GetCharacteristic( |
46 const std::string& identifier) const override; | 45 const std::string& identifier) const override; |
47 | 46 |
48 private: | 47 private: |
49 friend BluetoothLowEnergyDeviceMac; | 48 friend class BluetoothLowEnergyDeviceMac; |
50 friend BluetoothTestMac; | 49 friend class BluetoothRemoteGattCharacteristicMac; |
| 50 friend class BluetoothTestMac; |
51 | 51 |
52 // Starts discovering characteristics by calling CoreBluetooth. | 52 // Starts discovering characteristics by calling CoreBluetooth. |
53 void DiscoverCharacteristics(); | 53 void DiscoverCharacteristics(); |
54 // Called by the BluetoothLowEnergyDeviceMac instance when the characteristics | 54 // Called by the BluetoothLowEnergyDeviceMac instance when the characteristics |
55 // has been discovered. | 55 // has been discovered. |
56 void DidDiscoverCharacteristics(); | 56 void DidDiscoverCharacteristics(); |
| 57 // Called by the BluetoothRemoteGattServiceMac instance when the |
| 58 // characteristics value has been read. |
| 59 void DidUpdateValue(CBCharacteristic* characteristic, NSError* error); |
57 // Returns true if the characteristics has been discovered. | 60 // Returns true if the characteristics has been discovered. |
58 bool IsDiscoveryComplete(); | 61 bool IsDiscoveryComplete(); |
59 | 62 |
60 // Returns the mac adapter. | 63 // Returns the mac adapter. |
61 BluetoothAdapterMac* GetMacAdapter() const; | 64 BluetoothAdapterMac* GetMacAdapter() const; |
62 // Returns CBPeripheral. | 65 // Returns CBPeripheral. |
63 CBPeripheral* GetCBPeripheral() const; | 66 CBPeripheral* GetCBPeripheral() const; |
64 // Returns CBService. | 67 // Returns CBService. |
65 CBService* GetService() const; | 68 CBService* GetService() const; |
66 // Returns a remote characteristic based on the CBCharacteristic. | 69 // Returns a remote characteristic based on the CBCharacteristic. |
(...skipping 15 matching lines...) Expand all Loading... |
82 BluetoothUUID uuid_; | 85 BluetoothUUID uuid_; |
83 // Is true if the characteristics has been discovered. | 86 // Is true if the characteristics has been discovered. |
84 bool is_discovery_complete_; | 87 bool is_discovery_complete_; |
85 | 88 |
86 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac); | 89 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceMac); |
87 }; | 90 }; |
88 | 91 |
89 } // namespace device | 92 } // namespace device |
90 | 93 |
91 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ | 94 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_MAC_H_ |
OLD | NEW |