android - Bluetooth GATT error while doing onServicesDiscovered() -


this problem bothers me few days. code bluetooth connection work fine on first kind of devices (heart rate detector) other phones. second kind of devices (also heart rate detector) work fine mobile such htc, asus. however, of second kind of devices can not connect sony xperia z1~z3, samsung n5(i'm not sure actual model).

to observe logcat, error occurred while calling gatt.discoverservices(). call method in bluetoothgattcallback -> onconnectionstatechange -> newstate == state_connected.

it's normal services this:

05-04 12:08:15.678: d/btgatt.btif(23132): btif_gattc_upstreams_evt: event 7 05-04 12:08:15.678: d/btgatt.gattservice(23132): onsearchresult() - address=f9:ce:5f:a3:69:cf, uuid=00001800-0000-1000-8000-00805f9b34fb 05-04 12:08:15.678: d/bluetoothgatt(22365): ongetservice() - device=f9:ce:5f:a3:69:cf uuid=00001800-0000-1000-8000-00805f9b34fb 

but here got 6 services, in other device got 7 services. (lose 1 customize uuid)

service:

ongetservice() - device=f9:ce:5f:a3:69:cf uuid=00001800-0000-1000-8000-00805f9b34fb ongetservice() - device=f9:ce:5f:a3:69:cf uuid=00001801-0000-1000-8000-00805f9b34fb ongetservice() - device=f9:ce:5f:a3:69:cf uuid=0000180a-0000-1000-8000-00805f9b34fb ongetservice() - device=f9:ce:5f:a3:69:cf uuid=0000180d-0000-1000-8000-00805f9b34fb ongetservice() - device=f9:ce:5f:a3:69:cf uuid=6c721838-5bf1-4f64-9170-381c08ec57ee ongetservice() - device=f9:ce:5f:a3:69:cf uuid=6c721550-5bf1-4f64-9170-381c08ec57ee 

the following excerpts of logcat thought incorrect result:

05-04 12:08:15.678: d/btgatt.btif(23132): btif_gattc_get_characteristic 05-04 12:08:15.678: d/btgatt.btif(23132): btgattc_handle_event: event 1007 05-04 12:08:15.678: e/bt-btif(23132): no server cache available 05-04 12:08:15.678: d/btgatt.gattservice(23132): ongetcharacteristic() - address=f9:ce:5f:a3:69:cf, status=133, charuuid=449e4528-7633-6ccc-8000-00805f9b34fb, prop=2 05-04 12:08:15.678: d/btgatt.btif(23132): btif_gattc_get_included_service 05-04 12:08:15.678: d/btgatt.btif(23132): btgattc_handle_event: event 1011 05-04 12:08:15.678: e/bt-btif(23132): no server cache available 05-04 12:08:15.678: e/btgatt.btif(23132): bta_to_btif_uuid: unknown uuid length 30209! 05-04 12:08:15.688: d/btgatt.gattservice(23132): ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=00001800-0000-1000-8000-00805f9b34fb, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb 05-04 12:08:15.688: d/btgatt.gattservice(23132): continuesearch() - connid=5, status=0 

these logcat repeat 6 times every service in beginning same charateristic uuid = 449e4528-7633-6ccc-8000-00805f9b34fb. , uuid not appeared in other successful case.

characteristic: (just paste different part)

ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=00001800-0000-1000-8000-00805f9b34fb, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=00001801-0000-1000-8000-00805f9b34fb, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=0000180a-0000-1000-8000-00805f9b34fb, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=0000180d-0000-1000-8000-00805f9b34fb, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=6c721838-5bf1-4f64-9170-381c08ec57ee, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb ongetincludedservice() - address=f9:ce:5f:a3:69:cf, status=133, uuid=6c721550-5bf1-4f64-9170-381c08ec57ee, incluuid=449e4528-7633-6ccc-8000-00805f9b34fb 

i've found similar question: onservicediscoverd not contain service

but call every device.connectgatt() in runonuithread after onlescan(), tried call specific address method while click button(be sure runonuithread).

bluetoothdevice device = mbluetoothadapter.getremotedevice("f4:36:8c:9b:87:87"); device.connectgatt(this, false, mgattcallback); 

this solution not work.

i tried close wifi , restart bluetooth. works mi2, not xperia z1.

does have idea? lot! :)


Comments