Flutter_blue: Unable to write a characteristics in IPhone

Created on 9 Nov 2018  路  7Comments  路  Source: pauldemarco/flutter_blue

Same app which is running perfectly in Android is failed to write characteristics in IOS

waiting for customer response

Most helpful comment

@aduarte88 I had a similar issue running the basic example in the project. Double check whether the characteristic actually has the 'write' flag set in the characteristic declaration. On iOS you'll indeed get an error trying to write with response on a characteristic that only supports write without response. You can double check the characteristic's declaration by inspecting the characteristic.properties.writeWithoutResponse and characteristic.properties.write flags. The example does not differentiate between these 2 types of writes (yet). I'm pretty new to dart/flutter but this should fix the example I believe:

_writeCharacteristic(BluetoothCharacteristic c) async {
    CharacteristicWriteType writeType = c.properties.writeWithoutResponse
        ? CharacteristicWriteType.withoutResponse
        : CharacteristicWriteType.withResponse;
    await device.writeCharacteristic(c, [0x12, 0x34], type: writeType);
    setState(() {});
  }

All 7 comments

@aravindara I would need some more information if I'm to try and solve the issue.

What does the code look like?

What is the structure of the Bluetooth Characteristic / does it have descriptors?

same here
image
@pauldemarco
iphoneX

I have the same problem
in android works but in ios not
I have already been able to write in iOS of type "withoutResponse" but when it is "withResponse" it gives this error

@aduarte88 I had a similar issue running the basic example in the project. Double check whether the characteristic actually has the 'write' flag set in the characteristic declaration. On iOS you'll indeed get an error trying to write with response on a characteristic that only supports write without response. You can double check the characteristic's declaration by inspecting the characteristic.properties.writeWithoutResponse and characteristic.properties.write flags. The example does not differentiate between these 2 types of writes (yet). I'm pretty new to dart/flutter but this should fix the example I believe:

_writeCharacteristic(BluetoothCharacteristic c) async {
    CharacteristicWriteType writeType = c.properties.writeWithoutResponse
        ? CharacteristicWriteType.withoutResponse
        : CharacteristicWriteType.withResponse;
    await device.writeCharacteristic(c, [0x12, 0x34], type: writeType);
    setState(() {});
  }

i have fixed this by listen the notification.

This issue seems to be resolved. Closing for now.

Captura de Pantalla 2021-02-22 a la(s) 4 26 05 p 聽m
i have a this problem ,help me please
Captura de Pantalla 2021-02-22 a la(s) 4 08 36 p 聽m

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diso73 picture diso73  路  5Comments

M3sca picture M3sca  路  3Comments

a-v-ebrahimi picture a-v-ebrahimi  路  4Comments

pauldemarco picture pauldemarco  路  4Comments

ekuleshov picture ekuleshov  路  3Comments