|
本帖最后由 heyu852521 于 2019-2-21 14:25 编辑
public void int XXX(String ServiceUUID,String CharaUUID){
BluetoothGattService service = mBluetoothGatt.getService(UUID.fromString(ServiceUUID));
if (service == null){ return 1; }else{
BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(CharaUUID));
if (characteristic == null){ return 2; }else{
boolean aaa = mBluetoothGatt.setCharacteristicNotification(characteristic, true);
if (aaa == false){ return 3;}else{
BluetoothGattDescriptor desc = characteristic.getDescriptor(UUID.fromString(CharaUUID));
if (desc == null){ return 4; }else{
boolean bbb = desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
if (bbb == false){ return 5; }else{
boolean ccc = mBluetoothGatt.writeDescriptor(desc);
if (ccc == false){ return 6; }else{return 0;}}}}}}}
火山类库的代码
|
|