markqvist / Sideband

LXMF client for Android, Linux and macOS allowing you to communicate with people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, or anything else Reticulum supports.
Other
391 stars 27 forks source link

0.7.7 not connecting via BT on Android 12 (Redmi Note 10 pro) #35

Closed FD0815 closed 11 months ago

FD0815 commented 11 months ago

The same issue occurs on multiple RNodes. (Heltec, Lora32 v1 -- and my friend has several T-beams that appear to have the same issue with both a Pixel 5 XL and a 2 XL, although I haven't looked at his logs yet.)

12-18 00:37:12.243 31150 31168 I sidebandservice: [2023-12-18 00:37:12] [Notice] Configuring Reticulum instance... 12-18 00:37:12.243 31150 31168 I sidebandservice: [2023-12-18 00:37:12] [Notice] Not enabling Reticulum Transport 12-18 00:37:12.243 31150 31168 I sidebandservice: [2023-12-18 00:37:12] [Notice] Purging stale messages... /data/user/0/io.unsigned.sideband/files//app_storage/sideband.db 12-18 00:37:14.180 31150 31168 I sidebandservice: [2023-12-18 00:37:14] [Error] Could not open serial port for interface RNodeInterface[RNodeInterface] 12-18 00:37:14.180 31150 31168 I sidebandservice: [2023-12-18 00:37:14] [Error] The contained exception was: Could not connect to any Bluetooth devices 12-18 00:37:14.180 31150 31168 I sidebandservice: [2023-12-18 00:37:14] [Error] Reticulum will attempt to bring up this interface periodically

Pairing works. SB on either Linux or Windows can connect both via BT or USBserial; and on an older PH-1 running Android 10 everything works, so I don't think it's the RNodes.

Via BT serial terminal I can connect, this is the logcat output for the MAC address

12-18 01:12:09.889 25404 25437 D BluetoothRemoteDevices: aclStateChangeCallback: Adapter State: ON Connected: 30:AE:A4:56:15:22 12-18 01:12:09.908 1895 1895 D CompanionDeviceManagerService: onDeviceConnected(address = 30:AE:A4:56:15:22) 12-18 01:12:09.909 1895 1895 I CompanionDeviceManagerService: onDeviceNearby(justAppeared, address = 30:AE:A4:56:15:22) 12-18 01:12:09.920 3674 3674 I AIVS : BluetoothBase:onConnection Find device :30:AE:A4:56:15:22 not exist. 12-18 01:12:09.928 3674 3674 I AIVS : BluetoothBase:onReceive: ACTION_ACL_CONNECTED, device : BluetoothDeviceInfo{ mCurrentOpType: 1 Device Edr ='RNode B47E; 30:AE:A4:56:15:22 vid:0xffff pid:0xffff MandatoryUpgrade:false channelStatus:0bleStatus:0 sppStatus:0 authStage:0 PowerMode:0 mBackUpMode:-1 isDeviceInfoUpdated:false authCmd:false FailedReason:0x0} 12-18 01:12:09.929 25404 25404 I BluetoothPhonePolicy: processDeviceConnected, device=30:AE:A4:56:15:22 12-18 01:12:09.930 25404 25404 D BluetoothDatabase: setConnection: device=30:AE:A4:56:15:22 and isA2dpDevice=false 12-18 01:12:09.930 25404 25404 D BluetoothDatabase: Updating last connected time for device: 30:AE:A4:56:15:22 to 12 12-18 01:12:09.930 25404 25404 D BluetoothDatabase: updateDatabase 30:AE:A4:56:15:22 12-18 01:12:09.939 5282 5282 I GH.WifiBluetoothRcvr: Connection action: android.bluetooth.device.action.ACL_CONNECTED, device 30:AE:A4:56:15:22 12-18 01:12:09.946 5282 6413 I CAR.BTCapsStore: Checking device with address 30:AE:A4:56:15:22 12-18 01:12:09.972 25404 25437 D BluetoothRemoteDevices: Skip name update for 30:AE:A4:56:15:22 12-18 01:12:09.997 5282 6413 I CAR.BTCapsStore: Checking device with address 30:AE:A4:56:15:22 //disconnect 12-18 01:12:19.912 1895 1895 D CompanionDeviceManagerService: TriggerDeviceDisappearedRunnable.run(address = 30:AE:A4:56:15:22) 12-18 01:12:20.939 25404 25437 D BluetoothRemoteDevices: Battery level was never set or is already reset, device=30:AE:A4:56:15:22 12-18 01:12:20.939 25404 25437 D BluetoothRemoteDevices: aclStateChangeCallback: Adapter State: ON Disconnected: 30:AE:A4:56:15:22 12-18 01:12:20.956 1895 1895 D CompanionDeviceManagerService: 30:AE:A4:56:15:22 disconnected w/ reason: (1100) Local request 12-18 01:12:20.956 1895 1895 D CompanionDeviceManagerService: onDeviceDisconnected(address = 30:AE:A4:56:15:22) 12-18 01:12:20.979 25404 25404 I BluetoothMapService: sRemoteDevice :null device:30:AE:A4:56:15:22

All permissions for SB are granted and battery optimizations are off. Not sure if I missed any step.

FD0815 commented 11 months ago

also this:

12-18 01:31:49.846 25404 27283 W ServiceManager: Permission failure: android.permission.BLUETOOTH from uid=10335 pid=11358

Indeed, in the permission list of the installed app android.permission.BLUETOOTH is missing, even though it's declared in the apk manifest. Could it be that on Android 12+ installs this gets snipped but it instead expects the android.permission.BLUETOOTH_SCAN (which is not declared here)?

markqvist commented 11 months ago

The android.permission.BLUETOOTH_SCAN permission should not be necessary, since Sideband doesn't actually do any scanning for devices, but only connects to RNodes that have already been discovered and paired via the system Bluetooth settings.

What is actually causing it is currently unclear to me, though. It has been working perfectly fine on Android 12 previously, but something in a recent release may have changed that, and I currently don't have an Android 12 device to test with - only 8.1, 9, 11, 13 and 14, which all work fine. The logs from the Pixel phones would definitely help!

Just to get the obvious out of the way, can you check that you actually enabled "Connect via Bluetooth" in Hardware -> RNode settings?

markqvist commented 11 months ago

According to the Android SDK docs is correct. The android.permission.BLUETOOTH permission is only needed on Android < 12 (API level 30 and below), and Sideband includes it in the manifest only for API level 30 and below. For API levels above, the other relevant Bluetooth permissions are included.

Since nobody else have chimed in, and I haven't heard anything else indicating this is actually a general bug for Android 12, I am closing this due to lack of feedback for now. Feel free to comment with more information if available.

shodan8192 commented 6 months ago

I also have a problem with the connection (RAK4631 RNode, Samsung A52s - Android 14, Sideband 0.8.5) Logcat :

05-29 10:05:24.019 25432 25449 I BluetoothAdapter: BluetoothAdapter() : io.unsigned.sideband
05-29 10:05:24.024 15554 15289 D BluetoothAdapterService: getBondedDevices, remove custom devices: 
05-29 10:05:24.059 25432 25449 I BluetoothSocket: connect() for device XX:XX:XX:XX:E8:52 called by pid: 25432
05-29 10:05:24.063 15554 15289 I bt_btif_sock: packages/modules/Bluetooth/system/btif/src/btif_sock.cc:329 btsock_connect: btsock_connect
05-29 10:05:24.063 15554 15289 I bt_btif_sock: packages/modules/Bluetooth/system/btif/src/btif_sock.cc:169 btif_sock_connection_logger: address=xx:xx:xx:xx:e8:52, role=2, state=2
05-29 10:05:24.064 15554 15632 W btm_acl : packages/modules/Bluetooth/system/stack/acl/btm_acl.cc:1863 BTM_ReadRemoteVersion: Unable to find active acl
05-29 10:05:24.064 15554 15626 W bt_l2cap: packages/modules/Bluetooth/system/main/bte_logmsg.cc:110 LogMsg: l2cu_enqueue_ccb CID: 0x005c  priority: 2
05-29 10:05:24.067 15554 15632 I bluetooth: packages/modules/Bluetooth/system/gd/hci/acl_manager/acl_scheduler.cc:169 try_dequeue_next_operation: Pending connections is not empty; so sending next connection
05-29 10:05:24.067 15554 15632 W bluetooth: packages/modules/Bluetooth/system/gd/hci/acl_manager/classic_impl.h:353 actually_create_connection: xx:xx:xx:xx:e8:52 EnqueueCommand (classic_link)
05-29 10:05:30.513 15554 15632 W bluetooth: packages/modules/Bluetooth/system/main/shim/acl.cc:1642 OnConnectFail: Connection failed classic remote:xx:xx:xx:xx:e8:52 reason:PAGE_TIMEOUT
05-29 10:05:30.514 15554 15626 W bt_l2cap: packages/modules/Bluetooth/system/main/bte_logmsg.cc:110 LogMsg: l2cu_release_ccb: cid 0x005c  in_use: 1  local_id:0
05-29 10:05:30.514 15554 15626 W bt_l2cap: packages/modules/Bluetooth/system/main/bte_logmsg.cc:110 LogMsg: l2cu_dequeue_ccb  CID: 0x005c
05-29 10:05:30.514 15554 15626 W bt_l2cap: packages/modules/Bluetooth/system/stack/l2cap/l2c_api.cc:982 L2CA_DisconnectReq: L2CAP - no CCB for L2CA_disc_req, CID: 92
05-29 10:05:30.515 15554 15626 I bt_btif_sock: packages/modules/Bluetooth/system/btif/src/btif_sock.cc:169 btif_sock_connection_logger: address=xx:xx:xx:xx:e8:52, role=5, state=2
05-29 10:05:30.515 15554 15697 E bt_btif_sock_rfcomm: packages/modules/Bluetooth/system/btif/src/btif_sock_rfc.cc:171 find_rfc_slot_by_id: find_rfc_slot_by_id unable to find RFCOMM slot id: 243
05-29 10:05:30.515 15554 15626 I l2c_link: packages/modules/Bluetooth/system/stack/l2cap/l2c_link.cc:251 l2c_link_hci_conn_comp: Disconnecting link handle:0xffff status:HCI_ERR_PAGE_TIMEOUT
05-29 10:05:30.515 15554 15626 W btm_acl : packages/modules/Bluetooth/system/stack/acl/btm_acl.cc:627 btm_acl_removed: Unable to find active acl
05-29 10:05:30.516 15554 15671 D BluetoothDataManager: BluetoothDataManager :: notifyConnectionFailReason() is called
05-29 10:05:30.517 15554 15671 D BluetoothAdapterService: getRemoteInfoForBigData :: Get Remote Device Information
05-29 10:05:30.525 25432 25449 I sidebandservice: [2024-05-29 10:05:30] [Error] The contained exception was: Could not connect to any Bluetooth devices

It seems like connection is tried to be made using Classic Bluetooth instead of BLE ? I'm able to connect to RNode using Serial Bluetooth Terminal and nRFConnect apps.

EDIT : In my case the problem is probably caused by using RAK4631. It have Nordic UART Service with UUID 6E400001-B5A3-F393-E0A9-E50E24DCCA9E, but AndroidBluetoothManager from RNodeInterface expects well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB. Anyway, both of them should be handled in Sideband as RAK4631 become supported board.

markqvist commented 6 months ago

BLE host connection for RNodes aren't "officially" supported in core RNS or Sideband yet. Both nRF and ESP32-S3 based boards are BLE only, and until a BLE-capable interface driver is merged into RNS, those devices are serial/USB only for now.

(except for some cases, for example on Linux, where you can indeed use BLE, and with some of the development versions that already have partially implemented BLE support)

markqvist commented 6 months ago

If you want to help out with the BLE support, take a look at the work going on over at the RNode Firmware CE repository!

shodan8192 commented 6 months ago

OK, thanks for clarifications. I'm already looking at new RNode repo :)