Epson BT-2000 Developers Guide - Page 153
Connecting and Disconnecting BLE
![]() |
View all Epson BT-2000 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 153 highlights
8.8.4. Connecting and Disconnecting BLE The following provides an example of the processing for connecting and disconnecting BLE. Connecting: Enable GAP callback registration and scanning before connecting.Connect using information in (addrType, addr) in the scan results (onScanResult()). Disconnecting: Disconnect using the connection handle (connStatus.connectedHandle) in the connection results (onConnectResult()). import android.bluetooth.BluetoothLeAdapterManager; import android.bluetooth.BluetoothLeGapEvtConnected; import android.bluetooth.BluetoothLeGattCallback; public class MainActivity extends Activity { private BluetoothLeAdapterManager mManager; private boolean mConnectingFlg = false; @Override protected void onCreate(Bundle savedInstanceState) { //Instance acquisition for the BLE manager class mManager = BluetoothLeAdapterManager.getInstance(); //Register a callback for the GAP function provided mManager.setGapCallback (mLeGapCallback); } private void connectLe(final boolean enable) { if ( enable ) { //BLE connect //Set the addrType and addr acquired in onScanResult mManager.connect(addrType, addr, 1000, 0); } else { //BLE disconnect //Set the connection handle ConnectedHandle in connected event status connStatus acquired in onConnectResult mManager.disconnect(ConnectedHandle, REMOTE_USER_TERMINATED_CONNECTION); } } MOVERIO Pro Developer's Guide (Rev.1.0) 149
![](/manual_guide/products/epson-bt2000-developers-guide-3a30282/153.png)