MOVERIO Pro Developer's Guide (Rev.1.4)
172
8.9.5.
Searching for Primary Service
You can search for the Primary Service on a connected BLE device by executing the callback
function setGattCallback() and Primary Service search using discPriSrv().
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);
//Searching for Primary Service
//Set the connection handle ConnectedHandle in connected event status
connStatus acquired in onConnectResult
mManager.discPriSrv(ConnectedHandle, (char) 1);
}
Use the following callback to output logs when a Primary Service is detected.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onDiscPriSrvResult(char connectedHandle,
int status, BluetoothLeGattService[] data) {
for (int cnt=0; cnt<data.length; cnt++) {
Log.i(“DEBUG”, “startHandle=” +
data[cnt].start “ endHandle=” +
data[cnt].endHandle);
}
};
};
}
Содержание Moverio Pro BT-2000
Страница 7: ...MOVERIO Pro Developer s Guide Rev 1 4 1 1 Introduction ...
Страница 12: ...MOVERIO Pro Developer s Guide Rev 1 4 6 2 Developing Apps ...
Страница 30: ...MOVERIO Pro Developer s Guide Rev 1 4 24 3 Display control ...
Страница 39: ...MOVERIO Pro Developer s Guide Rev 1 4 33 4 UI control ...
Страница 47: ...MOVERIO Pro Developer s Guide Rev 1 4 41 5 Voice commands ...
Страница 70: ...MOVERIO Pro Developer s Guide Rev 1 4 64 6 Camera control ...
Страница 119: ...MOVERIO Pro Developer s Guide Rev 1 4 113 7 Sensor control ...
Страница 127: ...MOVERIO Pro Developer s Guide Rev 1 4 121 8 Bluetooth BLE ...
Страница 184: ...MOVERIO Pro Developer s Guide Rev 1 4 178 9 Power control ...
Страница 187: ...MOVERIO Pro Developer s Guide Rev 1 4 181 10 Self diagnostic function ...
Страница 191: ...MOVERIO Pro Developer s Guide Rev 1 4 185 11 GPS Assist ...
Страница 202: ...MOVERIO Pro Developer s Guide Rev 1 4 196 Memo ...