Connect to gatt server not working on Samsung Galaxy Core Prime (Android 5.1.1)










5















I have a BLE app which works on devices with Android 6.0 and higher but I have issues on Samsung Galaxy Core Prime (Android 5.1.1). After calling connectGatt nothing happens and the callback receives only disconnected state.



I have cut out appropriate code:



BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
final BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);
Log.e("BluetoothLeService", "connect: connectGatt(this, false, mGattCallback)");
BluetoothGatt bluetoothGatt = device.connectGatt(this, false, mGattCallback);

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback()
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
if (newState == BluetoothProfile.STATE_CONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_CONNECTED");
else if (newState == BluetoothProfile.STATE_DISCONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_DISCONNECTED");



@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status)


@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)


@Override
public void onMtuChanged (BluetoothGatt gatt, int mtu, int status)

;


And here is the log:



E/BluetoothLeService: connect: connectGatt(this, false, mGattCallback)
I/StatusBar: Icon Only
D/BluetoothGatt: connect() - device: CC:4B:73:22:9D:DB, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/BtGatt.GattService: registerClient() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/SamsungIME: Dismiss ExpandCandiate
D/PanelView: There is/are notification(s)
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@4
I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord2bfa99a5 u0 com.streamunlimited.streamsdkdemo/.ui.setup.SetupDeviceActivity t43 time:3838458
W/ActivityManager: mDVFSHelper.release()
D/CustomFrequencyManagerService: acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 pkgName : ACTIVITY_RESUME_BOOSTER@8
D/BtGatt.GattService: onClientRegistered() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462, clientIf=6
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BtGatt.GattService: clientConnect() - address=CC:4B:73:22:9D:DB, isDirect=true set own addr = false own addr type:0
D/BtGatt.btif: btif_get_device_type: Device [cc:4b:73:22:9d:db] type 3, addr. type 0
D/IOP_DB_BT: db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value cc:4b:73:22:9d:db
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_MFCT, value 15
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_VER, value 9:24838
D/IOP_DB_BT: db_query_add_key: key KEY_DIR_ALL, value 1
D/IOP_DB_BT: db_query_execute: result 1
D/bluedroid-mrvl: bt_vnd_mrvl_if_op(L95): opcode = 7
I/SurfaceFlinger: id=153 Removed TetupScanAc (3/9)
I/SurfaceFlinger: id=153 Removed TetupScanAc (-2/9)
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@21558ec5 time:3838516
W/SurfaceFlinger: couldn't log to binary event log: overflow.
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@8
D/BatteryService: !@BatteryListener : batteryPropertiesChanged!
W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004
D/BtGatt.GattService: onConnected() - clientIf=6, connId=0, address=CC:4B:73:22:9D:DB
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB
E/BluetoothLeService: onConnectionStateChange: STATE_DISCONNECTED


The lines that look suspicious are:



W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004


I found that reason 4 means:



PAGE TIMEOUT (0x04)
The Page Timeout error code indicates that a page timed out because of the
Page Timeout configuration parameter. This error code may occur only with the
Remote_Name_Request and Create_Connection commands.


in documentation https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=421043&_ga=2.243934277.1321770839.1542020684-854809025.1539785109



Also this line:



D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB


is just a macro for GATT_ERROR based on:



https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.4.4_r2.0.1/stack/include/gatt_api.h



I have also tried nRF Connect app and it fails to connect too with: Error 133 (0x85):GATT ERROR



Do you know any possible reason and solution for this?
Thanks










share|improve this question
























  • Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

    – Roberto Nicba Anić Banić
    Nov 16 '18 at 10:00











  • @RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

    – Matej Procházka
    Nov 20 '18 at 9:07












  • We used 5 retries, but make sure you check that the disconnect error is 133

    – Roberto Nicba Anić Banić
    Nov 21 '18 at 9:57















5















I have a BLE app which works on devices with Android 6.0 and higher but I have issues on Samsung Galaxy Core Prime (Android 5.1.1). After calling connectGatt nothing happens and the callback receives only disconnected state.



I have cut out appropriate code:



BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
final BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);
Log.e("BluetoothLeService", "connect: connectGatt(this, false, mGattCallback)");
BluetoothGatt bluetoothGatt = device.connectGatt(this, false, mGattCallback);

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback()
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
if (newState == BluetoothProfile.STATE_CONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_CONNECTED");
else if (newState == BluetoothProfile.STATE_DISCONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_DISCONNECTED");



@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status)


@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)


@Override
public void onMtuChanged (BluetoothGatt gatt, int mtu, int status)

;


And here is the log:



E/BluetoothLeService: connect: connectGatt(this, false, mGattCallback)
I/StatusBar: Icon Only
D/BluetoothGatt: connect() - device: CC:4B:73:22:9D:DB, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/BtGatt.GattService: registerClient() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/SamsungIME: Dismiss ExpandCandiate
D/PanelView: There is/are notification(s)
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@4
I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord2bfa99a5 u0 com.streamunlimited.streamsdkdemo/.ui.setup.SetupDeviceActivity t43 time:3838458
W/ActivityManager: mDVFSHelper.release()
D/CustomFrequencyManagerService: acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 pkgName : ACTIVITY_RESUME_BOOSTER@8
D/BtGatt.GattService: onClientRegistered() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462, clientIf=6
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BtGatt.GattService: clientConnect() - address=CC:4B:73:22:9D:DB, isDirect=true set own addr = false own addr type:0
D/BtGatt.btif: btif_get_device_type: Device [cc:4b:73:22:9d:db] type 3, addr. type 0
D/IOP_DB_BT: db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value cc:4b:73:22:9d:db
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_MFCT, value 15
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_VER, value 9:24838
D/IOP_DB_BT: db_query_add_key: key KEY_DIR_ALL, value 1
D/IOP_DB_BT: db_query_execute: result 1
D/bluedroid-mrvl: bt_vnd_mrvl_if_op(L95): opcode = 7
I/SurfaceFlinger: id=153 Removed TetupScanAc (3/9)
I/SurfaceFlinger: id=153 Removed TetupScanAc (-2/9)
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@21558ec5 time:3838516
W/SurfaceFlinger: couldn't log to binary event log: overflow.
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@8
D/BatteryService: !@BatteryListener : batteryPropertiesChanged!
W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004
D/BtGatt.GattService: onConnected() - clientIf=6, connId=0, address=CC:4B:73:22:9D:DB
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB
E/BluetoothLeService: onConnectionStateChange: STATE_DISCONNECTED


The lines that look suspicious are:



W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004


I found that reason 4 means:



PAGE TIMEOUT (0x04)
The Page Timeout error code indicates that a page timed out because of the
Page Timeout configuration parameter. This error code may occur only with the
Remote_Name_Request and Create_Connection commands.


in documentation https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=421043&_ga=2.243934277.1321770839.1542020684-854809025.1539785109



Also this line:



D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB


is just a macro for GATT_ERROR based on:



https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.4.4_r2.0.1/stack/include/gatt_api.h



I have also tried nRF Connect app and it fails to connect too with: Error 133 (0x85):GATT ERROR



Do you know any possible reason and solution for this?
Thanks










share|improve this question
























  • Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

    – Roberto Nicba Anić Banić
    Nov 16 '18 at 10:00











  • @RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

    – Matej Procházka
    Nov 20 '18 at 9:07












  • We used 5 retries, but make sure you check that the disconnect error is 133

    – Roberto Nicba Anić Banić
    Nov 21 '18 at 9:57













5












5








5


1






I have a BLE app which works on devices with Android 6.0 and higher but I have issues on Samsung Galaxy Core Prime (Android 5.1.1). After calling connectGatt nothing happens and the callback receives only disconnected state.



I have cut out appropriate code:



BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
final BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);
Log.e("BluetoothLeService", "connect: connectGatt(this, false, mGattCallback)");
BluetoothGatt bluetoothGatt = device.connectGatt(this, false, mGattCallback);

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback()
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
if (newState == BluetoothProfile.STATE_CONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_CONNECTED");
else if (newState == BluetoothProfile.STATE_DISCONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_DISCONNECTED");



@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status)


@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)


@Override
public void onMtuChanged (BluetoothGatt gatt, int mtu, int status)

;


And here is the log:



