Debian 9 with kernel 4.4.55_3 http://wiki.banana-pi.org/Banana_Pi_BPI-M2%2B#Raspbian ``` bash # Install System sudo fdisk -l unzip 2018-11-09-debian-9-stretch-mate-desktop-preview-bpi-m2p-4.4-sd-emmc.img.zip sudo dd if=2018-11-09-debian-9-stretch-mate-desktop-preview-bpi-m2p-sd-emmc.img of=/dev/mmcblk1 bs=10MB # Bluetooth Setup sudo apt install libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.49.tar.xz tar -xf bluez-5.49.tar.xz cd bluez-5.49/ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental make -j4 sudo make install sudo adduser pi bluetooth sudo cp /etc/dbus-1/system.d/bluetooth.conf /etc/dbus-1/system.d/bluetooth.conf.bak sudo nano /etc/dbus-1/system.d/bluetooth.conf #add the #comment lines to the bluetooth.conf without the # # # # # # # # # sudo reboot rfkill list 0: sunxi-bt: Bluetooth Soft blocked: no Hard blocked: no 1: phy0: Wireless LAN Soft blocked: yes Hard blocked: no 2: brcmfmac-wifi: Wireless LAN Soft blocked: yes Hard blocked: no 4: hci0: Bluetooth Soft blocked: yes Hard blocked: no rfkill unblock bluetooth 0: sunxi-bt: Bluetooth Soft blocked: no Hard blocked: no 1: phy0: Wireless LAN Soft blocked: yes Hard blocked: no 2: brcmfmac-wifi: Wireless LAN Soft blocked: yes Hard blocked: no 4: hci0: Bluetooth Soft blocked: no Hard blocked: no bluetoothctl power on agent on scan on # wait few seconds scan off pair 00:0B:CE:04:F6:66 #Attempting to pair with 00:0B:CE:04:F6:66 #Request PIN code #[blue1m[agent] Enter PIN code: 0000 #[CHG] Device 00:0B:CE:04:F6:66 Connected: yes #[CHG] Device 00:0B:CE:04:F6:66 UUIDs: 00001101-0000-1000-8000-00805f9b34fb #[CHG] Device 00:0B:CE:04:F6:66 ServicesResolved: yes #[CHG] Device 00:0B:CE:04:F6:66 Paired: yes #Pairing successful info 00:0B:CE:04:F6:66 #Device 00:0B:CE:04:F6:66 (public) # Name: BAmobile # Alias: BAmobile # Class: 0x00001f00 # Paired: yes # Trusted: no # Blocked: no # Connected: no # LegacyPairing: yes # UUID: Serial Port (00001101-0000-1000-8000-00805f9b34fb) sudo rfcomm bind 0 00:0B:CE:04:F6:66 sudo rfcomm show /dev/rfcomm0 0 #rfcomm0: 00:0B:CE:04:F6:66 channel 1 clean #test send sudo python3 -c 'print("\26\01\62\65\72\6c\69\6e")' > /dev/rfcomm #test empfang cat /dev/rfcomm0 sudo apt-get install python3-dev sudo apt install python3-pip python3 -m pip install setuptools python3 -m pip install wheel python3 -m pip install pybluez sudo apt autoremove # Python serial bluetooth transmitter / receiver sudo nano /etc/systemd/system/dbus-org.bluez.service changing ExecStart=/usr/lib/bluetooth/bluetoothd into ExecStart=/usr/lib/bluetooth/bluetoothd -C sudo sdptool add SP nano send_serial_bluetooth.py # Python Code Start #!/usr/bin/env python3 import sys import bluetooth addr = none if len(sys.argv) < 2: print("No device specified. Searching all nearby bluetooth devices for " "the SampleServer service...") else: addr = sys.argv[1] print("Searching for SampleServer on {}...".format(addr)) # search for the SampleServer service uuid = "00001101-0000-1000-8000-00805f9b34fb" service_matches = bluetooth.find_service(uuid=uuid, address=addr) if len(service_matches) == 0: print("Couldn't find the SampleServer service.") sys.exit(0) first_match = service_matches[0] port = first_match["port"] name = first_match["name"] host = first_match["host"] print("Connecting to \"{}\" on {}".format(name, host)) # Create the client socket sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) sock.connect((host, port)) print("Connected. Type something...") while True: data = input() if not data: break sock.send(data) sock.close() # Python Code End sudo hciconfig hci0 piscan nano receive_serial_bluetooth.py # Python Code Start #!/usr/bin/env python3 import bluetooth server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) server_sock.bind(("", bluetooth.PORT_ANY)) server_sock.listen(1) port = server_sock.getsockname()[1] uuid = "00001101-0000-1000-8000-00805f9b34fb" bluetooth.advertise_service(server_sock, "SampleServer", service_id=uuid, service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS], profiles=[bluetooth.SERIAL_PORT_PROFILE], # protocols=[bluetooth.OBEX_UUID] ) print("Waiting for connection on RFCOMM channel", port) client_sock, client_info = server_sock.accept() print("Accepted connection from", client_info) try: while True: data = client_sock.recv(1024) if not data: break print("Received", data) except OSError: pass print("Disconnected.") client_sock.close() server_sock.close() print("All done.") # Python Code End ```