Reputation: 6381
I am study about Bluetooth Low Energy (BLE, Bluetooth 4.0) for Android.
I have reference the document like the link: Bluetooth Low Energy.
It use connectGatt()
method for connecting to the GATT server on the device-A
like the following.
mBluetoothGatt = device_A.connectGatt(this, false, mGattCallback);
And it has onConnectionStateChange
, onCharacteristicRead
,etc in the mGattCallback
.
The question is:
1. When does the BluetoothGattCallback
has be called ?
2. Is the onConnectionStateChange
in the mBluetoothGatt
will return the message when the device-A
has any change for all characteristic on the device-A
?? , or it only return the characteristic which the characteristic I have connect??
Upvotes: 1
Views: 3487
Reputation: 5418
First of all after connection (you are connectiong as gatt-client to device as gatt-server) you should call Discovery device's services. After that device can send you onCharacteristicChanged
in case of some changes happened.
But there is a case when BLE device could be as gatt-client and should send writeCharacteristic
to your BluetoothGattServer
. In that case you should create gatt-server and receive calls.
Upvotes: 1