OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | |
11 | |
10 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
11 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 15 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
14 | 16 |
15 namespace device { | 17 namespace device { |
16 | 18 |
17 class BluetoothAdapterAndroid; | 19 class BluetoothAdapterAndroid; |
18 class BluetoothRemoteGattDescriptorAndroid; | 20 class BluetoothRemoteGattDescriptorAndroid; |
19 class BluetoothRemoteGattServiceAndroid; | 21 class BluetoothRemoteGattServiceAndroid; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 const ErrorCallback& error_callback) override; | 73 const ErrorCallback& error_callback) override; |
72 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, | 74 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, |
73 const base::Closure& callback, | 75 const base::Closure& callback, |
74 const ErrorCallback& error_callback) override; | 76 const ErrorCallback& error_callback) override; |
75 | 77 |
76 // Called when value changed event occurs. | 78 // Called when value changed event occurs. |
77 void OnChanged(JNIEnv* env, | 79 void OnChanged(JNIEnv* env, |
78 const base::android::JavaParamRef<jobject>& jcaller, | 80 const base::android::JavaParamRef<jobject>& jcaller, |
79 const base::android::JavaParamRef<jbyteArray>& value); | 81 const base::android::JavaParamRef<jbyteArray>& value); |
80 | 82 |
83 // Callback after StartNotifySession operation completes. | |
scheib
2016/02/26 04:27:01
Called when StartNotifySession operation completes
tommyt
2016/03/01 14:45:15
Done.
| |
84 void OnStartNotifySession(JNIEnv* env, | |
85 const base::android::JavaParamRef<jobject>& jcaller, | |
86 int32_t status); | |
87 | |
81 // Callback after Read operation completes. | 88 // Callback after Read operation completes. |
82 void OnRead(JNIEnv* env, | 89 void OnRead(JNIEnv* env, |
83 const base::android::JavaParamRef<jobject>& jcaller, | 90 const base::android::JavaParamRef<jobject>& jcaller, |
84 int32_t status, | 91 int32_t status, |
85 const base::android::JavaParamRef<jbyteArray>& value); | 92 const base::android::JavaParamRef<jbyteArray>& value); |
86 | 93 |
87 // Callback after Write operation completes. | 94 // Callback after Write operation completes. |
88 void OnWrite(JNIEnv* env, | 95 void OnWrite(JNIEnv* env, |
89 const base::android::JavaParamRef<jobject>& jcaller, | 96 const base::android::JavaParamRef<jobject>& jcaller, |
90 int32_t status); | 97 int32_t status); |
(...skipping 25 matching lines...) Expand all Loading... | |
116 BluetoothAdapterAndroid* adapter_; | 123 BluetoothAdapterAndroid* adapter_; |
117 BluetoothRemoteGattServiceAndroid* service_; | 124 BluetoothRemoteGattServiceAndroid* service_; |
118 | 125 |
119 // Java object | 126 // Java object |
120 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. | 127 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. |
121 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; | 128 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; |
122 | 129 |
123 // Adapter unique instance ID. | 130 // Adapter unique instance ID. |
124 std::string instance_id_; | 131 std::string instance_id_; |
125 | 132 |
133 // StartNotifySession callbacks and pending state. | |
134 typedef std::pair<NotifySessionCallback, ErrorCallback> | |
135 PendingStartNotifyCall; | |
136 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; | |
137 | |
126 // ReadRemoteCharacteristic callbacks and pending state. | 138 // ReadRemoteCharacteristic callbacks and pending state. |
127 bool read_pending_ = false; | 139 bool read_pending_ = false; |
128 ValueCallback read_callback_; | 140 ValueCallback read_callback_; |
129 ErrorCallback read_error_callback_; | 141 ErrorCallback read_error_callback_; |
130 | 142 |
131 // WriteRemoteCharacteristic callbacks and pending state. | 143 // WriteRemoteCharacteristic callbacks and pending state. |
132 bool write_pending_ = false; | 144 bool write_pending_ = false; |
133 base::Closure write_callback_; | 145 base::Closure write_callback_; |
134 ErrorCallback write_error_callback_; | 146 ErrorCallback write_error_callback_; |
135 | 147 |
136 std::vector<uint8_t> value_; | 148 std::vector<uint8_t> value_; |
137 | 149 |
138 // Map of descriptors, keyed by descriptor identifier. | 150 // Map of descriptors, keyed by descriptor identifier. |
139 base::ScopedPtrHashMap<std::string, | 151 base::ScopedPtrHashMap<std::string, |
140 scoped_ptr<BluetoothRemoteGattDescriptorAndroid>> | 152 scoped_ptr<BluetoothRemoteGattDescriptorAndroid>> |
141 descriptors_; | 153 descriptors_; |
142 | 154 |
143 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); | 155 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); |
144 }; | 156 }; |
145 | 157 |
146 } // namespace device | 158 } // namespace device |
147 | 159 |
148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ | 160 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ |
OLD | NEW |