E/BluetoothLeService: connect: connectGatt(this, false, mGattCallback)
I/StatusBar: Icon Only
D/BluetoothGatt: connect() - device: CC:4B:73:22:9D:DB, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/BtGatt.GattService: registerClient() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/SamsungIME: Dismiss ExpandCandiate
D/PanelView: There is/are notification(s)
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@4
I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord2bfa99a5 u0 com.streamunlimited.streamsdkdemo/.ui.setup.SetupDeviceActivity t43 time:3838458
W/ActivityManager: mDVFSHelper.release()
D/CustomFrequencyManagerService: acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 pkgName : ACTIVITY_RESUME_BOOSTER@8
D/BtGatt.GattService: onClientRegistered() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462, clientIf=6
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BtGatt.GattService: clientConnect() - address=CC:4B:73:22:9D:DB, isDirect=true set own addr = false own addr type:0
D/BtGatt.btif: btif_get_device_type: Device [cc:4b:73:22:9d:db] type 3, addr. type 0
D/IOP_DB_BT: db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value cc:4b:73:22:9d:db
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_MFCT, value 15
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_VER, value 9:24838
D/IOP_DB_BT: db_query_add_key: key KEY_DIR_ALL, value 1
D/IOP_DB_BT: db_query_execute: result 1
D/bluedroid-mrvl: bt_vnd_mrvl_if_op(L95): opcode = 7
I/SurfaceFlinger: id=153 Removed TetupScanAc (3/9)
I/SurfaceFlinger: id=153 Removed TetupScanAc (-2/9)
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@21558ec5 time:3838516
W/SurfaceFlinger: couldn't log to binary event log: overflow.
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@8
D/BatteryService: !@BatteryListener : batteryPropertiesChanged!
W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004
D/BtGatt.GattService: onConnected() - clientIf=6, connId=0, address=CC:4B:73:22:9D:DB
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB
E/BluetoothLeService: onConnectionStateChange: STATE_DISCONNECTED


The lines that look suspicious are:



W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004


I found that reason 4 means:



PAGE TIMEOUT (0x04)
The Page Timeout error code indicates that a page timed out because of the
Page Timeout configuration parameter. This error code may occur only with the
Remote_Name_Request and Create_Connection commands.


in documentation https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=421043&_ga=2.243934277.1321770839.1542020684-854809025.1539785109



Also this line:



D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB


is just a macro for GATT_ERROR based on:



https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.4.4_r2.0.1/stack/include/gatt_api.h



I have also tried nRF Connect app and it fails to connect too with: Error 133 (0x85):GATT ERROR



Do you know any possible reason and solution for this?
Thanks










share|improve this question
















I have a BLE app which works on devices with Android 6.0 and higher but I have issues on Samsung Galaxy Core Prime (Android 5.1.1). After calling connectGatt nothing happens and the callback receives only disconnected state.



I have cut out appropriate code:



BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
final BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);
Log.e("BluetoothLeService", "connect: connectGatt(this, false, mGattCallback)");
BluetoothGatt bluetoothGatt = device.connectGatt(this, false, mGattCallback);

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback()
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
if (newState == BluetoothProfile.STATE_CONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_CONNECTED");
else if (newState == BluetoothProfile.STATE_DISCONNECTED)
Log.e("BluetoothLeService", "onConnectionStateChange: STATE_DISCONNECTED");



@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status)


@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)


@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)


@Override
public void onMtuChanged (BluetoothGatt gatt, int mtu, int status)

;


And here is the log:



