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.
When does the BluetoothGattCallback and onConnectionStateChange been called in Android for BLE?
-
07-07-2023 - |
문제
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??
해결책
제휴하지 않습니다 StackOverflow