androidbluetoothpairinghci

Getting around pairing pin exchange on an android system without GUI and HAL


On an Android System without a bluetooth-hal and only hciconfig, hcitool, sdptool and rfcomm I want to pair host and device (host: Asus BT400 dongle). On the Android system I do

hciconfig hci0 up
hciconfig hci0 sspmode 1
sdptool add SP
rfcomm ...

on the host I start bluetoothctl and do

power on
agent on
default-agent
scan on
pair <bd-addr>

however now I am asked for the PIN.

The target Andoid has no bluetooth-hal and no GUI, there is no pin diablog. Still I would like to retrieve the pin for this system so that I can pair from the host.

Can I retrieve the PIN via commandline?

Can I recompile the Android kernel and printk() the pin if somebody knows the place where it appears?

I cannot use any other bluez tools other than the available hciconfig, hcitool, sdptool and rfcomm but if there is some ioctl() or socket to connect to to watch for the pin appearing I could maybe write my own c-snippet? Where is the place to look for a template for such a util?

What is the easiest way?


Solution

  • I also compiled btmgmt on target. With btmgmt running both on target and host I can start a pairing cycle from console and enter PIN in console. Looking into the sourceode of btmgmt it seems possible to automate the pairing by watching for MGMT_OP_PIN_CODE_REPLY event and sending MGMT_EV_PIN_CODE_REQUEST to automate it.