Trying OpenWRT Chaos Calmer (15.05 RC1) on Raspberry Pi 2

 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER (15.05 RC1)
 -----------------------------------------------------

The original guide to install Barrier Breaker (14.04) on Pi and Pi2 could be found here

http://wiki.openwrt.org/toh/raspberry_pi

Install official CHAOS CALMER (15.05 RC1) for Raspberry Pi2

(1) Grab the image from OpenWRT

https://downloads.openwrt.org/chaos_calmer/15.05-rc1/brcm2708/bcm2709/openwrt-15.05-rc1-brcm2708-bcm2709-sdcard-vfat-ext4.img

This image works for BCM2709/BCM2836, while R.Pi2 uses BCM2836. Use Win32DiskImager to write it into SD card.

(2) Boot up R.Pi2 with the SD card

(3) Configure DHCP for the only LAN port

uci set network.lan.proto=dhcp
uci commit
reboot

(4) Connect R.Pi to broadband router, then it should have Internet connection.

  laptop -- WiFi Router --- Internet
                |
        R.Pi2 with OpenWRT ---- nRF51DK (IoT SDK v0.8.0)

In my case, br-lan interface get 192.168.1.9 with gateway/dns to be 192.168.1.1

(5) Install USB, Bluetooth modules and BlueZ package

opkg update
opkg install kmod-usb-ohci kmod-usb-storage kmod-usb2
opkg install kmod-bluetooth kmod-bluetooth_6lowpan 
opkg install bluez-utils bluez-libs ip

(6) Edit /etc/modules.d/Bluetooth_6lowpan, in which it should be “blueooth_6lowpan” instead of “bluetooth”

Everything is now ready, reboot.

(7) Connect Nordic IoT node device

Plug in BT USB dongle to one of the USB port

hciconfig hci0 reset
hcitool lescan
echo 35 > /sys/kernel/debug/bluetooth/6lowpan_psm
echo “connect XX:XX:XX:XX:XX:XX 1” > /sys/kernel/debug/bluetooth/6lowpan_control
ifconfig bt0

By now there should be new “bt0” interface added

(8) Login to LuCI web interface from laptop’s browser, no password for root. Set a password for SSH access later.

In my case, 192.168.1.9 is the LuCI home.

(9) Add a new interface of “6lowpan”, refer to [1]

IPv6 assignment length, 64

Setup DHCP service for this interface,

General Setup, Disable DHCP for this interface.
IPv6 Settings, Router Advertisement-Service «Server Mode»

(10) Edit /etc/config/dhcp to add below for "6lowpan" part, refer to [1]

option ra_default ‘1’
option ra_management ‘1’
option ra_offlink ‘1’

NOTE it's leading tab not spaces before each line.

(11) Set the Global IPv6 ULA-Prefix like below image (with your choice) image description

(12) Restart R.Pi and repeat step (7), the nRF51 IoT node should have a global address working image description

In case your PC is connected to the same broadband router, it should have reveived global address prefix from OpenWRT/br-lan interface. In my case, it's 2003::10/64.

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : lan
   IPv6 Address. . . . . . . . . . . : 2001:c90:8024:65b9:fce4:7f5b:7ebc:97a0
   IPv6 Address. . . . . . . . . . . : 2003::10:fce4:7f5b:7ebc:97a0
   IPv6 Address. . . . . . . . . . . : 2003:c90:8024:1::67a
   IPv6 Address. . . . . . . . . . . : fdab:dd80:8201:0:fce4:7f5b:7ebc:97a0
   Link-local IPv6 Address . . . . . : fe80::fce4:7f5b:7ebc:97a0%11
   IPv4 Address. . . . . . . . . . . : 192.168.1.5
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::5675:d0ff:fe97:88cc%11
                                       192.168.1.1

The 2001:c90:xxxx is from the broadband router.

Then I could access the CoAP server on the connected nRF51DK. image description

Good luck!

[1] PK, "OpenWRT Series" #1: setting up TP-Link WDR4300 (or N750) for Bluetooth Low Energy 6LoWPAN https://devzone.nordicsemi.com/blogs/698/openwrt-series-1-setting-up-tp-link-wdr4300-or-n75/

  • Hello, is the sensor (thermometer's) service is writing by yourself? so you needs external thermomter embedded on nrf51DK by yourself?

    Or it is just the example of nrf51DK?

    And when you press the Get button, you recived newest value of temperture, it's json format or not? Thanks!!!!

  • Hi,

    Thank you for your answer, I read PK's post, but did not find what I wanted to. I would like to know if there was any proper way to continuously scan for BLE devices, and connect to them totally automatically (without having to enter the "echo connect..." command by hand) ?

    That will be the role of the Linux-based IPSP Router role daemon ? When do you think will it be available ?

    I already wrote some scripts, I got them to work but experienced stability problems...

  • Hi Arnaud, please follow the "OpenWRT Series" by PK (see reference[1]). He already has some script to do automatic scanning and connecting. In the long term, there will be a Linux-based IPSP Router role daemon implemented.

  • Great articles series, thank you !

    Did you come up to a solution for scanning and connecting to BLE devices automatically ?

    I was looking forward to implementing such a thing, tried with some python scripts that sort of worked by scanning at intervals and connecting to new devices. But it locked up pretty often my rpi2 as scanning while connected appears to be problematic.