Desktop dock A2DP

Search This thread

ghimus

Member
Jan 4, 2011
5
0
Initial debugging

I've actually downloaded all the android source tree and started grepping for bluetooth, docking, nexus, etc.

I've arrived at BluetoothService.java that contains an interesting method called "writeDockPin".
From what I can decode the Nexus One generates a pseudo random PIN then sends it to the dock for pairing.

The dock actually has its own directory on the phones' filesystem at "/sys/class/switch/dock" where two interesting files are found: bt_addr and bt_pin.

When I dock the phone, 'bt_addr' is written with the dock's bluetooth hardware address and 'state' turns to 1.

'bt_pin' is a special file which I couldn't manage to read using the standard linux utilities.

I wanted to see what happens in that directory when you first dock the phone (initial pairing). I found a nice apk called FileObserver that only shows that certain files were indeed read, written to, deleted or closed.

The initial pairing made FileObserver output this:
Code:
bt_addr is opened
/sys/devices/virtual/switch/dock/bt_addr is accessed/read
bt_addr is closed
/sys/devices/virtual/switch/dock/bt_pin is modified
bt_pin is opened
/sys/devices/virtual/switch/dock/bt_pin is modified
/sys/devices/virtual/switch/dock/bt_pin is written and closed

Now I'm not a programmer so I might have a hard time investigating this further. I'm very curious to 'see' the changes made to bt_pin.

I suspect that if we could somehow spoof the Nexus One's bluetooth hardware address to match that of the computer, then have it initiate the pairing and continue it on the computer, it might actually work.

Another suspicion I have is that it might be necessary to build a mock phone with the 3 pins, that's connected to a computer, dock it, and have it negotiate the PIN with the Dock.

Either way it seems amazingly difficult to get the initial pairing working. Am I missing something here?

P.S.: PM for links to FileObserver and/or Android sources location.
 

burnduck

Senior Member
May 23, 2010
82
20
Ealing, London
After some trial and error i can confirm I managed to pair the Nexus One Dock with my Mac computer.

The key to making it pair up with other devices would be the timing when the Dock makes itself visible to other devices, and it only does it for a split second when the phone is being inserted.

I tried to scan for the dock with a Nexus 4 as soon as my Nexus One is plugged in to no avail. I resorted to the "Setup Bluetooth Device" feature on my mac, since it constantly searches for new devices. Once I popped the phone onto the dock, the dock came up and all I need to do to pair it up was to pair it up with no passcode at all.

Audio playback works but I noticed some very slight distortion and jitter. Not sure what is causing it but it proves pairing is possible with other devices, but the trick is to make it reveal itself (make visible).

rjg


rjf


---------- Post added at 03:42 PM ---------- Previous post was at 03:28 PM ----------

I managed to get the dock to show up in my Nexus 4 bluetooth settings by pairing and unpairing the N1 with the dock.

However I am unable to proceed further since the dock doesn't seem to support pairing without passcode.
I tried 0000 and 1234 and unfortunately didn't work. :(

rjj


rjl
 

gwsxda

New member
Jun 24, 2010
4
2
works with my galaxy s 4 / hacks

I'm not entirely sure what the magic recipe is, but my N1 dock is working for A2DP at the moment, playing music from my stock Galaxy S 4.

I poked around a bit; with sshdroid running on my (rooted/CM) N1, here are the approximate-ish steps I took. These steps may not be an exact reproduction of what I did, and contain no timing information.

- N1: in docking station (paired, connected)
- N1: cd /sys/devices/virtual/switch/dock
- N1: cat bt_addr -> valid dock BT addr -> looks good
- N1: cat bt_pin -> cat: read error: I/O error
- N1: echo 0000 > bt_pin
- N1: disable bluetooth (still in dock)
- S4: enable bluetooth & scan
- S4: magic! the N1 dock showed up; I paired with it, connected to it...

unplugged it, moved it to my room with a stereo, and I was able to connect to it from my S4 with no problem.

I'm not actually convinced that writing to the pin did anything. It may have just been the act of scanning for it while the N1 was docked... or a lucky guess. I tend to have good luck with embedded devices. ;) Either way, I'm not going to mess with it further at this point.

-g
 

zeus_chingon

Senior Member
Apr 2, 2010
96
16
Houston
Your method worked perfectly for my Nexus One Desktop Dock with my Nexus 7 2013. You have no idea how long I have been trying to pair the desktop dock with my other devices. At one time I manually tried 5000 pins to no avail. Tomorrow I'll give it a try with my Car Dock, hopefully it will work too, I'll like to inject some new life to that poor car dock.


I'm not entirely sure what the magic recipe is, but my N1 dock is working for A2DP at the moment, playing music from my stock Galaxy S 4.

I poked around a bit; with sshdroid running on my (rooted/CM) N1, here are the approximate-ish steps I took. These steps may not be an exact reproduction of what I did, and contain no timing information.

- N1: in docking station (paired, connected)
- N1: cd /sys/devices/virtual/switch/dock
- N1: cat bt_addr -> valid dock BT addr -> looks good
- N1: cat bt_pin -> cat: read error: I/O error
- N1: echo 0000 > bt_pin
- N1: disable bluetooth (still in dock)
- S4: enable bluetooth & scan
- S4: magic! the N1 dock showed up; I paired with it, connected to it...

unplugged it, moved it to my room with a stereo, and I was able to connect to it from my S4 with no problem.

I'm not actually convinced that writing to the pin did anything. It may have just been the act of scanning for it while the N1 was docked... or a lucky guess. I tend to have good luck with embedded devices. ;) Either way, I'm not going to mess with it further at this point.

