Git Product home page Git Product logo

Comments (22)

P3nguin-M avatar P3nguin-M commented on June 2, 2024 1

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..

from bluetooth_headset_battery_level.

asandikci avatar asandikci commented on June 2, 2024 1

interestingly,
$ sudo apt-get install bluez*
solved my problem
(on kali (5.15.0-kali3-amd64) and Soundcore Life Q10 bluetooth headphone)

from bluetooth_headset_battery_level.

MadFlasheroo7 avatar MadFlasheroo7 commented on June 2, 2024

Did u find any fixes?

from bluetooth_headset_battery_level.

HarshalRathore avatar HarshalRathore commented on June 2, 2024

@MadFlasheroo7 no I haven't yet, waiting for the author of the project to respond.

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

P3nguin-M avatar P3nguin-M commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

P3nguin-M avatar P3nguin-M commented on June 2, 2024

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

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

@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.

from bluetooth_headset_battery_level.

P3nguin-M avatar P3nguin-M commented on June 2, 2024

@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.

btsnoop_hci.log

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.

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

P3nguin-M avatar P3nguin-M commented on June 2, 2024

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?

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

MadFlasheroo7 avatar MadFlasheroo7 commented on June 2, 2024

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

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

@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.

from bluetooth_headset_battery_level.

P3nguin-M avatar P3nguin-M commented on June 2, 2024

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

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

MadFlasheroo7 avatar MadFlasheroo7 commented on June 2, 2024

@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

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

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.

from bluetooth_headset_battery_level.

carlocastoldi avatar carlocastoldi commented on June 2, 2024

@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

from bluetooth_headset_battery_level.

TheWeirdDev avatar TheWeirdDev commented on June 2, 2024

@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.

from bluetooth_headset_battery_level.

MadFlasheroo7 avatar MadFlasheroo7 commented on June 2, 2024

@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

i actually got busy with my college stuff so once i root my device ill let u know

from bluetooth_headset_battery_level.

ask-compu avatar ask-compu commented on June 2, 2024

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

from bluetooth_headset_battery_level.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.