RPi Bluetooth
hello
Contents |
Bluetooth
SLAVE
modprobe bluetooth_6lowpan lsmod | grep 6low #gives three (3) lines echo "1" > /sys/kernel/debug/bluetooth/6lowpan_enable lsmod | grep 6low #gives three (4) lines; now includes ipv6 -> 6lowpan #rename hci0 to "whatever" hciconfig hci0 name rpi-slave # doing "hcitool lescan" on a third comupter shows nothing # this cammand is undocumented ?!? hciconfig hci0 leadv # the slave now shows up as BCM43438A1
MASTER
modprobe bluetooth_6lowpan lsmod | grep 6low #gives three (3) lines echo "1" > /sys/kernel/debug/bluetooth/6lowpan_enable lsmod | grep 6low #gives three (4) lines; now includes ipv6 -> 6lowpan hciconfig hci0 name Master #Use address of other side's hci0 (Low Energy Create Connexion) hcitool lecc B8:27:EB:C1:E9:42 # lecc should return "connection handle 65" sleep 5 echo "connect B8:27:EB:C1:E9:42" > /sys/kernel/debug/bluetooth/6lowpan_control #still nothing in ifconfig ifconfig bt0 up ifconfig # Finally!
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 (use hciconfig -a for more details)
root@raspberrypi:/home/pi# lsusb Bus 001 Device 004: ID 0461:4d51 Primax Electronics, Ltd 0Y357C PMX-MMOCZUL (B) [Dell Laser Mouse] Bus 001 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard Bus 001 Device 002: ID 0424:2412 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The BLE adapter is not on the USB-bus in rPi Zero W !!
root@raspberrypi:/home/pi# hciconfig -a hci0: Type: Primary Bus: UART BD Address: B8:27:EB:C1:E9:42 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:1469 acl:0 sco:0 events:89 errors:0 TX bytes:4405 acl:0 sco:0 commands:89 errors:0 Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'raspberrypi' Class: 0x6c0000 Service Classes: Rendering, Capturing, Audio, Telephony Device Class: Miscellaneous, HCI Version: 4.1 (0x7) Revision: 0x168 LMP Version: 4.1 (0x7) Subversion: 0x2209 Manufacturer: Broadcom Corporation (15) root@raspberrypi:/home/pi#
- 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
has GATTOOL anything to do with it ??
gatttool
https://elinux.org/RPi_Bluetooth_LE#Connecting_with_gatttool
Creating a channel, capable of 6lowPAN (IPv6)
[RFC7668] "IPv6 over Bluetooth LE is dependent on both Bluetooth 4.1 and IPSP 1.0 or ..."
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)
lsmod | grep 6lo modprobe bluetooth_6lowpan echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable modprobe bluetooth_6lowpan 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 ipv6 401548 29 6lowpan
hciconfig hci0 lestates YES Non-connectable Advertising State < 20 more lines > hciconfig hci0 leadv LE set advertise enable on hci0 returned status 12
> #hciconfig hci0 lestates > Read LE supported states on hci0 returned status 12 Yep, 0x0c or 12 is for unsupported command. So the fw doesn't seem to have support for LE. Let me get back to you on this, need to check up what fw is upon the repository.
Note If using a Linux kernel version less than 4.0, the kernel debug file 6lowpan_enable will not be present. Instead you should use "echo 35 > /sys/kernel/debug/bluetooth/6lowpan_psm" to set PSM channel as 0x23 (35), and enable the bluetooth 6lowpan module.
Command for viewing other end capabilities (IPSP ??)
hcitool lescan LE Scan ... CB:AF:14:57:D8:6E (unknown) CB:AF:14:57:D8:6E Test IPSP node \-- from http://docs.zephyrproject.org/samples/bluetooth/ipsp/README.html
Local setup: NOT WORKING !!
#!/bin/sh . ./ibeacon.conf echo "Launching virtual iBeacon..." sudo hciconfig $BLUETOOTH_DEVICE up sudo hciconfig $BLUETOOTH_DEVICE noleadv sudo hciconfig $BLUETOOTH_DEVICE leadv 0 sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 $UUID $MAJOR $MINOR $POWER 00 00 00 00 00 00 00 00 00 00 00 00 00 echo "Complete"
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
Windows 10: Check BLE Version
The LMP versions correspond to Bluetooth versions as follows: LMP 0.x - Bluetooth 1.0b LMP 1.x - Bluetooth 1.1 LMP 2.x - Bluetooth 1.2 LMP 3.x - Bluetooth 2.0 + EDR LMP 4.x - Bluetooth 2.1 + EDR LMP 5.x - Bluetooth 3.0 + HS LMP 6.x - Bluetooth 4.0 LMP 7.x - Bluetooth 4.1 LMP 8.x - Bluetooth 4.2 LMP 9.x - Bluetooth 5.0 Source: https://superuser.com/questions/502825/how-can-i-find-out-what-version-of-bluetooth-my-laptop-supports
LÄNKAR
- DEBUGGING: hcidump -t -x
- SoC or Dongle ??: MakerSpot CC2640 Bluetooth Low Energy BLE 5.0 USB HID Dongle (Backward compatible with BLE 4.0 / 4.1 / 4.2)
Firmware
- https://fwupd.org/lvfs/vendorlist
- Asus BT400 has BMC 20702 chipset according to
- Firmware upgrade: CSR (BlueSuite 2.4 --
- Firmware Update: UG216 (over SPI ??)
- Firmware Upgrade BroadCom BCM 20702
- SONY: Bluetooth Firmware (Broadcom) Update version 2.2.3.593.596a (Windows 7 64bit)
- SuperUser: Bluetooth 6LoWPAN connection between two Raspberry Pis
- BASH Script
- Dokumentation BLE ? (bluetooth.org)
+Start advertising with EIR data (__Linux only__): + + var scanData = new Buffer(...); // maximum 31 bytes + var advertisementData = new Buffer(...); // maximum 31 bytes + + bleno.startAdvertisingWithEIRData(advertisementData, scanData[, callback(error)]); + + * For EIR format section [Bluetooth Core Specification](https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=229737) sections and 8 and 18 for more information the data format.
- 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!