android.widget.SimpleExpandableListAdapter#android.bluetooth.BluetoothGattService源码实例Demo

下面列出了android.widget.SimpleExpandableListAdapter#android.bluetooth.BluetoothGattService 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: blefun-androidthings   文件: GattClient.java
@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);
    }
}
 
源代码2 项目: blessed-android   文件: BluetoothPeripheral.java
@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);
        }
    });
}
 
源代码3 项目: react-native-ble-manager   文件: Peripheral.java
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);
			}
		}
	}
 
源代码4 项目: BLEService   文件: BTLEDeviceManager.java
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);
  }
 
源代码5 项目: bean-sdk-android   文件: OADProfile.java
/**
 * 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;
    }
}
 
源代码6 项目: bitgatt   文件: GattConnection.java
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;
        }
    }
}
 
@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;
}
 
源代码8 项目: Android-nRF-Mesh-Library   文件: BleMeshManager.java
@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;
}
 
源代码9 项目: AsteroidOSSync   文件: BleManager.java
/**
 * 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;
}
 
源代码10 项目: SweetBlue   文件: PA_ServiceManager.java
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;
}
 
源代码11 项目: BLEService   文件: PeripheralActivity.java
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();
}
 	});
 }
 
源代码12 项目: BleLib   文件: BleService.java
/**
     * 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;
//        }
    }
 
源代码13 项目: Android-nRF-Toolbox   文件: BleManager.java
/**
 * 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);
}
 
/**
 * 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;
}
 
源代码15 项目: IoT-Firstep   文件: DeviceControlActivity.java
/**
   * 获取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();
}

  }
 
源代码16 项目: Bluefruit_LE_Connect_Android   文件: BleManager.java
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);
    }
}
 
源代码17 项目: FastBle   文件: ServiceListFragment.java
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();
}
 
源代码18 项目: thunderboard-android   文件: BleUtils.java
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;
}
 
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);
}
 
@Override
public void onServiceAdded(int status, BluetoothGattService service) {
    super.onServiceAdded(status, service);

    Log.d(TAG, "GattServer: onServiceAdded");
    mAddServicesSemaphore.release();
}
 
源代码21 项目: blessed-android   文件: BluetoothPeripheralTest.java
@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() );
}
 
源代码22 项目: BlueSTSDK_Android   文件: NodeTest.java
@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);
}
 
源代码23 项目: bean-sdk-android   文件: BatteryProfile.java
@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;
}
 
源代码24 项目: microbit   文件: BLEService.java
/**
 * 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);
    }
}
 
源代码25 项目: OpenFit   文件: BluetoothLeService.java
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();
}
 
源代码26 项目: RxAndroidBle   文件: LoggerUtilBluetoothServices.java
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');
}
 
源代码27 项目: xDrip-plus   文件: Ob1G5CollectionService.java
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();
}
 
源代码28 项目: bleYan   文件: AppBleService.java
@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);
        }
    }
}
 
源代码29 项目: BleSensorTag   文件: BleServicesAdapter.java
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);
    }
}
 
源代码30 项目: AsteroidOSSync   文件: PA_ServiceManager.java
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;
}