-g
 
Last edited:

zeus_chingon

Senior Member
Apr 2, 2010
96
16
Houston
It works with the Nexus Car Dock too. I managed to pair my Nexus 7 2013 with both docks. A dock can only have one device connected at a time, but the pairing remains functional for both (Nexus One, Nexus 7 2013).
 
Last edited:

gwsxda

New member
Jun 24, 2010
4
2
Excellent! I'm so glad I could help! I wasn't sure if you could pair multiple devices, but that's also very useful knowledge.

If you can post an updated script with the minimal number of steps to make it work, I'm sure that would be helpful to someone else!

Let's breath some new life into these old-but-still-useful gadgets!

-g


It works with the Nexus Car Dock too. I managed to pair my Nexus 7 2013 with both docks. A dock can only have one device connected at a time, but the pairing remains functional for both (Nexus One, Nexus 7 2013).
 

zeus_chingon

Senior Member
Apr 2, 2010
96
16
Houston
The steps you gave are pretty much all needed. The only one that can be skipped would be "cat bt_pin". I can't see how to improve on that.
The last hurdle to overcome is to enable the pairing without needing a working Nexus One.
 

gcbxda

Senior Member
Jan 5, 2009
227
17
California
The steps you gave are pretty much all needed. The only one that can be skipped would be "cat bt_pin". I can't see how to improve on that.
The last hurdle to overcome is to enable the pairing without needing a working Nexus One.

guys can i have more information on what kernel/image you were using at the time?

mine has stock kernel i guess, and CM7 (latest nightly they released)

i did the steps. did have to get root to write to bt_pin tho.

and nothing works.

trying to connect a nexus 5. nothing shows up when i disable bluetooth on the N1 still on the dock.

---------
Edit:

Success! some more information.

to read the original pin, not really usefull, you have to implement the interface on the kernel. http://stackoverflow.com/questions/...ice-attribute-fails-with-error-invalid-length

There is a setting "fast connect" under bluetooth, that must be off.

and it only worked for me after:
1. N1 on dock
2. bluetooth on
3. set pin to 0000 (i used terminal emulator. and i have to `su` before i can write the file)
4. turn bluetooth off
5. set pin to 0000 again.

only after i set the pin AFTER bluetooth off, i was able to see the bt_addr device on the N5.

also one caveat to pay attention. i tried setting the pin AFTER removing the phone from the dock. after that i can't pair it even with the N1. but it resolved after a reboot (thankfully /sys is read only :) that is why i try setting the pin before turning bt off. may not be necessary, but doesn't hurt and i was trying to avoid yet another reboot...

thanks everyone for this thread :)
 
Last edited:

zeus_chingon

Senior Member
Apr 2, 2010
96
16
Houston
guys can i have more information on what kernel/image you were using at the time?

mine has stock kernel i guess, and CM7 (latest nightly they released)

i did the steps. did have to get root to write to bt_pin tho.

and nothing works.

trying to connect a nexus 5. nothing shows up when i disable bluetooth on the N1 still on the dock.

---------
Edit:

Success! some more information.

to read the original pin, not really usefull, you have to implement the interface on the kernel. http://stackoverflow.com/questions/...ice-attribute-fails-with-error-invalid-length

There is a setting "fast connect" under bluetooth, that must be off.

and it only worked for me after:
1. N1 on dock
2. bluetooth on
3. set pin to 0000 (i used terminal emulator. and i have to `su` before i can write the file)
4. turn bluetooth off
5. set pin to 0000 again.

only after i set the pin AFTER bluetooth off, i was able to see the bt_addr device on the N5.

also one caveat to pay attention. i tried setting the pin AFTER removing the phone from the dock. after that i can't pair it even with the N1. but it resolved after a reboot (thankfully /sys is read only :) that is why i try setting the pin before turning bt off. may not be necessary, but doesn't hurt and i was trying to avoid yet another reboot...

thanks everyone for this thread :)

I'm glad you got it working. I believe I used the stock CM kernel.
ebydevab.jpg


Sent from my Nexus 5 using Tapatalk
 
Last edited:

gwsxda

New member
Jun 24, 2010
4
2
My N1 has a horribly cracked screen - but thank goodness I:

1) kept my broken N1 around, and
2) wrote my notes down in the form of a post.

I've referred to my own post here countless times - pretty much every time I wipe another phone and try to use it for music! :D
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    works with my galaxy s 4 / hacks

    I'm not entirely sure what the magic recipe is, but my N1 dock is working for A2DP at the moment, playing music from my stock Galaxy S 4.

    I poked around a bit; with sshdroid running on my (rooted/CM) N1, here are the approximate-ish steps I took. These steps may not be an exact reproduction of what I did, and contain no timing information.

    - N1: in docking station (paired, connected)
    - N1: cd /sys/devices/virtual/switch/dock
    - N1: cat bt_addr -> valid dock BT addr -> looks good
    - N1: cat bt_pin -> cat: read error: I/O error
    - N1: echo 0000 > bt_pin
    - N1: disable bluetooth (still in dock)
    - S4: enable bluetooth & scan
    - S4: magic! the N1 dock showed up; I paired with it, connected to it...

    unplugged it, moved it to my room with a stereo, and I was able to connect to it from my S4 with no problem.

    I'm not actually convinced that writing to the pin did anything. It may have just been the act of scanning for it while the N1 was docked... or a lucky guess. I tend to have good luck with embedded devices. ;) Either way, I'm not going to mess with it further at this point.

    -g