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

nRF51: IoT-MQTT Publisher Example problems

Hi, I just read IoT-MQTT example and have almost exactly the same problem but with the Publisher. I am running a PI with Raspberian 4.4.34-v7+. I have installed mosquitto on the PI and have radvd installed. I turned on the IPV6 forwarding (echo 1 > /proc/sys/net/ipv6/conf/all/forwarding), did the config file and restarted radvd. This worked ONCE. I did get this:

sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
root@raspberrypi:/home/pi# sudo service radvd restart
root@raspberrypi:/home/pi# ifconfig bt0
bt0       Link encap:UNSPEC  HWaddr B8-27-EB-FF-FE-F1-72-D4-00-00-00-00-00-00-00-00  
inet6 addr: 2001:db8::ba27:ebff:fef1:72d4/64 Scope:Global
inet6 addr: fe80::ba27:ebff:fef1:72d4/64 Scope:Link
UP POINTOPOINT RUNNING MULTICAST  MTU:1280  Metric:1
RX packets:47 errors:0 dropped:0 overruns:0 frame:0
TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1 
RX bytes:1906 (1.8 KiB)  TX bytes:2808 (2.7 KiB)

This is with the Publisher connected to bt0. The publisher has the 2001:... address compiled in. I then run mosquitto -v on the PI but when I press button 1 all 4 LED's light up and stay lit showing it failed. I get no messages on mosquitto.

But now if I disconnect and re-connect bt0 does NOT have the global address anymore. I even re-booted the PI and did the whole sequence all over again starting with loading 6lowPAN and still it does not get the global address. Do you have any suggestions of what to try next.

And one more question. The disconnect does not work. When I try to do:

echo "disconnect 00:EF:0B:A4:88:A6" > /sys/kernel/debug/bluetooth/6lowpan_control 

I get a write error of invalid argument. That is the correct MAC.

Thank you for the help. --jim schimpf

  • I have this running on a Raspberry Pi and I have to manually add the prefix, i.e. sudo ifconfig btX add 2001:db8::1/64 every time after I disconnect and want to re-connect to the broker. Also make sure that every time you run sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding and sudo service radvd restart after you reboot your pi.

  • Thank you very much for the help. I have done as you suggested and added the ifconfig line to my script also I do the forward cmd and restart of radvd. I have the producer using the default address of 2001:db8::1 and running mosquitto on my PI and still no connection. The bt0 shows inet6 addr: 2001:db8::1/64 Scope:Global.

  • Hmm, I'll post my bash script that does the configuration and connects to my nRF52 devices when I get home((my Raspberry Pi i setup there).

  • Thank you again, my script is ( I have two boards)

    
    
    
    modprobe bluetooth_6lowpan
    
    
    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    
    
    hciconfig
    
    hciconfig hci0 reset 
    
    echo "Connecting.."
    
    echo "connect 00:EF:0B:A4:88:A6 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    
    sleep 5
    
    echo "connect 00:CB:11:CB:73:15 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    
    echo "Forwarding.."
    
    echo 1 >  /proc/sys/net/ipv6/conf/all/forwarding
    
    sleep 1
    
    service radvd restart
    
    sleep 1
    
    ifconfig bt0 add 2001:db8::1/64
    
    
    Also have you tried connecting to the log output of the Nordic board ?  I can connect but get only garbage at 115200, but nothing prints at 38400. Have tried on OSX and Windows and it's the same in both.
    
  • device_list=( "00:8B:5C:0C:09:AC" "00:C0:1E:C1:49:66" "00:BA:F2:90:B8:FB" )

    #echo $PATH
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    
    # 6lowpan Initialization
    modprobe  bluetooth-6lowpan
    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    
    # Enabling IPv6 Forwarding
    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    
    # Restart radvd service
    sudo service radvd restart
    
    # Connect to devices in the list
    
    for i in ${device_list[@]}; do
        con_grep=$(hcitool con | grep -o $i)
        if [ "$(hcitool con | grep -o $i)" = "$i" ]; then
            #echo $(hcitool con | grep -o $i)
            #echo "$i"
            echo "Already connected to: $i"
        else
            echo "Connecting to: $i"
            echo "connect $i 1" > /sys/kernel/debug/bluetooth/6lowpan_control
        fi
    done
    
Related