E/BluetoothLeService: connect: connectGatt(this, false, mGattCallback)
I/StatusBar: Icon Only
D/BluetoothGatt: connect() - device: CC:4B:73:22:9D:DB, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/BtGatt.GattService: registerClient() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462
D/SamsungIME: Dismiss ExpandCandiate
D/PanelView: There is/are notification(s)
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@4
I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord2bfa99a5 u0 com.streamunlimited.streamsdkdemo/.ui.setup.SetupDeviceActivity t43 time:3838458
W/ActivityManager: mDVFSHelper.release()
D/CustomFrequencyManagerService: acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 pkgName : ACTIVITY_RESUME_BOOSTER@8
D/BtGatt.GattService: onClientRegistered() - UUID=7d428718-b549-4021-8a45-9d3bd2afd462, clientIf=6
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BtGatt.GattService: clientConnect() - address=CC:4B:73:22:9D:DB, isDirect=true set own addr = false own addr type:0
D/BtGatt.btif: btif_get_device_type: Device [cc:4b:73:22:9d:db] type 3, addr. type 0
D/IOP_DB_BT: db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value cc:4b:73:22:9d:db
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_MFCT, value 15
D/IOP_DB_BT: db_query_add_key: key KEY_LMP_VER, value 9:24838
D/IOP_DB_BT: db_query_add_key: key KEY_DIR_ALL, value 1
D/IOP_DB_BT: db_query_execute: result 1
D/bluedroid-mrvl: bt_vnd_mrvl_if_op(L95): opcode = 7
I/SurfaceFlinger: id=153 Removed TetupScanAc (3/9)
I/SurfaceFlinger: id=153 Removed TetupScanAc (-2/9)
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@21558ec5 time:3838516
W/SurfaceFlinger: couldn't log to binary event log: overflow.
D/CustomFrequencyManagerService: releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT frequency : 1248000 uid : 1000 pid : 2975 tag : ACTIVITY_RESUME_BOOSTER@8
D/BatteryService: !@BatteryListener : batteryPropertiesChanged!
W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004
D/BtGatt.GattService: onConnected() - clientIf=6, connId=0, address=CC:4B:73:22:9D:DB
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB
E/BluetoothLeService: onConnectionStateChange: STATE_DISCONNECTED


The lines that look suspicious are:



W/bt-btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
W/bt-btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0004


I found that reason 4 means:



PAGE TIMEOUT (0x04)
The Page Timeout error code indicates that a page timed out because of the
Page Timeout configuration parameter. This error code may occur only with the
Remote_Name_Request and Create_Connection commands.


in documentation https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=421043&_ga=2.243934277.1321770839.1542020684-854809025.1539785109



Also this line:



D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=CC:4B:73:22:9D:DB


is just a macro for GATT_ERROR based on:



https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.4.4_r2.0.1/stack/include/gatt_api.h



I have also tried nRF Connect app and it fails to connect too with: Error 133 (0x85):GATT ERROR



Do you know any possible reason and solution for this?
Thanks







android bluetooth bluetooth-lowenergy gatt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 9:53









Étienne

3,58412147




3,58412147










asked Nov 12 '18 at 11:22









Matej ProcházkaMatej Procházka

376




376












  • Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

    – Roberto Nicba Anić Banić
    Nov 16 '18 at 10:00











  • @RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

    – Matej Procházka
    Nov 20 '18 at 9:07












  • We used 5 retries, but make sure you check that the disconnect error is 133

    – Roberto Nicba Anić Banić
    Nov 21 '18 at 9:57

















  • Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

    – Roberto Nicba Anić Banić
    Nov 16 '18 at 10:00











  • @RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

    – Matej Procházka
    Nov 20 '18 at 9:07












  • We used 5 retries, but make sure you check that the disconnect error is 133

    – Roberto Nicba Anić Banić
    Nov 21 '18 at 9:57
















Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

– Roberto Nicba Anić Banić
Nov 16 '18 at 10:00





Im pretty sure it is samsung just being stupid in general. Had the same issue in projects that I made for the company I work for. We ended up retrying to connect a couple times in a row cause it is the same things the NRFConnect folks did. There is an issue on their github somewhere. And well they are Nordic folks who make BLE ICs. Apparently samsung has issues with internal service cache refreshing, so you can also hack a method that is private and call it via reflection and it apparently solves it. We chose to just connect a couple times in a row.

– Roberto Nicba Anić Banić
Nov 16 '18 at 10:00













@RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

– Matej Procházka
Nov 20 '18 at 9:07






@RobertoNicbaAnićBanić Thanks for you advice. So you say that I should try to call device.connectGatt(this, false, mGattCallback); when I receive disconnect call device.connectGatt(this, false, mGattCallback); till I get connected or max number of tries is reached? Any advice on that max number of retries? Thanks

– Matej Procházka
Nov 20 '18 at 9:07














We used 5 retries, but make sure you check that the disconnect error is 133

– Roberto Nicba Anić Banić
Nov 21 '18 at 9:57





