# Sharing internet to phone via bluetooth



## hedgehog (Mar 23, 2011)

Greetings. I'm trying to share internet connection from my desktop PC to SE K800i phone using btpand. Everything seems working untill the following error appears in /var/log/messages:

```
Mar 22 13:49:06 lair kernel: ng_l2cap_l2ca_receive: ubt0l2cap - unexpected L2CAP data packet. Invalid channel state, cid=65, state=5
Mar 22 13:49:42 lair last message repeated 6 times
Mar 22 13:51:49 lair last message repeated 36 times
Mar 22 14:01:52 lair last message repeated 54 times
```

When it happens, there is only arp requests and replies on the tap0 interface which is created by btpand and internet on the phone isn't available:

```
00:00:00.139084 00:1f:e4:dc:9f:5c > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 192.168.251.2 tell 192.168.251.15, length 46
00:00:00.000022 00:15:83:15:a2:56 > 00:1f:e4:dc:9f:5c, ethertype ARP (0x0806), length 42: Reply 192.168.251.2 is-at 00:15:83:15:a2:56, length 28
00:00:00.999971 00:1f:e4:dc:9f:5c > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 192.168.251.2 tell 192.168.251.15, length 46
00:00:00.000027 00:15:83:15:a2:56 > 00:1f:e4:dc:9f:5c, ethertype ARP (0x0806), length 42: Reply 192.168.251.2 is-at 00:15:83:15:a2:56, length 28
00:00:02.715897 00:1f:e4:dc:9f:5c > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 192.168.251.2 tell 192.168.251.15, length 46
00:00:00.000028 00:15:83:15:a2:56 > 00:1f:e4:dc:9f:5c, ethertype ARP (0x0806), length 42: Reply 192.168.251.2 is-at 00:15:83:15:a2:56, length 28
00:00:00.996936 00:1f:e4:dc:9f:5c > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 192.168.251.2 tell 192.168.251.15, length 46
00:00:00.000030 00:15:83:15:a2:56 > 00:1f:e4:dc:9f:5c, ethertype ARP (0x0806), length 42: Reply 192.168.251.2 is-at 00:15:83:15:a2:56, length 28
00:00:00.998979 00:1f:e4:dc:9f:5c > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 192.168.251.2 tell 192.168.251.15, length 46
00:00:00.000030 00:15:83:15:a2:56 > 00:1f:e4:dc:9f:5c, ethertype ARP (0x0806), length 42: Reply 192.168.251.2 is-at 00:15:83:15:a2:56, length 28
```

192.168.251.2 is tap0, 192.168.251.15 - phone. To fix this I have to plug-out and then plug-in BT adapter back to the usb port and it starts to work again.

I use btpand to share connection to previously paired phone:
`# btpand -d ubt0 -s NAP -l 100 -i tap0`
`# ifconfig tap0 inet 192.168.251.2/24`

I can't assign an IP adress to the phone manually, so I've set up DHCP:

```
subnet 192.168.251.0 netmask 255.255.255.0 {
  range 192.168.251.20 192.168.251.100;
  option domain-name-servers 8.8.8.8;
  option routers 192.168.251.2;
  option broadcast-address 192.168.251.255;
  default-lease-time 6000;
  max-lease-time 72000;
}

host k800 {
  hardware ethernet 00:1f:e4:dc:9f:5c;
  fixed-address 192.168.251.15;
}
```

Internet is shared via NAT (pf):

```
nat pass log on vr0 from tap0:network to any -> vr0
```


```
$ uname -srm
FreeBSD 8.2-RELEASE amd64
```

BT adapter:

```
Mar 22 13:20:14 lair root: Unknown USB device: vendor 0x0a12 product 0x0001 bus uhub0
Mar 22 13:20:14 lair kernel: ugen0.3: <vendor 0x0a12> at usbus0
Mar 22 13:20:14 lair kernel: ubt0: <vendor 0x0a12 product 0x0001, class 224/1, rev 1.10/1.34, addr 3> on usbus0
```


----------



## BrockyL (Jun 27, 2014)

My cheesy Android does this too but the only reason it does is because it tries to authenticate the internet connection in a really weird way, using a third party I do not know, and when it gets a host not found or just no DHCP ack for 30 seconds it disconnects and the ubt() driver gets hung because of it. In retort I would like to see the Atheros firmware debugged.


----------

