RPi Bluetooth
hello
Contents |
Bluetooth
Scanning BLE
Scanning BLE is from https://elinux.org/RPi_Bluetooth_LE
device testing
- Check what devices you've got
- lsusb
- Basic installation checks: The Pi 3's built-in Bluetooth adapter is called hci0. You can check it is operating correctly with the command:
- hciconfig
- If you are on a laptop two(2) hci devices will show up, the first one is buggy
- hciconfig hci0 down
- Now you can try scanning for BLE devices
- hcitool lescan
Python programs
- do stuff
- sudo apt-get install python-pip
- sudo apt-get install libglib2.0-dev
- sudo pip install bluepy
- blescan
Creating a channel, capable of 6lowPAN (IPv6)
Reading http://blog.bluetooth.com/bluetooth-meet-the-internet-internet-say-hello-to-bluetooth you find that BLE uses Generic Attribute Profile (GATT) which is modular, and not Generic Access Profil (GAP) which is static and used by Bluetooth Classic.
GATT has many forms of which one is Internet Protocol Support Profile (IPSP) (Beware of HTTP Proxy Service (HPS) which is something completely different
Picture http://blog.bluetooth.com/~/media/images/blog%20images/migrated/smarthomerouter-01.ahsx (IPv6-BLE switch -> Gateway -> IPv6-Wifi-Bulb == All Native IPv6)
Command for setting what I am (IPSP) Command for viewing other end capabilities (IPSP ??)
Setting an IPv6 address
following the lowpan 802.15.4 blog
- add
- apt-get install libnl-3-dev
- This is a strange page
- https://devzone.nordicsemi.com/f/nordic-q-a/14292/iot-sdk-rpi3---using-jessie-with-bluetooth_6lowpan
- that says:
- root@raspberry:/home/pi#
- root@raspberry:/home/pi# lsmod | grep 6lo
- root@raspberry:/home/pi# modprobe bluetooth_6lowpan
- root@raspberry:/home/pi# echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
- root@raspberry:/home/pi# modprobe bluetooth_6lowpan
- root@raspberry:/home/pi# lsmod | grep 6lo
- bluetooth_6lowpan 24576 0
- 6lowpan 36864 8 nhc_udp,nhc_routing,nhc_mobility,bluetooth_6lowpan,nhc_fragment,nhc_dest,nhc_hop,nhc_ipv6
- bluetooth 552960 32 btrtl,bluetooth_6lowpan,btintel,bnep,btbcm,rfcomm,btusb
- root@raspberry:/home/pi#
- Another page
Now to establish my Bluetooth connection between the Raspberry Pis I run though the following steps: On the Master device I run the following commands:
#need root access sudo su #enable 6lowpan over Bluetooth le echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable #start advertising Bluetooth LE service hciconfig hci0 leadv
On the Slave device I run the following commands:
#need root access sudo su #enable 6lowpan over Bluetooth le echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable #establish le connection to master hcitool lecc 5C:F3:70:XX:XX:XX
The hcitool lecc command always returns “Connection Handle 64”. At this point I have a stable connection between the two devices that I can verify using the hcitool con command.
I am now able to run the following command on either the master or the slave where the mac address is the address for the Bluetooth device I am connecting too:
echo “connect 5C:F3:70:XX:XX:XX 1” > /sys/kernel/debug/bluetooth/6lowpan_control
Whichever Raspberry Pi I run the command on establishes a 6lowpan connection and if I run the ifconfig command I see a new bt0 device.
Programming in python
från tysk sida
https://forum.fhem.de/index.php?topic=68019.15
Hi und danke erstmal, bin jetzt soweit mit fast allen befehlen durch Code: [Auswählen] pi@raspberrypi:~ $ ls -l /dev/ser* lrwxrwxrwx 1 root root 7 Feb 28 23:59 /dev/serial0 -> ttyAMA0 lrwxrwxrwx 1 root root 5 Feb 28 23:59 /dev/serial1 -> ttyS0 das sieht schon mal gut aus, lt. deinem Howto allerdings bekomme ich dennoch kein Device : Code: [Auswählen] pi@raspberrypi:~ $ hcitool dev Devices: pi@raspberrypi:~ $ hcitool scan Device is not available: No such device pi@raspberrypi:~ $ glaub bin zu müde oder zu blind. habt Ihr eine Idee ?? danke
pi@raspberrypi:~ $ systemctl status bluetooth ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled) Active: active (running) since Do 2017-03-09 22:05:23 CET; 22s ago Docs: man:bluetoothd(8) Main PID: 794 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service └─794 /usr/lib/bluetooth/bluetoothd pi@raspberrypi:~ $ sudo service bluetooth status ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled) Active: active (running) since Do 2017-03-09 22:05:23 CET; 27s ago Docs: man:bluetoothd(8) Main PID: 794 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service └─794 /usr/lib/bluetooth/bluetoothd pi@raspberrypi:~ $ sudo hciconfig dev Can't get device info: No such device pi@raspberrypi:~ $ sudo bluetoothctl [bluetooth]# agent on Agent registered [bluetooth]# default-agent Default agent request successful [bluetooth]# scan on No default controller available [bluetooth]# exit Agent unregistered pi@raspberrypi:~ $ dmesg | grep Blue [ 22.873317] Bluetooth: Core ver 2.22 [ 22.873369] Bluetooth: HCI device and connection manager initialized [ 22.873381] Bluetooth: HCI socket layer initialized [ 22.873389] Bluetooth: L2CAP socket layer initialized [ 22.873408] Bluetooth: SCO socket layer initialized [ 103.040851] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 103.040860] Bluetooth: BNEP filters: protocol multicast [ 103.040871] Bluetooth: BNEP socket layer initialized
so alles was mit Bluetooth zu tun hat gelöscht und folgendes getan Code: [Auswählen] sudo apt-get install raspberrypi-sys-mods sudo apt-get --reinstall install pi-bluetooth sudo shutdown -r now dann Code: [Auswählen] sudo systemctl start hciuart.service pi@raspberrypi:~ $ systemctl status hciuart.service ● hciuart.service - Configure Bluetooth Modems connected by UART Loaded: loaded (/lib/systemd/system/hciuart.service; disabled) Active: active (running) since Fr 2017-03-10 00:17:11 CET; 5s ago Process: 951 ExecStart=/usr/bin/btuart (code=exited, status=0/SUCCESS) Main PID: 962 (hciattach) CGroup: /system.slice/hciuart.service └─962 /usr/bin/hciattach /dev/serial1 bcm43xx 460800 noflow - und siehe da!!! Code: [Auswählen] pi@raspberrypi:~ $ hcitool dev Devices: hci0 B8:27:EB:90:BC:6D es geht!! danke an alle!