apt-get install bluetooth bluez (on server and client)
First check for bdaddr on server and client:
Server:> hcitool dev
Devices:
hci0 00:01:1A:63:49:33
Client:> hcitool dev
Devices:
hci0 00:02:6E:53:42:78
Pairing:
Server:> /usr/share/doc/bluez/examples/test-adapter discoverable on
Server:> /usr/share/doc/bluez/examples/simple-agent
Client:> /usr/share/doc/bluez/examples/simple-agent 00:02:6E:53:42:78 00:01:1A:63:49:33
Hint: On newer systems use /usr/bin/bluez-test-adapter, /usr/bin/bluez-simple-agent and bluez-test-network
On Server:
Agent registered
RequestPinCode (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78)
Enter PIN Code: 1234
(keep simple-agent running)
On Client:
RequestPinCode (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)
Enter PIN Code: 1234
Release
New device (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)
Pairing keys are stored hashed in /var/lib/bluetooth/<local bdaddr>/linkkeys
Network:
--- /usr/share/doc/bluez/examples/test-networkClient:> /usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33
+++ /usr/share/doc/bluez/examples/test-network.sh
@@ -35,9 +35,10 @@
print "Press CTRL-C to disconnect"
try:
- time.sleep(1000)
- print "Terminating connection"
+ while 1:
+ time.sleep(1000)
except:
pass
+print "Terminating connection"
network.Disconnect()
(keep test-network running)
On Server:
Authorize (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78, 0000000f-0000-1000-8000-00803f9b24fa)
Authorize connection (yes/no): yes
Now you can stop simple-agent.
Server:> ifconfig ifconfig bnep0 192.168.0.1 netmask 255.255.255.0 up
Client:> ifconfig ifconfig bnep0 192.168.0.2 netmask 255.255.255.0 up
Now you can ping each other.
To avoid start simple-agent on server for connection authorisation each time you can trust the client with:
Server:> /usr/share/doc/bluez/examples/test-device trusted 00:01:1A:63:49:33 on
Automatisation:
On my server i'm running a bridged network with dhcp support, therefore i use udev to add bnep to my bridge:
/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/sbin/brctl addif br0 %k"
Client:
/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/sbin/dhclient -nw -pf /var/run/dhclient-%k.pid %k"
ACTION=="remove", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/bin/pkill -9 dhclient"
maybe you need to reload udev!
On clientside you only have to keep running
/usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33
Usually this should be done by networkmanager but this is not supported (now)
[ view entry ] ( 2633 views ) | print article
<<First <Back | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Next> Last>>