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

How do I test example project iot mqtt publish and subscribe projects?

The example projects I am referring to is located here:

nRF5_SDK_15.2.0\examples\iot\mqtt\lwip\subscriber\pca10056\s140\ses\iot_lwip_mqtt_subscriber_pca10056_s140

nRF5_SDK_15.2.0\examples\iot\mqtt\lwip\publisher\pca10056\s140\ses\iot_lwip_mqtt_publisher_pca10056_s140

Using a window10 pc:

I have build and downloaded pub program to one nRF52840DK and sub to another nRF52840DK successfully. On my smart phone I can see both of them as Bluetooth devices.

As new to Nordics products and IDE it would be nice with guides/documentation as how to verify that this MQTT pub/sub projects works ( as well as all the other example projects ). 

Do I need another Linux board to work as the MQTT broker? Or does the subscriber board also works as a broker?

Appreciate a link to documentation/guides that explain the many example projects.

Thanks

Parents
  • Yes, you need a 3rd device that acts as the MQTT Broker, see Setting up the Mosquitto MQTT broker for information on how to set this up on a Windows, Linux or OS X device. 

    The MQTT examples are documented here, Experimental: IoT Examples / MQTT. Each example have a Testing subsection in their documentation, explaining step by step how to test the examples, see 

    MQTT Client - Publisher / Testing

    MQTT Client - Subscriber / Testing

    Best regards
    Bjørn

  • Thanks for your reply. If I don't have the option of a 3rd device MQTT broker, is there a preferred protocol / best way to send and receive data/commands between two BLE devices? I assume it has to be a master-slave relationship, and payload be structured as a JSON document, and it has to be BLE5 to have a payload size of 253 bytes.

    Thanks

  • Thanks again,

    Just a few more questions

    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/iot_rpi_kernel

    What default kernel config command do I run if I am using RPi 3?

    If I should replace the RPi with other HW, what are the requirements? 

    Any Ubuntu/Debian system with min. same amount of Flash and RAM as RPi, WiFi radio and 

    a USB port for the BLE dongle?

  • Use the second kernel config command, it should be # If Raspberry Pi 2/3, see https://www.raspberrypi.org/documentation/linux/kernel/configuring.md.
     
    # If Raspberry Pi 2.
    pi@raspberry:~/raspbian/kernel/linux$ make bcm2709_defconfig
    I am afraid that I do not know the requirements for the Ubuntu/Debian OS with the required modules and I do not know which single board computers that are equivalent to the Raspberry Pi. 
  • Hi, 

    Still moving forward..but I ran into some issues starting the cross compiling step 5! First issue was "No rule to make target '--j5'

    I am using a Core i5 with 4 CPU cores, so it should be OK with --j5, anyway I tried again without --j5 and it resulted in GCC -option errors. see below.

    The first 4 steps seem to be successful, not sure where the chain dropped off. 

    Some system info:

    Ubuntu 16.04 LTS PC with 4 GB

    plp@toby:~$ uname -a
    Linux toby 4.4.0-141-generic #167-Ubuntu SMP Wed Dec 5 10:40:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    Any feedback is appreciated

    Thanks.

    plp@toby:~/Nordic-Semi/rpikernel/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make bcm2709_defconfig HOSTCC scripts/basic/fixdep

    HOSTCC scripts/kconfig/conf.o

    SHIPPED scripts/kconfig/zconf.tab.c

    SHIPPED scripts/kconfig/zconf.lex.c

    HOSTCC scripts/kconfig/zconf.tab.o

    HOSTLD scripts/kconfig/conf

    #

    # configuration written to .config

    #

    plp@toby:~/Nordic-Semi/rpikernel/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make –j5

    scripts/kconfig/conf --silentoldconfig Kconfig

    make: *** No rule to make target '–j5'. Stop.

    plp@toby:~/Nordic-Semi/rpikernel/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make –j5 modules

    make: *** No rule to make target '–j5'. Stop.

    plp@toby:~/Nordic-Semi/rpikernel/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make

    SYSHDR arch/arm/include/generated/uapi/asm/unistd-common.h

    SYSHDR arch/arm/include/generated/uapi/asm/unistd-oabi.h

    SYSHDR arch/arm/include/generated/uapi/asm/unistd-eabi.h

    CHK include/config/kernel.release

    UPD include/config/kernel.release

    WRAP arch/arm/include/generated/uapi/asm/bitsperlong.h

    WRAP arch/arm/include/generated/uapi/asm/errno.h

    WRAP arch/arm/include/generated/uapi/asm/ioctl.h

    WRAP arch/arm/include/generated/uapi/asm/ipcbuf.h

    WRAP arch/arm/include/generated/uapi/asm/msgbuf.h

    WRAP arch/arm/include/generated/uapi/asm/param.h

    WRAP arch/arm/include/generated/uapi/asm/poll.h

    WRAP arch/arm/include/generated/uapi/asm/resource.h

    WRAP arch/arm/include/generated/uapi/asm/sembuf.h

    WRAP arch/arm/include/generated/uapi/asm/shmbuf.h

    WRAP arch/arm/include/generated/uapi/asm/siginfo.h

    WRAP arch/arm/include/generated/uapi/asm/socket.h

    WRAP arch/arm/include/generated/uapi/asm/sockios.h

    WRAP arch/arm/include/generated/uapi/asm/termbits.h

    WRAP arch/arm/include/generated/uapi/asm/termios.h

    WRAP arch/arm/include/generated/asm/clkdev.h

    WRAP arch/arm/include/generated/asm/current.h

    WRAP arch/arm/include/generated/asm/early_ioremap.h

    WRAP arch/arm/include/generated/asm/emergency-restart.h

    WRAP arch/arm/include/generated/asm/exec.h

    WRAP arch/arm/include/generated/asm/extable.h

    WRAP arch/arm/include/generated/asm/irq_regs.h

    WRAP arch/arm/include/generated/asm/kdebug.h

    WRAP arch/arm/include/generated/asm/local.h

    WRAP arch/arm/include/generated/asm/local64.h

    WRAP arch/arm/include/generated/asm/mm-arch-hooks.h

    WRAP arch/arm/include/generated/asm/msi.h

    WRAP arch/arm/include/generated/asm/parport.h

    WRAP arch/arm/include/generated/asm/preempt.h

    WRAP arch/arm/include/generated/asm/rwsem.h

    WRAP arch/arm/include/generated/asm/seccomp.h

    WRAP arch/arm/include/generated/asm/segment.h

    WRAP arch/arm/include/generated/asm/serial.h

    WRAP arch/arm/include/generated/asm/simd.h

    WRAP arch/arm/include/generated/asm/sizes.h

    WRAP arch/arm/include/generated/asm/timex.h

    WRAP arch/arm/include/generated/asm/trace_clock.h

    CHK include/generated/uapi/linux/version.h

    UPD include/generated/uapi/linux/version.h

    CHK include/generated/utsrelease.h

    UPD include/generated/utsrelease.h

    HOSTCC scripts/basic/bin2c

    SYSNR arch/arm/include/generated/asm/unistd-nr.h

    GEN arch/arm/include/generated/asm/mach-types.h

    SYSTBL arch/arm/include/generated/calls-oabi.S

    SYSTBL arch/arm/include/generated/calls-eabi.S

    CC kernel/bounds.s

    gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’

    gcc: note: valid arguments to ‘-mabi=’ are: ms sysv

    gcc: error: unrecognized command line option ‘-mlittle-endian’

    gcc: error: unrecognized command line option ‘-mapcs’

    gcc: error: unrecognized command line option ‘-mno-sched-prolog’

    gcc: error: unrecognized command line option ‘-mfpu=vfp’

    Kbuild:21: recipe for target 'kernel/bounds.s' failed

    make[1]: *** [kernel/bounds.s] Error 1

    Makefile:1084: recipe for target 'prepare0' failed

    make: *** [prepare0] Error 2

    plp@toby:~/Nordic-Semi/rpikernel/linux$

  • Have you exported the CCPREFIX correctly? You could try to replace ${CCPREFIX} with the actual path of the toolchain. See the two forum posts below:

    https://www.raspberrypi.org/forums/viewtopic.php?t=76850

    https://www.raspberrypi.org/forums/viewtopic.php?f=26&t=39592

  • Thanks, CCPREFIX was the problem. I exported in one terminal and I ran the build command from another terminal. It build successfully!

    I hit the next error in step 6 Generate .deb packages.

    plp@toby:~/Nordic-Semi/rpikernel/linux$ CONCURRENCY_LEVEL=5 DEB_HOST_ARCH=armhf fakeroot make-kpkg --append-to-version -plp --revision `date +%Y%m%d%H%M%S` --ARCH=arm --cross-compile ${CCPREFIX} kernel_image kernel_headers

    ...

    install -p -o root -g root -m 644 REPORTING-BUGS /home/plp/Nordic-Semi/rpikernel/linux/debian/linux-headers-4.14.95-plp-v7+/usr/share/doc/linux-headers-4.14.95-plp-v7+/

    install: cannot stat 'REPORTING-BUGS': No such file or directory

    debian/ruleset/targets/headers.mk:40: recipe for target 'debian/stamp/install/linux-headers-4.14.95-plp-v7+' failed

    make[1]: *** [debian/stamp/install/linux-headers-4.14.95-plp-v7+] Error 1

    make[1]: Leaving directory '/home/plp/Nordic-Semi/rpikernel/linux'

    debian/ruleset/local.mk:102: recipe for target 'kernel_headers' failed

    make: *** [kernel_headers] Error 2

    plp@toby:~/Nordic-Semi/rpikernel/linux$

    One solution is just to create an empty REPORTING-BUGS file and it will compile, 

    but what do you say about it? Is there a better way to fix the error??

