java - Android BLE: cannot write a Characteristic (no PROPERTY_WRITE) -
java - Android BLE: cannot write a Characteristic (no PROPERTY_WRITE) -
i have android (glass) application acts ble central , connects ble peripheral (which ios device using core bluetooth). trying read and write peripheral.
reading works fine (and receiving notifications works fine too).
however didn't manage write characteristic. here's code:
@override public void onservicesdiscovered(bluetoothgatt gatt, int status) { if (status == bluetoothgatt.gatt_success) { bluetoothgattservice bse = gatt.getservice(transfer_service_uuid); bluetoothgattcharacteristic bgc = bse.getcharacteristic(transfer_characteristic_uuid); bgc.setvalue("hello"); boolean writeok = gatt.writecharacteristic(bgc); } } @override public void oncharacteristicwrite(bluetoothgatt gatt, bluetoothgattcharacteristic characteristic, int status) { // never called } writeok false. debugged , found out reason properties. bgc.getproperties() returns 50, no matter properties set on ios side. 50 property_read, property_notify , property_indicate, missing property_write, bluetoothgatt.writecharacteristic() exits:
public boolean writecharacteristic(bluetoothgattcharacteristic characteristic) { if ((characteristic.getproperties() & bluetoothgattcharacteristic.property_write) == 0 && (characteristic.getproperties() & bluetoothgattcharacteristic.property_write_no_response) == 0) homecoming false; ... } it seems me properties not transmitted correctly ios peripheral android central. when connecting ios peripheral ios central, properties transmitted correctly , writing works.
i have tried:
pairing devices using reliable write (but don't know anyway)so - doing wrong on android side? if not: bug? or ios wants writes ios devices?
i using android 4.4.2 (glass xe18.11).
seems bug in android ble api. after latest update (glass xe18.3) behaviour gone , transmitting properties works expected.
java android bluetooth-lowenergy google-glass core-bluetooth
Comments
Post a Comment