Epson BT-2000 Developers Guide - Page 158
Acquiring Characteristic Value by Specifying a Handle
View all Epson BT-2000 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 158 highlights
8.8.8. Acquiring Characteristic Value by Specifying a Handle You can acquire the Characteristic Value on a connected BLE device by executing the callback function setGattCallback() and Characteristic Value acquisition using readGatt(). import android.bluetooth.BluetoothLeAdapterManager; import android.bluetooth.BluetoothLeGapEvtConnected; import android.bluetooth.BluetoothLeGattCallback; public class MainActivity extends Activity { private BluetoothLeAdapterManager mManager; @Override protected void onCreate(Bundle savedInstanceState) { //Instance acquisition for the BLE manager class mManager = BluetoothLeAdapterManager.getInstance(); //Register a callback for the GATT function provided mManager.setGattCallback(mLeGattCallback); //Acquire (READ) Characteristic Value //Set the handle HandleValue in Characteristic Value from the Characteristic //information acquired in onDiscCharResult() mManager.readGatt(ConnectedHandle, HandleValue) } Use the following callback to output logs when a Characteristic Value is acquired. private BluetoothLeGattCallback mLeGattCallback = new BluetoothLeGattCallback() { }; } @Override public void onReadGattResult ( char status, BluetoothLeGattEvtReadRsp data) { Log.i("DEBUG", "Characteristic Value=" + data.data); } MOVERIO Pro Developer's Guide (Rev.1.0) 154