Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h

Issue 2094633003: Bluetooth: Mac: implementation for start notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write_read_characteristicscan_servicescan_cleanup
Patch Set: Tests working Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_CHARACTERISTIC_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_
7 7
8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/weak_ptr.h"
11 12
12 #if defined(__OBJC__) 13 #if defined(__OBJC__)
13 #import <CoreBluetooth/CoreBluetooth.h> 14 #import <CoreBluetooth/CoreBluetooth.h>
14 #else 15 #else
15 @class CBCharacteristic; 16 @class CBCharacteristic;
16 typedef NS_ENUM(NSInteger, CBCharacteristicWriteType); 17 typedef NS_ENUM(NSInteger, CBCharacteristicWriteType);
17 #endif // defined(__OBJC__) 18 #endif // defined(__OBJC__)
18 19
19 namespace device { 20 namespace device {
20 21
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicMac); 55 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicMac);
55 56
56 private: 57 private:
57 friend class BluetoothRemoteGattServiceMac; 58 friend class BluetoothRemoteGattServiceMac;
58 friend class BluetoothTestMac; 59 friend class BluetoothTestMac;
59 60
60 // Called by the BluetoothRemoteGattServiceMac instance when the 61 // Called by the BluetoothRemoteGattServiceMac instance when the
61 // characteristics value has been read. 62 // characteristics value has been read.
62 void DidUpdateValue(NSError* error); 63 void DidUpdateValue(NSError* error);
64 // Updates the |value_| and send notify the mac adapter for the new value
ortuno 2016/06/28 16:24:50 nit: Usually the "|" are used when referring to a
jlebel 2016/06/28 18:09:52 Done.
65 void UpdateValueAndNotify();
63 // Called by the BluetoothRemoteGattServiceMac instance when the 66 // Called by the BluetoothRemoteGattServiceMac instance when the
64 // characteristics value has been written. 67 // characteristics value has been written.
65 void DidWriteValue(NSError* error); 68 void DidWriteValue(NSError* error);
69 // Called by the BluetoothRemoteGattServiceMac instance when the notify
70 // session has been started or failed.
71 void DidUpdateNotificationState(NSError* error);
66 // Returns true if the characteristic is readable. 72 // Returns true if the characteristic is readable.
67 bool IsReadable() const; 73 bool IsReadable() const;
68 // Returns true if the characteristic is writable. 74 // Returns true if the characteristic is writable.
69 bool IsWritable() const; 75 bool IsWritable() const;
76 // Returns true if the characteristic is notifiable or indicatable.
ortuno 2016/06/28 16:24:49 nit: ... if the characteristic supports notificati
jlebel 2016/06/28 18:09:52 Done.
77 bool IsNotifiableOrIndicatable() const;
ortuno 2016/06/28 16:24:49 nit: SupportsNotificationsOrIndications.
jlebel 2016/06/28 18:09:52 Done.
70 // Returns the write type (with or without responses). 78 // Returns the write type (with or without responses).
71 CBCharacteristicWriteType GetCBWriteType() const; 79 CBCharacteristicWriteType GetCBWriteType() const;
72 // Returns CoreBluetooth characteristic. 80 // Returns CoreBluetooth characteristic.
73 CBCharacteristic* GetCBCharacteristic() const; 81 CBCharacteristic* GetCBCharacteristic() const;
74 82
75 // gatt_service_ owns instances of this class. 83 // gatt_service_ owns instances of this class.
76 BluetoothRemoteGattServiceMac* gatt_service_; 84 BluetoothRemoteGattServiceMac* gatt_service_;
77 // A characteristic from CBPeripheral.services.characteristics. 85 // A characteristic from CBPeripheral.services.characteristics.
78 base::scoped_nsobject<CBCharacteristic> cb_characteristic_; 86 base::scoped_nsobject<CBCharacteristic> cb_characteristic_;
79 // Characteristic identifier. 87 // Characteristic identifier.
80 std::string identifier_; 88 std::string identifier_;
81 // Service UUID. 89 // Service UUID.
82 BluetoothUUID uuid_; 90 BluetoothUUID uuid_;
83 // Characteristic value. 91 // Characteristic value.
84 std::vector<uint8_t> value_; 92 std::vector<uint8_t> value_;
85 // True if a gatt read or write request is in progress. 93 // True if a gatt read or write request is in progress.
86 bool characteristic_value_read_or_write_in_progress_; 94 bool characteristic_value_read_or_write_in_progress_;
87 // ReadRemoteCharacteristic request callbacks. 95 // ReadRemoteCharacteristic request callbacks.
88 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; 96 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_;
89 // WriteRemoteCharacteristic request callbacks. 97 // WriteRemoteCharacteristic request callbacks.
90 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_; 98 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_;
99 // Vector stores StartNotifySession request callbacks.
ortuno 2016/06/28 16:24:49 nit: Remove "Vector". The type is easy to see alre
jlebel 2016/06/28 18:09:52 Done.
100 std::vector<std::pair<NotifySessionCallback, ErrorCallback>>
ortuno 2016/06/28 16:24:49 nit optional: make the pair a typedef like https:/
jlebel 2016/06/28 18:09:52 Done.
101 start_notify_session_callbacks_;
102 // Flag indicates if GATT event registration is in progress.
103 bool gatt_event_registeration_in_progress_;
ortuno 2016/06/28 16:24:49 nit: change this to start_notifications_in_progres
jlebel 2016/06/28 18:09:52 Done.
104 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicMac> weak_ptr_factory_;
91 }; 105 };
92 106
93 } // namespace device 107 } // namespace device
94 108
95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ 109 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698