Reply
  • Thanks, CCPREFIX was the problem. I exported in one terminal and I ran the build command from another terminal. It build successfully!

    I hit the next error in step 6 Generate .deb packages.

    plp@toby:~/Nordic-Semi/rpikernel/linux$ CONCURRENCY_LEVEL=5 DEB_HOST_ARCH=armhf fakeroot make-kpkg --append-to-version -plp --revision `date +%Y%m%d%H%M%S` --ARCH=arm --cross-compile ${CCPREFIX} kernel_image kernel_headers

    ...

    install -p -o root -g root -m 644 REPORTING-BUGS /home/plp/Nordic-Semi/rpikernel/linux/debian/linux-headers-4.14.95-plp-v7+/usr/share/doc/linux-headers-4.14.95-plp-v7+/

    install: cannot stat 'REPORTING-BUGS': No such file or directory

    debian/ruleset/targets/headers.mk:40: recipe for target 'debian/stamp/install/linux-headers-4.14.95-plp-v7+' failed

    make[1]: *** [debian/stamp/install/linux-headers-4.14.95-plp-v7+] Error 1

    make[1]: Leaving directory '/home/plp/Nordic-Semi/rpikernel/linux'

    debian/ruleset/local.mk:102: recipe for target 'kernel_headers' failed

    make: *** [kernel_headers] Error 2

    plp@toby:~/Nordic-Semi/rpikernel/linux$

    One solution is just to create an empty REPORTING-BUGS file and it will compile, 

    but what do you say about it? Is there a better way to fix the error??

