Bluetooth on the RAK 7246 Gateway

I would like to use the Bluetooth functionality of the Raspberry Pi Zero W which is part of the RAK 7246 gateway but it seems to be disabled. Even after enabling in the boot configuration it isn’t available. I fear that the ports are shared with the LoRa hat. Is there any chance to get Bluetooth working?

Remove the line "dtoverlay = disable-bt" from /boot/config.txt.

I’ve done that and rebooted afterwards. But no change.

[email protected]:~# lsmod | grep bt
btbcm                  16384  0
bluetooth             409600  8 bnep,btbcm
[email protected]:~# lsmod | grep blu
bluetooth             409600  8 bnep,btbcm
ecdh_generic           28672  1 bluetooth
rfkill                 28672  6 bluetooth,cfg80211
[email protected]:~# dmesg | grep Blue
[  232.376504] Bluetooth: Core ver 2.22
[  232.376767] Bluetooth: HCI device and connection manager initialized
[  232.376796] Bluetooth: HCI socket layer initialized
[  232.376811] Bluetooth: L2CAP socket layer initialized
[  232.376877] Bluetooth: SCO socket layer initialized
[  245.702938] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  245.702953] Bluetooth: BNEP filters: protocol multicast
[  245.702985] Bluetooth: BNEP socket layer initialized
[email protected]:~# systemctl status bluetooth
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-05-15 12:39:51 BST; 3min 26s ago
     Docs: man:bluetoothd(8)
 Main PID: 799 (bluetoothd)
   Status: "Running"
   Memory: 2.9M
   CGroup: /system.slice/bluetooth.service
           └─799 /usr/lib/bluetooth/bluetoothd

May 15 12:39:50 rak-gateway systemd[1]: Starting Bluetooth service...
May 15 12:39:51 rak-gateway bluetoothd[799]: Bluetooth daemon 5.50
May 15 12:39:51 rak-gateway systemd[1]: Started Bluetooth service.
May 15 12:39:51 rak-gateway bluetoothd[799]: Starting SDP server
May 15 12:39:51 rak-gateway bluetoothd[799]: Bluetooth management interface 1.14 initialized
[email protected]:~# systemctl status hciuart
● hciuart.service - Configure Bluetooth Modems connected by UART
   Loaded: loaded (/lib/systemd/system/hciuart.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-05-15 12:42:13 BST; 1min 6s ago
  Process: 894 ExecStart=/usr/bin/btuart (code=exited, status=1/FAILURE)

May 15 12:41:43 rak-gateway systemd[1]: Starting Configure Bluetooth Modems connected by UART...
May 15 12:42:13 rak-gateway btuart[894]: Initialization timed out.
May 15 12:42:13 rak-gateway btuart[894]: bcm43xx_init
May 15 12:42:13 rak-gateway systemd[1]: hciuart.service: Control process exited, code=exited, status=1/FAILURE
May 15 12:42:13 rak-gateway systemd[1]: hciuart.service: Failed with result 'exit-code'.
May 15 12:42:13 rak-gateway systemd[1]: Failed to start Configure Bluetooth Modems connected by UART.
[email protected]:~# grep bt /boot/config.txt 
[email protected]:~# hcitool dev
[email protected]:~# 

Here introduces the use of Bluetooth through the bluetoothctl tool, I think you can try it.

Another idea would be to temporarily put in a different uSD card with a stock Raspbian or whatever and try all your experiments on that first without it trying to be a gateway. If you get bluetooth working there, then you know that there’s an issue of different configuration between the OS images, and you can try to identify the issue. But if it doesn’t work on a stock image, then the problem is likely a mistake in the attempt to use bluetooth…

Worst case you could also start with a stock image and follow the many instructions for turning a pi into a gateway.

1 Like

That is a good idea, will try that and report back (will take some time!)

I tried the suggestion and installed Raspbian on a separate SD card and bluetooth worked out of the box. Then I executed the install script found in for the RAK2246 board and this broke bluetooth again, but also the gateway itself doesn’t work:

*** Beacon Packet Forwarder for Lora Gateway ***
Version: 4.0.1
*** Lora concentrator HAL library version info ***
Version: 5.0.1;
INFO: Little endian host
INFO: found global configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
INFO: lorawan_public 1, clksrc 1
INFO: no configuration for LBT
INFO: antenna_gain 0 dBi
INFO: no configuration for tx gain lut 9
INFO: no configuration for tx gain lut 10
INFO: no configuration for tx gain lut 11
INFO: no configuration for tx gain lut 12
INFO: no configuration for tx gain lut 13
INFO: no configuration for tx gain lut 14
INFO: no configuration for tx gain lut 15
INFO: Configuring TX LUT with 9 indexes
ERROR: Failed to configure concentrator TX Gain LUT

So it looks like this ends up in a lot of try-and-error. Let’s see if I ever get this to work.

At least it would be great to figure out if it even is able to work hardware-wise…

It should be able to work, unless there’s a conflict over attempts to support GPS.

Maybe try a generic gateway install procedure and not RAK’s; there’s not much unique about the hardware of the concentrator itself, except for the reset pin assignment and the unfortunate need to keep the SPI clock slow.

Hello @tobru

thank you for your feedback.
This is my fault. I set a wrong value for dig_power. I have fixed it, please push the latest code.

Please try to comment “dtoverlay=disable-bt” in the file /boot/config.txt, Then try again if Bluetooth works.

@ZhuQI Thanks for the fix, the gateway now starts properly and connects to TTN.

But still no luck with with Bluetooth. After running the install script I compared the original config.txt and the one provided by the install script:

[email protected]:~ $ diff -u config.txt /boot/config.txt 
--- config.txt	2020-07-18 13:04:18.404095485 +0100
+++ /boot/config.txt	2020-07-18 13:10:26.000000000 +0100
@@ -46,21 +46,14 @@
+dtparam=i2c1=on, dtparam=i2c_arm_baudrate=100000
-# Uncomment this to enable infrared communication.
+# Uncomment this to enable the lirc-rpi module
 # Additional overlays and parameters are documented /boot/overlays/README
 # Enable audio (loads snd_bcm2835)
-# Enable DRM VC4 V3D driver on top of the dispmanx display stack

I then removed the line dtoverlay=disable-bt and rebooted: No luck. I then restored the original config.txt and rebooted: No luck.

The next step I’m taking is to again start from scratch with an clean Raspbian installation and try to install the gateway software manually. It looks like the installer changes something which breaks Bluetooth, but I don’t know what. Just removing / commenting the dtoverlay=disable-bt isn’t enough as it seems.

Hello @tobru

Can you try to delete “gps_tty_path” from the file /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json?
2020-07-20 09-32-56

Please use command sudo systemctl enable hciuart.

@ZhuQI YES! That finally did the trick and bluetooth is now working. Thanks a lot for helping.