We used 5 retries, but make sure you check that the disconnect error is 133

– Roberto Nicba Anić Banić
Nov 21 '18 at 9:57












1 Answer
1






active

oldest

votes


















1





+100









Error status 133 may have various reasons as it is a general error reported by the Android system. Possible causes:



  1. When the peripheral is out of range / turned off at the moment of establishing
    the connection

  2. When the Android BLE stack is not working correctly (sometimes turning off and on both Bluetooth Adapter and WiFi helps)

  3. When a peripheral does not conform correctly to BLE specification

  4. When the phone BLE drivers are not good enough

  5. Other (check google)

The easiest workaround, is to retry to connect if it fails with that type of error.



I highly recommend using Polidea's RxAndroidBle Library for implementing BLE communication, it is very useful.



If you start using it, then you can try to establish the connection and then retry if it fails using a the operator retryWhen. You can get some clues in this answer.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261130%2fconnect-to-gatt-server-not-working-on-samsung-galaxy-core-prime-android-5-1-1%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1





    +100









    Error status 133 may have various reasons as it is a general error reported by the Android system. Possible causes:



    1. When the peripheral is out of range / turned off at the moment of establishing
      the connection

    2. When the Android BLE stack is not working correctly (sometimes turning off and on both Bluetooth Adapter and WiFi helps)

    3. When a peripheral does not conform correctly to BLE specification

    4. When the phone BLE drivers are not good enough

    5. Other (check google)

    The easiest workaround, is to retry to connect if it fails with that type of error.



    I highly recommend using Polidea's RxAndroidBle Library for implementing BLE communication, it is very useful.



    If you start using it, then you can try to establish the connection and then retry if it fails using a the operator retryWhen. You can get some clues in this answer.






    share|improve this answer



























      1





      +100









      Error status 133 may have various reasons as it is a general error reported by the Android system. Possible causes:



      1. When the peripheral is out of range / turned off at the moment of establishing
        the connection

      2. When the Android BLE stack is not working correctly (sometimes turning off and on both Bluetooth Adapter and WiFi helps)

      3. When a peripheral does not conform correctly to BLE specification

      4. When the phone BLE drivers are not good enough

      5. Other (check google)

      The easiest workaround, is to retry to connect if it fails with that type of error.



      I highly recommend using Polidea's RxAndroidBle Library for implementing BLE communication, it is very useful.



      If you start using it, then you can try to establish the connection and then retry if it fails using a the operator retryWhen. You can get some clues in this answer.






      share|improve this answer

























        1





        +100







        1





        +100



        1




        +100





        Error status 133 may have various reasons as it is a general error reported by the Android system. Possible causes:



        1. When the peripheral is out of range / turned off at the moment of establishing
          the connection

        2. When the Android BLE stack is not working correctly (sometimes turning off and on both Bluetooth Adapter and WiFi helps)

        3. When a peripheral does not conform correctly to BLE specification

        4. When the phone BLE drivers are not good enough

        5. Other (check google)

        The easiest workaround, is to retry to connect if it fails with that type of error.



        I highly recommend using Polidea's RxAndroidBle Library for implementing BLE communication, it is very useful.



        If you start using it, then you can try to establish the connection and then retry if it fails using a the operator retryWhen. You can get some clues in this answer.






        share|improve this answer













        Error status 133 may have various reasons as it is a general error reported by the Android system. Possible causes:



        1. When the peripheral is out of range / turned off at the moment of establishing
          the connection

        2. When the Android BLE stack is not working correctly (sometimes turning off and on both Bluetooth Adapter and WiFi helps)

        3. When a peripheral does not conform correctly to BLE specification

        4. When the phone BLE drivers are not good enough

        5. Other (check google)

        The easiest workaround, is to retry to connect if it fails with that type of error.



        I highly recommend using Polidea's RxAndroidBle Library for implementing BLE communication, it is very useful.



        If you start using it, then you can try to establish the connection and then retry if it fails using a the operator retryWhen. You can get some clues in this answer.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 20:45









        dglozanodglozano

        946121




        946121





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261130%2fconnect-to-gatt-server-not-working-on-samsung-galaxy-core-prime-android-5-1-1%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党