Open HarshalRathore opened 2 years ago
Did u find any fixes?
@MadFlasheroo7 no I haven't yet, waiting for the author of the project to respond.
This error could be caused by many reasons. Some devices are not supported by this script and some have issues. I need to have access to the specific device in order to debug and test.
You can try the workarounds mentioned in the readme file, maybe that fixes the issue.
Same issue here, would like to help on this although i can't send you a phone. Telegram @toxicbyte
The actual failure is when its trying to itterate through sock object:
result = None sock = RFCOMMSocket() sock.connect(self._bt_settings) for line in sock: if b"BRSF" in line:
I've been doing some smalll debugging and noticed the UUID isn't listed on my device (Galaxy S10 - OS: 9.0)
Here's what it lists though: UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb) UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb) UUID: PANU (00001115-0000-1000-8000-00805f9b34fb) UUID: NAP (00001116-0000-1000-8000-00805f9b34fb) UUID: Handsfree Audio Gateway (0000111f-0000-1000-8000-00805f9b34fb) UUID: Phonebook Access Server (0000112f-0000-1000-8000-00805f9b34fb) UUID: Message Access Server (00001132-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: Vendor specific (594a34fc-31db-11ea-978f-2e728ce88125) UUID: Vendor specific (a23d00bc-217c-123b-9c00-fc44577136ee)
Please contact me if you want help with resolving. I can help debug a bit.
Connection is opening and connecting: Under class SocketDataIterator return the received socket data is being held up. have tried different chunk sizes, etc. The AT commands are sending to the device using logcat I found: 01-30 11:32:36.776 1661 1661 I Telecom:SamsungGearCommand: sendSecBluetoothATCommand : DUAL,S****E
Any ideas why the socket is unable to receive data back?
EDIT: AT+BIEV= should be working, if not maybe this alternate will help? I don't understand your format. I'm used to doing soemthing like "AT+BIEV=" write to serial
Here's the AT command to fetch battery info via AT on samsung: AT+BATGETLEVEL? BATGETLEVEL=6 VOLT=4210mV
@P3nguin-M Good job with the debugging. Can you also sniff the commands using this trick and send me the capture file? Include your logcat as well.
@P3nguin-M Good job with the debugging. Can you also sniff the commands using this trick and send me the capture file? Include your logcat as well.
I just wanted to clarify -- I'm using this tool not to read battery but just communicate with bluetooth stack using linux PC with bluetooth USB chip and bluetoothctl. Although I believe it's sending the AT commands I am not seeing ANY in the log i dumped after connecting it to my machine and running your script on it. I get past the socket connection, but it freezes on the read.
This script is written only with battery level in mind. The commands which are being sent to the device might be wrong, and the device stops answering back. You can add debug prints to the program to see what is being sent/received. You can also look for similar commands in the logcat that you found before, and update the code.
This script is written only with battery level in mind. The commands which are being sent to the device might be wrong, and the device stops answering back. You can add debug prints to the program to see what is being sent/received. You can also look for similar commands in the logcat that you found before, and update the code.
I figured if i can get the bluetooth battery stuff working i can modify afterwards to send the AT commands i extracted from the device's firmware. Is there any other scripts that you know of that lets us do just that? Test AT commands without modifying yours? Also notice you don't use any "at+" commands but just the endings. How does that work?
The code is fairly small. You can remove all the battery stuff and replace your own commands. I don't remember any script that does what you want but there was a java app called 'AT Command Tester' I think.
Also notice you don't use any "at+" commands but just the endings. How does that work?
The headset sends commands with the 'at+' prefix but the response doesn't have that. We got these commands and their responses mostly by reading Bluetooth captures, and that's what we found there. I'm not an expert in this.
This error could be caused by many reasons. Some devices are not supported by this script and some have issues. I need to have access to the specific device in order to debug and test.
You can try the workarounds mentioned in the readme file, maybe that fixes the issue.
how can i contribute add support for my devices
@MadFlasheroo7 By capturing the Bluetooth connection from your phone and the headset, then analyzing the commands being sent/received. Then you can change code in order to support your device. It needs a lot of debugging and trial and error to get things working, plus there is no guarantee that it will work.
What mode is this bluetooth device supposed to be in? When i issue MAC.2 -> "Connected for calls" is shown. MAC.4 -> "Connected (Selected) Message Access". When i try MAC.3 -> Connecting then fails and reset by peer. MAC.2 & MAC.4 both stay connected but do not output any data from socket. I am now finding out the AT commands are going through while im on one of those modes 2/4. btsnoop log pasted below btsnoop_hci.log
What mode is this bluetooth device supposed to be in?
For Bluetooth headsets, we'll use the RFCOMM uuid to get the desired port number. Perhaps you can use the UUIDs that you have to find the port that suits your needs.
Pulled apart the bluetooth apk on this S10 i have and found the commands it will take:
sock = RFCOMMSocket()
sock.connect(self._bt_settings)
print(f'Socket connected..')
sock.send(b"AT+CSQ")
sock.send(b"AT+CGMI")
sock.send(b"AT+CGMM")
sock.send(b"AT+SSVOICE=1")
# Iterate received packets until there is no more or a result was found
for line in sock:
print(f'Socket Data: {line}')
output: Socket Data: b'\r\n+CSQ: 0,99\r\n' Returning data chunks.. Socket Data: b'\r\nOK\r\n' Returning data chunks.. Socket Data: b'\r\n+CGMI: samsung\r\n' Returning data chunks.. Socket Data: b'\r\nOK\r\n' Returning data chunks.. Socket Data: b'\r\n+CGMM: SM-G973U\r\n' Returning data chunks.. Socket Data: b'\r\nOK\r\n' Returning data chunks..
@MadFlasheroo7 By capturing the Bluetooth connection from your phone and the headset, then analyzing the commands being sent/received. Then you can change code in order to support your device. It needs a lot of debugging and trial and error to get things working, plus there is no guarantee that it will work.
Should my android device be rooted? And kindly tell the process to log commands too
Should my android device be rooted? And kindly tell the process to log commands too
No I don't think so. You can check this comment for more info.
interestingly, $ sudo apt-get install bluez* solved my problem (on kali (5.15.0-kali3-amd64) and Soundcore Life Q10 bluetooth headphone)
@TheWeirdDev I don't know if it's the right place where to post this, but I experience Errno 111
as well with my BT dongle. I thus created the file log with Android: btsnoop_hci.log
If you can't fix it yourself, can you guide me on how to do it myself? Thanks in advance!
@MadFlasheroo7: Should my android device be rooted? And kindly tell the process to log commands too
in my experience you have to. On my Android 11 it got saved in /data/misc/bluetooth/logs/
, not in sdcard
@carlocastoldi Your log file seems OK and the script should work, but the error 111 happens when the socket connection wasn't successful, so there was no way to send or receive commands.
Did you try changing the port number? Try to figure out why it can't connect, then you can check if commands work.
@TheWeirdDev I don't know if it's the right place where to post this, but I experience
Errno 111
as well with my BT dongle. I thus created the file log with Android: btsnoop_hci.logIf you can't fix it yourself, can you guide me on how to do it myself? Thanks in advance!
@MadFlasheroo7: Should my android device be rooted? And kindly tell the process to log commands too
in my experience you have to. On my Android 11 it got saved in
/data/misc/bluetooth/logs/
, not in sdcard
i actually got busy with my college stuff so once i root my device ill let u know
i have a Soundcore Anker Life Q20 i get this error on all but a few ports (tested 1 through 30, waiting a few seconds between tries) ports 13,18: when specifying these ports the script seems to just hang port 19 (and when not specifying any port): i get bluetooth.btcommon.BluetoothError: [Errno 16] Device or resource busy
this testing was done one a brand new pair, first thing i did upon receiving them in the mail was to pair and connect them to my computer and play some music on them while i did this testing
Installation is done with
yay -S python-bluetooth-battery
command run
bluetooth_battery $(bluetoothctl info | awk '/^Device/ {print $2}')
andsudo bluetooth_battery $(bluetoothctl info | awk '/^Device/ {print $2}')
Error received
---- Update ----
Tried Manual installation, returned with the same error
Also tried to run with docker, returned with the same error.
---- Conculsion ----
Problem lies in the project/script not in the underlying or user's OS.