This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF51: IoT-MQTT example and Raspberry Pi 3

Hello,

I need a little help regarding IoT-SDK 0.8.0 on nRF51.

What I want to achive: Get the IoT-SDK 0.8.0 MQTT-Example running on nRF51 and publishing sensor data to a Raspberry Pi 3 using IPv6 and MQTT. Later, more sensor nodes should publish their data "simultaneously".

What my current situation is: I flashed the IoT-Softdevice along with the recompiled example code into the nRF51. On the Pi, I started with a freshly installed Debian Jessie lite. First, I installed the mosquitto broker and radvd (there was no bt0-device present at this point):

sudo su
apt-get install mosquitto
apt-get install radvd

After that, I created the config file for radvd:

nano /etc/radvd.conf

with the following content:

interface bt0
{
    AdvSendAdvert on;
    prefix 2001:db8::/64
    {
        AdvOnLink off;
        AdvAutonomous on;
        AdvRouterAddr on;
    };
};

First question here: How do I know "my" prefix? Or is it always the same as in the example? Then I started radvd:

echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
service radvd restart

After that, I found the nRF51-device using "hcitool lescan":

00:AB:C8:3A:XX:YY MQTTPublisher

Then I started the 6lowpan stack:

modprobe bluetooth_6lowpan
echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable

But there was still no bt0-device visible in the output of "ifconfig".

After that, I tried to establish the connection with

echo "connect 00:AB:C8:3A:XX:YY 2" > /sys/kernel/debug/bluetooth/6lowpan_control

but the board is not leaving the advertising mode nor is bt0 visible on the Pi.

Thats the point I am stuck at the moment. Can you tell me what I miss?

Thank you very much in advance!

Best Regards

Note: I already found this, unfortunately it did not solve my problem: devzone.nordicsemi.com/.../

  • Have you done this? From the nRF51 IoT SDK 0.8.0 documentation:

    debugfs file system

    In most Linux distributions, the debugfs file system is mounted to /sys/kernel/debug. However, Raspbian OS does not automatically mount the debugfs file system. Therefore, you must mount it manually before 6LoWPAN can use it:

    # Mount debugfs file system.
    mount -t debugfs none /sys/kernel/debug
    # Check the contents of the folder.
    ls /sys/kernel/debug
    

    To initialize the 6LoWPAN module, you must first load it:

    modprobe bluetooth_6lowpan
    

    Next, set the Protocol Service Multiplexer number (PSM) in the module. It must be set to the PSM of the Internet Protocol Support Profile (IPSP), which is 0x23 in hex or 35 decimal.

    To set the correct PSM number:

    echo 35 > /sys/kernel/debug/bluetooth/6lowpan_psm
    

    I would also try to use 1 instead of 2 in the connect command.

  • Thank you for your reply. Unfortunately it is still not connecting to the broker. The debugfs was already mounted, the bluetooth_6lowpan was already loaded as mentioned in the text and I get "permission denied" when trying to execute the psm command (console was running as super user). Any further help/suggestions would be much apprechiated.

  • What is the PSM in /sys/kernel/debug/bluetooth/6lowpan_psm? Do you have permission to access /sys/kernel/debug/bluetooth/6lowpan_control ?

  • Update: Connection ist established successfully, when I use "1" in the connect command. Unfortunately I cannot connect to the broker. Is my address right:

    When I get this using ifconfig on my bt0 device:

    inet6 addr: fe80::ba27:ebff:fe47:XXYY/64 
    

    Than I have to enter it like this:

    .addr =
    {HTONL(0xBA27EBFF),
    0x00000000,
    0x00000000,
    HTONL(0xFE47XXYY)}
    

    Is this correct?

  • This works without problems:

    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    

    But this results in an permission error:

    echo 35 > /sys/kernel/debug/bluetooth/6lowpan_psm
    

    I also get this:

    root@raspberrypi:/home/pi# ls /sys/kernel/debug/bluetooth/6lowpan_psm
    ls: cannot access /sys/kernel/debug/bluetooth/6lowpan_psm: No such file or directory
    

    And here is the content of /sys/kernel/debug/bluetooth/ :

    root@raspberrypi:/home/pi# ls /sys/kernel/debug/bluetooth/                      6lowpan_control  hci0   l2cap_le_default_mps  sco
    6lowpan_enable   l2cap  l2cap_le_max_credits
    
Related