Children
  • Yes, after looking at some forums it should be ok to just create the REPORTING-BUGS file. It does not appear to be used by the kernel so this is a Ok way to fix the issue. 

  • Thanks good to know!

    I am going through the 16 test steps of "pca10056 MQTT Client Publisher" 

    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/iot_sdk_app_mqtt_publisher?1649#iot_sdk_app_mqtt_publisher_test

    And the client startup advertising, push button 1 and it connect to 6lowpan router, push button 2 result in error code 0000c943, instead of connecting to the MQTT Broker.

    What does the error code mean?

    Can you tell me how to insert the brokers IPv6 addr correctly, please!

    Is this correct inserted it in MQTT Client Publisher's main.c file. m_broker_addr

    when:

    linux mosquitto broker's IPv6 addr fe80::8292:9e6f:cc08:1520/64

    windows mosquitto broker's Link-local IPv6: fe80::bdeb:857e:f92b:730f%13  

    This is the only place I have setup the MQTT brokers addr, is that correct?

    In step 8 "Prepare the IPv6 global prefix for the btX interface" in the 6lowpan router.

    I followed the guide

    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/iot_sdk_user_guides_radvd

    Enter root user 

    sudo su

    sudo apt-get install radvd

    I modified the /etc/radvd.conf file

    and ran

    # Set IPv6 forwarding (must be present).
    sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    # Run radvd daemon.
    sudo service radvd restart
    Commands had no errors, but not sure I could see this happen

    "Observe if new IPv6 prefix is disseminating over bt0 interface"

    ifconfig gave me this:  bt0: inet6 fe80::b827..... and it should be 2001:db8::...

    Please advise..

    Help is appreciated!

  • Hi Pih

    you need to call

     ifconfig bt0 add 2001:db8::1/64

    to add the prefix, the radvd service does not do this as it shold i thinnk. 

    Bjørn

  • "ifconfig bt0 add 2001:db8::1/64" didn't help

    How can I find the root cause of why it's not working?  Is it possible for you to run the example project on the same HW?

  • Hi Pih, 

    I apologize for the late reply. 

    Are you running the command as sudo? i.e.

    sudo ifconfig bt0 add 2001:db8::1/64

    I beleive things must be done in the following order

    # Log in as a root user.
    sudo su
    # Mount debugfs file system.
    mount -t debugfs none /sys/kernel/debug
    # Load 6LoWPAN module.
    modprobe bluetooth_6lowpan
    # Enable the bluetooth 6lowpan module.
    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    # Look for available HCI devices.
    hciconfig
    # Reset HCI device - for example hci0 device.
    hciconfig hci0 reset
    # Read 00:AA:BB:XX:YY:ZZ address of the nRF5x device.
    hcitool lescan
    # Connect to the device.
    echo "connect 00:AA:BB:XX:YY:ZZ 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    # Check if you have established a connection.
    ifconfig
    # Set IPv6 forwarding (must be present).
    sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    # Run radvd daemon.
    sudo service radvd restart
    #Assign prefix
    ifconfig bt0 add 2001:db8::1/64
    # Observe if new IPv6 prefix is disseminating over bt0 interface.
    ifconfig
    # Try to ping the device using its link-local address, for example, on bt0 interface.
    ping6 -I bt0 fe80::2AA:BBFF:FEXX:YYZZ
    # Disconnect from the device.
    echo "disconnect 00:AA:BB:XX:YY:ZZ" > /sys/kernel/debug/bluetooth/6lowpan_control
    # Check if there are active connections left.
    ifconfig
Related