android.bluetooth.BluetoothGattService Java Examples
The following examples show how to use
android.bluetooth.BluetoothGattService.
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 Project: blefun-androidthings Author: Nilhcem File: GattClient.java License: Apache License 2.0 | 8 votes |
@Override public void onServicesDiscovered(BluetoothGatt gatt, int status) { if (status == BluetoothGatt.GATT_SUCCESS) { boolean connected = false; BluetoothGattService service = gatt.getService(SERVICE_UUID); if (service != null) { BluetoothGattCharacteristic characteristic = service.getCharacteristic(CHARACTERISTIC_COUNTER_UUID); if (characteristic != null) { gatt.setCharacteristicNotification(characteristic, true); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(DESCRIPTOR_CONFIG); if (descriptor != null) { descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); connected = gatt.writeDescriptor(descriptor); } } } mListener.onConnected(connected); } else { Log.w(TAG, "onServicesDiscovered received: " + status); } }
Example #2
Source Project: blessed-android Author: weliem File: BluetoothPeripheral.java License: MIT License | 6 votes |
@Override public void onServicesDiscovered(BluetoothGatt gatt, int status) { if (status != GATT_SUCCESS) { Timber.e("service discovery failed due to internal error '%s', disconnecting", statusToString(status)); disconnect(); return; } final List<BluetoothGattService> services = gatt.getServices(); Timber.i("discovered %d services for '%s'", services.size(), getName()); if (listener != null) { listener.connected(BluetoothPeripheral.this); } callbackHandler.post(new Runnable() { @Override public void run() { peripheralCallback.onServicesDiscovered(BluetoothPeripheral.this); } }); }
Example #3
Source Project: react-native-ble-manager Author: innoveit File: Peripheral.java License: Apache License 2.0 | 6 votes |
public void read(UUID serviceUUID, UUID characteristicUUID, Callback callback) { if (!isConnected()) { callback.invoke("Device is not connected", null); return; } if (gatt == null) { callback.invoke("BluetoothGatt is null", null); return; } BluetoothGattService service = gatt.getService(serviceUUID); BluetoothGattCharacteristic characteristic = findReadableCharacteristic(service, characteristicUUID); if (characteristic == null) { callback.invoke("Characteristic " + characteristicUUID + " not found.", null); } else { readCallback = callback; if (!gatt.readCharacteristic(characteristic)) { readCallback = null; callback.invoke("Read failed", null); } } }
Example #4
Source Project: BLEService Author: RatioLabs File: BTLEDeviceManager.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean writeDescriptor(String address, UUID serviceUUID, UUID characteristicUUID, UUID descriptorUUID, byte[] value) throws DeviceManagerException, DeviceNameNotFoundException { BTDeviceInfo deviceInfo = getDeviceInfo(address); if (deviceInfo == null) { throw new DeviceNameNotFoundException(String.format("%s %s", mContext.getString(R.string.device_not_found), address)); } BluetoothGattService service = deviceInfo.getGatt().getService(serviceUUID); if (service == null) { throw new DeviceManagerException(String.format("%s %s %s", mContext.getString(R.string.service_not_found), address, serviceUUID)); } BluetoothGattCharacteristic characteristic = service.getCharacteristic(characteristicUUID); if (characteristic == null) { throw new DeviceManagerException(String.format("%s %s %s", mContext.getString(R.string.characteristic_not_found), address, characteristicUUID)); } BluetoothGattDescriptor descriptor = characteristic.getDescriptor(descriptorUUID); if (descriptor == null) { throw new DeviceManagerException(String.format("%s %s %s %s", mContext.getString(R.string.descriptor_not_found), address, characteristicUUID, descriptorUUID)); } return writeDescriptor(deviceInfo, characteristic, descriptor, value); }
Example #5
Source Project: bean-sdk-android Author: PunchThrough File: OADProfile.java License: MIT License | 6 votes |
/** * Setup BLOCK and IDENTIFY characteristics */ private void setupOAD() { BluetoothGattService oadService = mGattClient.getService(Constants.UUID_OAD_SERVICE); if (oadService == null) { fail(BeanError.MISSING_OAD_SERVICE); return; } oadIdentify = oadService.getCharacteristic(Constants.UUID_OAD_CHAR_IDENTIFY); if (oadIdentify == null) { fail(BeanError.MISSING_OAD_IDENTIFY); return; } oadBlock = oadService.getCharacteristic(Constants.UUID_OAD_CHAR_BLOCK); if (oadBlock == null) { fail(BeanError.MISSING_OAD_BLOCK); return; } }
Example #6
Source Project: bitgatt Author: Fitbit File: GattConnection.java License: Mozilla Public License 2.0 | 6 votes |
boolean connectedDeviceHostsService(UUID serviceUuid) { if (mockMode) { for (BluetoothGattService service : mockServices) { if (service.getUuid() != null && service.getUuid().equals(serviceUuid)) { return true; } } return false; } else { // if the device has not had discovery performed, we will not know that the connection // is hosting the service if (isConnected()) { return null != getGatt() && null != getGatt().getService(serviceUuid); } else { return false; } } }
Example #7
Source Project: Android-nRF-Toolbox Author: NordicSemiconductor File: ProximityServerManager.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@NonNull @Override protected List<BluetoothGattService> initializeServer() { final List<BluetoothGattService> services = new ArrayList<>(); services.add( service(ProximityManager.IMMEDIATE_ALERT_SERVICE_UUID, characteristic(ProximityManager.ALERT_LEVEL_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, BluetoothGattCharacteristic.PERMISSION_WRITE)) ); services.add( service(ProximityManager.LINK_LOSS_SERVICE_UUID, characteristic(ProximityManager.ALERT_LEVEL_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ, AlertLevelData.highAlert())) ); return services; }
Example #8
Source Project: Android-nRF-Mesh-Library Author: NordicSemiconductor File: BleMeshManager.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean isRequiredServiceSupported(@NonNull final BluetoothGatt gatt) { final BluetoothGattService meshProxyService = gatt.getService(MESH_PROXY_UUID); if (meshProxyService != null) { isProvisioningComplete = true; mMeshProxyDataInCharacteristic = meshProxyService.getCharacteristic(MESH_PROXY_DATA_IN); mMeshProxyDataOutCharacteristic = meshProxyService.getCharacteristic(MESH_PROXY_DATA_OUT); return mMeshProxyDataInCharacteristic != null && mMeshProxyDataOutCharacteristic != null && hasNotifyProperty(mMeshProxyDataOutCharacteristic) && hasWriteNoResponseProperty(mMeshProxyDataInCharacteristic); } final BluetoothGattService meshProvisioningService = gatt.getService(MESH_PROVISIONING_UUID); if (meshProvisioningService != null) { isProvisioningComplete = false; mMeshProvisioningDataInCharacteristic = meshProvisioningService.getCharacteristic(MESH_PROVISIONING_DATA_IN); mMeshProvisioningDataOutCharacteristic = meshProvisioningService.getCharacteristic(MESH_PROVISIONING_DATA_OUT); return mMeshProvisioningDataInCharacteristic != null && mMeshProvisioningDataOutCharacteristic != null && hasNotifyProperty(mMeshProvisioningDataOutCharacteristic) && hasWriteNoResponseProperty(mMeshProvisioningDataInCharacteristic); } return false; }
Example #9
Source Project: AsteroidOSSync Author: AsteroidOS File: BleManager.java License: GNU General Public License v3.0 | 6 votes |
/** * Returns a {@link BleServer} instance. This is now the preferred method to retrieve the server instance. */ public final BleServer getServer(final IncomingListener incomingListener, final GattDatabase gattDatabase, final BleServer.ServiceAddListener addServiceListener) { if (m_server == null) { m_server = new BleServer(this, /*isNull*/false); if (gattDatabase != null) { for (BluetoothGattService service : gattDatabase.getServiceList()) { m_server.addService(service, addServiceListener); } } } m_server.setListener_Incoming(incomingListener); return m_server; }
Example #10
Source Project: SweetBlue Author: iDevicesInc File: PA_ServiceManager.java License: GNU General Public License v3.0 | 6 votes |
public BleDescriptorWrapper getDescriptor(final UUID serviceUuid_nullable, final UUID charUuid_nullable, final UUID descUuid) { if (serviceUuid_nullable == null) { final List<BluetoothGattService> serviceList = getNativeServiceList_original(); for (int i = 0; i < serviceList.size(); i++) { final BleServiceWrapper service_ith = new BleServiceWrapper(serviceList.get(i)); final BleDescriptorWrapper descriptor = getDescriptor(service_ith, charUuid_nullable, descUuid); return descriptor; } } else { final BleServiceWrapper service = getServiceDirectlyFromNativeNode(serviceUuid_nullable); if (service.hasUhOh()) return new BleDescriptorWrapper(service.getUhOh()); else return getDescriptor(service, charUuid_nullable, descUuid); } return BleDescriptorWrapper.NULL; }
Example #11
Source Project: BLEService Author: RatioLabs File: PeripheralActivity.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public void uiCharacteristicsDetails(final BluetoothGatt gatt, final BluetoothDevice device, final BluetoothGattService service, final BluetoothGattCharacteristic characteristic) { runOnUiThread(new Runnable() { @Override public void run() { mListType = ListType.GATT_CHARACTERISTIC_DETAILS; mListView.setAdapter(mCharDetailsAdapter); mHeaderTitle.setText(BleNamesResolver.resolveCharacteristicName(characteristic.getUuid().toString().toLowerCase(Locale.getDefault())) + "\'s details:"); mHeaderBackButton.setVisibility(View.VISIBLE); mCharDetailsAdapter.setCharacteristic(characteristic); mCharDetailsAdapter.notifyDataSetChanged(); } }); }
Example #12
Source Project: BleLib Author: junkchen File: BleService.java License: Apache License 2.0 | 6 votes |
/** * Reads the value for a given descriptor from the associated remote device. * * @param serviceUUID remote device service uuid * @param characteristicUUID remote device characteristic uuid * @param descriptorUUID remote device descriptor uuid * @return true, if the read operation was initiated successfully */ public boolean readDescriptor(String serviceUUID, String characteristicUUID, String descriptorUUID) { if (mBluetoothGatt == null) { Log.w(TAG, "BluetoothGatt is null"); return false; } // try { BluetoothGattService service = mBluetoothGatt.getService(UUID.fromString(serviceUUID)); BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID)); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(descriptorUUID)); return mBluetoothGatt.readDescriptor(descriptor); // } catch (Exception e) { // Log.e(TAG, "read descriptor exception", e); // return false; // } }
Example #13
Source Project: Android-nRF-Toolbox Author: NordicSemiconductor File: BleManager.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * When the device is bonded and has the Generic Attribute service and the Service Changed characteristic this method enables indications on this characteristic. * In case one of the requirements is not fulfilled this method returns <code>false</code>. * * @return <code>true</code> when the request has been sent, <code>false</code> when the device is not bonded, does not have the Generic Attribute service, the GA service does not have * the Service Changed characteristic or this characteristic does not have the CCCD. */ private boolean ensureServiceChangedEnabled() { final BluetoothGatt gatt = bluetoothGatt; if (gatt == null) return false; // The Service Changed indications have sense only on bonded devices final BluetoothDevice device = gatt.getDevice(); if (device.getBondState() != BluetoothDevice.BOND_BONDED) return false; final BluetoothGattService gaService = gatt.getService(GENERIC_ATTRIBUTE_SERVICE); if (gaService == null) return false; final BluetoothGattCharacteristic scCharacteristic = gaService.getCharacteristic(SERVICE_CHANGED_CHARACTERISTIC); if (scCharacteristic == null) return false; return internalEnableIndications(scCharacteristic); }
Example #14
Source Project: sample-bluetooth-le-gattserver Author: androidthings File: TimeProfile.java License: Apache License 2.0 | 6 votes |
/** * Return a configured {@link BluetoothGattService} instance for the * Current Time Service. */ public static BluetoothGattService createTimeService() { BluetoothGattService service = new BluetoothGattService(TIME_SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY); // Current Time characteristic BluetoothGattCharacteristic currentTime = new BluetoothGattCharacteristic(CURRENT_TIME, //Read-only characteristic, supports notifications BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_READ); BluetoothGattDescriptor configDescriptor = new BluetoothGattDescriptor(CLIENT_CONFIG, //Read/write descriptor BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE); currentTime.addDescriptor(configDescriptor); // Local Time Information characteristic BluetoothGattCharacteristic localTime = new BluetoothGattCharacteristic(LOCAL_TIME_INFO, //Read-only characteristic BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ); service.addCharacteristic(currentTime); service.addCharacteristic(localTime); return service; }
Example #15
Source Project: IoT-Firstep Author: nladuo File: DeviceControlActivity.java License: GNU General Public License v3.0 | 5 votes |
/** * 获取BLE的特征值 * @param gattServices */ private void getCharacteristic(List<BluetoothGattService> gattServices) { if (gattServices == null) return; String uuid = null; // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { uuid = gattService.getUuid().toString(); //找uuid为0000ffe0-0000-1000-8000-00805f9b34fb的服务 if (uuid.equals(C.SERVICE_UUID)) { List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); //找uuid为0000ffe1-0000-1000-8000-00805f9b34fb的特征值 for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { uuid = gattCharacteristic.getUuid().toString(); if(uuid.equals(C.CHAR_UUID)){ mCharacteristic = gattCharacteristic; final int charaProp = gattCharacteristic.getProperties(); //开启该特征值的数据的监听 if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mBluetoothLeService.setCharacteristicNotification( mCharacteristic, true); } System.out.println("uuid----->" + uuid); } } } } //如果没找到指定的特征值,直接返回 if (mCharacteristic == null) { Toast.makeText(DeviceControlActivity.this, "未找到指定特征值", Toast.LENGTH_LONG).show(); finish(); } }
Example #16
Source Project: Bluefruit_LE_Connect_Android Author: adafruit File: BleManager.java License: MIT License | 5 votes |
public void writeService(BluetoothGattService service, String uuid, byte[] value) { if (service != null) { if (mAdapter == null || mGatt == null) { Log.w(TAG, "writeService: BluetoothAdapter not initialized"); return; } mExecutor.write(service, uuid, value); mExecutor.execute(mGatt); } }
Example #17
Source Project: FastBle Author: Jasonchenlijian File: ServiceListFragment.java License: Apache License 2.0 | 5 votes |
private void showData() { BleDevice bleDevice = ((OperationActivity) getActivity()).getBleDevice(); String name = bleDevice.getName(); String mac = bleDevice.getMac(); BluetoothGatt gatt = BleManager.getInstance().getBluetoothGatt(bleDevice); txt_name.setText(String.valueOf(getActivity().getString(R.string.name) + name)); txt_mac.setText(String.valueOf(getActivity().getString(R.string.mac) + mac)); mResultAdapter.clear(); for (BluetoothGattService service : gatt.getServices()) { mResultAdapter.addResult(service); } mResultAdapter.notifyDataSetChanged(); }
Example #18
Source Project: thunderboard-android Author: SiliconLabs File: BleUtils.java License: Apache License 2.0 | 5 votes |
private static List<BluetoothGattCharacteristic> findCharacteristics(BluetoothGatt gatt, UUID serviceUuid, UUID characteristicUuid, int property) { if (serviceUuid == null) { return null; } if (characteristicUuid == null) { return null; } if (gatt == null) { return null; } BluetoothGattService service = gatt.getService(serviceUuid); if (service == null) { return null; } List<BluetoothGattCharacteristic> results = new ArrayList<>(); for (BluetoothGattCharacteristic c : service.getCharacteristics()) { int props = c.getProperties(); if (characteristicUuid.equals(c.getUuid()) && (property == (property & props))) { results.add(c); } } return results; }
Example #19
Source Project: BLE-Heart-rate-variability-demo Author: oerjanti File: BleSensor.java License: MIT License | 5 votes |
private BluetoothGattCharacteristic getCharacteristic(BluetoothGatt bluetoothGatt, String uuid) { final UUID serviceUuid = UUID.fromString(getServiceUUID()); final UUID characteristicUuid = UUID.fromString(uuid); final BluetoothGattService service = bluetoothGatt.getService(serviceUuid); return service.getCharacteristic(characteristicUuid); }
Example #20
Source Project: Bluefruit_LE_Connect_Android_V2 Author: adafruit File: GattServer.java License: MIT License | 5 votes |
@Override public void onServiceAdded(int status, BluetoothGattService service) { super.onServiceAdded(status, service); Log.d(TAG, "GattServer: onServiceAdded"); mAddServicesSemaphore.release(); }
Example #21
Source Project: blessed-android Author: weliem File: BluetoothPeripheralTest.java License: MIT License | 5 votes |
@Test public void writeDescriptor() { BluetoothGattCallback callback = connectAndGetCallback(); callback.onConnectionStateChange(gatt, GATT_SUCCESS, STATE_CONNECTED); BluetoothGattService service = new BluetoothGattService(SERVICE_UUID, 0); BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(UUID.fromString("00002A1C-0000-1000-8000-00805f9b34fb"),PROPERTY_INDICATE,0); BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(UUID.fromString("00002903-0000-1000-8000-00805f9b34fb"),0); service.addCharacteristic(characteristic); characteristic.addDescriptor(descriptor); when(gatt.getServices()).thenReturn(Arrays.asList(service)); byte[] originalByteArray = new byte[]{0x01}; peripheral.writeDescriptor(descriptor, originalByteArray); verify(gatt).writeDescriptor(descriptor); callback.onDescriptorWrite(gatt, descriptor, 0); ArgumentCaptor<BluetoothPeripheral> captorPeripheral = ArgumentCaptor.forClass(BluetoothPeripheral.class); ArgumentCaptor<byte[]> captorValue = ArgumentCaptor.forClass(byte[].class); ArgumentCaptor<BluetoothGattDescriptor> captorDescriptor = ArgumentCaptor.forClass(BluetoothGattDescriptor.class); ArgumentCaptor<Integer> captorStatus = ArgumentCaptor.forClass(Integer.class); verify(peripheralCallback).onDescriptorWrite(captorPeripheral.capture(), captorValue.capture(), captorDescriptor.capture(), captorStatus.capture()); byte[] value = captorValue.getValue(); assertEquals(0x01, value[0]); assertNotEquals(value, originalByteArray); // Check if the byte array has been copied assertEquals(peripheral, captorPeripheral.getValue()); assertEquals(descriptor, captorDescriptor.getValue()); assertEquals(GATT_SUCCESS, (int) captorStatus.getValue() ); }
Example #22
Source Project: BlueSTSDK_Android Author: STMicroelectronics File: NodeTest.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void connectNodeWithDebug(){ BluetoothDevice device = spy(Shadow.newInstanceOf(BluetoothDevice.class)); BluetoothDeviceShadow shadowDevice = Shadow.extract(device); BluetoothGattService debugService = new BluetoothGattService(BLENodeDefines.Services .Debug.DEBUG_SERVICE_UUID,BluetoothGattService.SERVICE_TYPE_PRIMARY); debugService.addCharacteristic( new BluetoothGattCharacteristic(BLENodeDefines.Services.Debug.DEBUG_STDERR_UUID, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic .PROPERTY_NOTIFY)); debugService.addCharacteristic( new BluetoothGattCharacteristic(BLENodeDefines.Services.Debug.DEBUG_TERM_UUID, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic .PROPERTY_NOTIFY) ); shadowDevice.addService(debugService); Node node = createNode(device); Assert.assertEquals(Node.State.Idle, node.getState()); node.connect(RuntimeEnvironment.application); TestUtil.execAllAsyncTask(); verify(device).connectGatt(eq(RuntimeEnvironment.application), eq(false), any(BluetoothGattCallback.class)); Assert.assertEquals(Node.State.Connected, node.getState()); Assert.assertTrue(node.getDebug()!=null); }
Example #23
Source Project: bean-sdk-android Author: PunchThrough File: BatteryProfile.java License: MIT License | 5 votes |
@Override public void onProfileReady() { List<BluetoothGattService> services = mGattClient.getServices(); for (BluetoothGattService service : services) { if (service.getUuid().equals(Constants.UUID_BATTERY_SERVICE)) { mBatteryService = service; } } ready = true; }
Example #24
Source Project: microbit Author: Samsung File: BLEService.java License: Apache License 2.0 | 5 votes |
/** * write repeatedly to (4) to register for the events your app wants to see from the micro:bit. * e.g. write <1,1> to register for a 'DOWN' event on ButtonA. * Any events matching this will then start to be delivered via the MicroBit Event characteristic. * * @param eventService Bluetooth GATT service. * @param enable Enable or disable. */ private void register_AppRequirement(BluetoothGattService eventService, boolean enable) { if(!enable) { return; } BluetoothGattCharacteristic app_requirements = eventService.getCharacteristic(CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS); if(app_requirements != null) { logi("register_AppRequirement() :: found Constants.ES_CLIENT_REQUIREMENTS "); /* Registering for everything at the moment <1,0> which means give me all the events from ButtonA. <2,0> which means give me all the events from ButtonB. <0,0> which means give me all the events from everything. writeCharacteristic(Constants.EVENT_SERVICE.toString(), Constants.ES_CLIENT_REQUIREMENTS.toString(), 0, BluetoothGattCharacteristic.FORMAT_UINT32); */ writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_REMOTE_CONTROL_ID, GattFormats.FORMAT_UINT32); writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_CAMERA_ID, GattFormats.FORMAT_UINT32); writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_ALERTS_ID, GattFormats.FORMAT_UINT32); writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_SIGNAL_STRENGTH_ID, GattFormats.FORMAT_UINT32); writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_DEVICE_INFO_ID, GattFormats.FORMAT_UINT32); //writeCharacteristic(GattServiceUUIDs.EVENT_SERVICE.toString(), CharacteristicUUIDs // .ES_CLIENT_REQUIREMENTS.toString(), EventCategories.SAMSUNG_TELEPHONY_ID, // GattFormats.FORMAT_UINT32); } }
Example #25
Source Project: OpenFit Author: jareddlc File: BluetoothLeService.java License: MIT License | 5 votes |
public List<BluetoothGattService> getSupportedGattServices() { if(mBluetoothGatt == null) { Log.w(LOG_TAG, "getSupportedGattServices mBluetoothGatt not initialized"); return null; } Log.d(LOG_TAG, "getSupportedGattServices"); return mBluetoothGatt.getServices(); }
Example #26
Source Project: RxAndroidBle Author: Polidea File: LoggerUtilBluetoothServices.java License: Apache License 2.0 | 5 votes |
private static void appendServiceHeader(StringBuilder descriptionBuilder, BluetoothGattService bluetoothGattService) { descriptionBuilder .append("\n") .append(createServiceType(bluetoothGattService)) .append(" - ") .append(createServiceName(bluetoothGattService)) .append(" (") .append(LoggerUtil.getUuidToLog(bluetoothGattService.getUuid())) .append(")\n") .append("Instance ID: ").append(bluetoothGattService.getInstanceId()) .append('\n'); }
Example #27
Source Project: xDrip-plus Author: jamorham File: Ob1G5CollectionService.java License: GNU General Public License v3.0 | 5 votes |
private void onServicesDiscovered(RxBleDeviceServices services) { for (BluetoothGattService service : services.getBluetoothGattServices()) { if (d) UserError.Log.d(TAG, "Service: " + getUUIDName(service.getUuid())); if (service.getUuid().equals(BluetoothServices.CGMService)) { if (d) UserError.Log.i(TAG, "Found CGM Service!"); if (!always_discover) { do_discovery = false; } changeState(STATE.CHECK_AUTH); return; } } UserError.Log.e(TAG, "Could not locate CGM service during discovery"); incrementErrors(); }
Example #28
Source Project: bleYan Author: captain-miao File: AppBleService.java License: GNU General Public License v2.0 | 5 votes |
@Override public void onDiscoverServices(BluetoothGatt gatt) { //for test final BluetoothGattService gattService = gatt .getService(UUID.fromString("E54EAA50-371B-476C-99A3-74d267e3edbe")); if (gattService != null) { final BluetoothGattCharacteristic connectConf = gattService.getCharacteristic(UUID.fromString("E54EAA55-371B-476C-99A3-74D267E3EDBE")); if(connectConf != null) { AppLog.i(TAG, "onDiscoverServices: connectConf()"); connectConf.setValue(new byte[]{ (byte) 0x88 }); write(connectConf); } } }
Example #29
Source Project: BleSensorTag Author: StevenRudenko File: BleServicesAdapter.java License: MIT License | 5 votes |
public BleServicesAdapter(Context context, List<BluetoothGattService> gattServices, @Nullable DeviceDef def) { inflater = LayoutInflater.from(context); this.def = def; services = new ArrayList<>(gattServices.size()); characteristics = new HashMap<>(gattServices.size()); for (BluetoothGattService gattService : gattServices) { final List<BluetoothGattCharacteristic> gattCharacteristics = gattService .getCharacteristics(); characteristics.put(gattService, new ArrayList<>(gattCharacteristics)); services.add(gattService); } }
Example #30
Source Project: AsteroidOSSync Author: AsteroidOS File: PA_ServiceManager.java License: GNU General Public License v3.0 | 5 votes |
private List<BluetoothGattDescriptor> collectAllNativeDescriptors( final UUID serviceUuid_nullable, final UUID charUuid_nullable, final Object forEach_nullable) { final ArrayList<BluetoothGattDescriptor> toReturn = forEach_nullable == null ? new ArrayList<BluetoothGattDescriptor>() : null; final List<BluetoothGattService> serviceList_native = getNativeServiceList_original(); for (int i = 0; i < serviceList_native.size(); i++) { final BleServiceWrapper service_ith = new BleServiceWrapper(serviceList_native.get(i)); if (serviceUuid_nullable == null || !service_ith.isNull() && serviceUuid_nullable.equals(service_ith.getService().getUuid())) { final List<BluetoothGattCharacteristic> charList_native = getNativeCharacteristicList_original(service_ith); for (int j = 0; j < charList_native.size(); j++) { final BleCharacteristicWrapper char_jth = new BleCharacteristicWrapper(charList_native.get(j)); if (charUuid_nullable == null || !char_jth.isNull() && charUuid_nullable.equals(char_jth.getCharacteristic().getUuid())) { final List<BluetoothGattDescriptor> descriptors = getNativeDescriptorList_original(char_jth); if (forEach_nullable != null) { if (Utils.doForEach_break(forEach_nullable, descriptors)) { return P_Const.EMPTY_DESCRIPTOR_LIST; } } else { toReturn.addAll(descriptors); } } } } } return toReturn; }