android.bluetooth.BluetoothGattServerCallback Java Examples
The following examples show how to use
android.bluetooth.BluetoothGattServerCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BLEServicePeripheral.java From unity-bluetooth with MIT License | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void start(String uuidString) { mServiceUUID = UUID.fromString(uuidString); if (mBtAdvertiser == null) { return; } BluetoothGattService btGattService = new BluetoothGattService(mServiceUUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); btGattService.addCharacteristic(mBtGattCharacteristic); BluetoothGattServerCallback btGattServerCallback = createGattServerCallback(mServiceUUID, UUID.fromString(CHARACTERISTIC_UUID)); mBtGattServer = mBtManager.openGattServer(mActivity.getApplicationContext(), btGattServerCallback); mBtGattServer.addService(btGattService); mDataBuilder = new AdvertiseData.Builder(); mDataBuilder.setIncludeTxPowerLevel(false); mDataBuilder.addServiceUuid(new ParcelUuid(mServiceUUID)); mSettingsBuilder=new AdvertiseSettings.Builder(); mSettingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED); mSettingsBuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH); mBleAdvertiser = mBtAdapter.getBluetoothLeAdvertiser(); mBleAdvertiser.startAdvertising(mSettingsBuilder.build(), mDataBuilder.build(), mAdvertiseCallback); }