android BluetoothGatt.writeCharacteristic()写入返回false

    xiaoxiao2022-06-30  111

    http://stackoverflow.com/questions/23879869/bluetoothgatt-writecharacteristic-always-returns-false 服务和写入特性在每次需要写入的时候重新获取,只有BluetoothGatt反复使用: byte[] data_to_write; // Your data BluetoothManager mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SREVICE); BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter(); BluetoothDevice mDevice = mBluetoothAdapter.getRemoteDevice(....); BluetoothGatt mBG = mDevice.connectGatt(....); BluetoothGattService mSVC = mBG.getService(service_uuid); BluetoothGattCharacteristic mCH = mSVC.getCharacteristic(characteristic_uuid); mCH.setValue(data_to_write); mBG.writeCharacteristic(mCH);
    转载请注明原文地址: https://ju.6miu.com/read-1126260.html

    最新回复(0)