Showing posts with label Contiki-NG. Show all posts
Showing posts with label Contiki-NG. Show all posts

Tuesday, April 24, 2018

How to setup Mosquitto on Raspberry Pi and make Contiki/Contiki-NG cc26xx-web-demo do mqtt publish to it.

The following steps show you how to setup Mosquitto on Raspberry Pi and make Contiki/Contiki-NG cc26xx-web-demo do mqtt publish to it.

1. Login to Raspberry Pi and do the following steps to install Mosquitto.
  • 1.1 Run "apt-get update" and "apt-get install mosquitto" to install Mosquitto server.
  • 2.2 Run "apt-get install mosquitto-clients" to install mosquitto_sub and mosquitto_pub.
2. Follow steps in How to configure 6lbr to make it can do ping6 to a CC26xx/CC13xx node from Raspberry Pi running 6lbr to setup 6lbr in bridge router mode.

3. Do "ifconfig" to get br0 IPv6 address. In my case, it's "bbbb::e786:9d85:9446:709".


4. Go to cc26xx-web-demo MQTT/IBM Cloud Config page and set "bbbb::e786:9d85:9446:709" as broker IP.


5. Open another ssh login to Raspberry pi and run "mosquitto_sub -h bbbb::e786:9d85:9446:709 -t iot-2/evt/status/fmt/json" to subscribe to ccx6xx-web-demo publish topic. You should be it receives cc26xx-web-demo published MQTT messages.


p.s. You can also use "mosquitto_pub -h bbbb::e786:9d85:9446:709 -p 1883 -t iot-2/evt/status/fmt/json -m "hello"" to test MQTT message publish from Raspberry Pi terminal.

6. The following steps show you how to toggle red led on LAUNCHXL-CC1310 or LAUNCHXL-CC2560 running cc26xx-web-demo.
  •  Use "test" as Org ID instead of "quickstart" and "123456" as Auth Token instead of empty.
  • Click "Submit" to make cc26xx-web-demo to reconnect to mqtt server.
  • Start a ssh login to raspberry pi. Use "mosquitto_pub -h bbbb::e786:9d85:9446:709 -m "1" -t iot-2/cmd/leds/fmt/json" to turn on red led, or "mosquitto_pub -h bbbb::e786:9d85:9446:709 -m "0" -t iot-2/cmd/leds/fmt/json" to turn off red led.



Thursday, April 19, 2018

How to build and run Contiki-NG cc26xx-web-demo running on LAUNCHXL-CC1310 and rpl-border-router on Raspberry Pi with slip radio running on LAUNCHXL-CC1310

The following steps show how to build and run Contiki-NG cc26xx-web-demo running on LAUNCHXL-CC1310 (or LAUNCHXL-CC2650) and rpl-border-router on Raspberry Pi with slip radio running on LAUNCHXL-CC1310 (or LAUNCHXL-CC2650) .

1. Do "git clone --recursive https://github.com/contiki-ng/contiki-ng" on your InstantContiki or Cygwin (you can build Cygwin develop environment according to here)

2. Build slip radio for LAUNCHXL-CC1310

  • 2.1 Change directory to contiki-ng/examples/slip-radio
  • 2.2 Add "#define IEEE802154_CONF_DEFAULT_CHANNEL 25" to project-conf.h
  • 2.3 Build slip-radio.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 slip-radio.bin"
  • 2.4 Download slip-radio.bin to one of LAUNCHXL-CC1310 to act as slip radio for usage of rpl-border-router.
3. Build cc26x0-web-demo for LAUNCHXL-CC1310

  • 3.1 Change directory to contiki-ng/examples/platform-specific/cc26xx/cc26x0-web-demo
  • 3.2 Make sure "#define IEEE802154_CONF_DEFAULT_CHANNEL 25" is defined in project-conf.h
  • 3.3 Build cc26xx-web-demo.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 cc26xx-web-demo.bin"
  • 3.4 Download cc26xx-web-demo.bin to another of LAUNCHXL-CC1310 to connect with rpl-border-router later.
4. Build and run rpl-border-router on Raspberry Pi
  • 4.1 Do "git clone --recursive https://github.com/contiki-ng/contiki-ng" on your Raspberry Pi.
  • 4.2 Change directory to contiki-ng/examples/rpl-border-router
  • 4.3 Build border-router.native by "make TARGET=native all"
  • 4.4 Connect LAUNCHXL-CC1310 (running slip radio) to Raspberry Pi and make sure it emulates ttyACM0.
  • 4.5 Run rpl-border-router by "sudo ./border-router -native fd00::1/64 -s /dev/ttyACM0"

5. You can type "help" on rpl-border-router console to know more available commands.



6. You can login to Raspberry Pi using another terminal and do "ping6 fd00::212:4b00:e00:cc00" to see reply from rpl-border-router.


6. Power on cc26xx-web-demo on another LAUNCHXL-CC1310. The green led on LAUNCHXL-CC1310 should blink fast in the beginning. When you see green led blinking slows down, it means cc26xx-web-demo joins rpl-border-router.

7. You can type "ip-nbr" on rpl-border-router console to know reachable nodes.



8. Now, you can do "ping6 fd00::212:4b00:a27:f319" (fd00::212:4b00:a27:f319 is the IPv6 address of cc26xx-web-demo) and see reply from cc26xx-web-demo.




Build and run 6lbr/Contiki-NG cc26xx-web-demo on Rasperry Pi with LAUNCHXL-CC1310/LAUNCHXL-CC2650

The following steps show how to build and run 6lbr/Contiki-NG cc26xx-web-demo on Rasperry Pi with LAUNCHXL-CC1310/LAUNCHXL-CC2650:

1. Build Contiki-NG slip radio for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin (you can refer here to setup Cygwin build environment)
  • 1.1 Do "git clone --recursive https://github.com/contiki-ng/contiki-ng"
  • 1.2 Switch to directory contiki-ng/
  • 1.3 Do "git submodule sync" and "git submodule update --init"
  • 1.4 Switch to directory contiki-ng/examples/slip-radio
  • 1.5 Since 6lbr/Contiki-NG only supports RPL-CLASSIC now, we use "make TARGET=cc26x0-cc13x0 srf06-cc26xx BOARD=launchpad/cc1310 MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC  slip-radio.bin" to build slip radio for LAUNCHXL-CC1310.
  • 1.6 Download slip-radio.bin to one LAUNCHXL-CC1310 to act as slip radio for Raspberry Pi later.

2. Build Contiki-NG cc26x0-web-demo for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin
  • 2.1 Apply Fixing cc26xx 6lbr client example patch first.
  • 2.2 Switch to directory contiki-ng/examples/platform-specific/cc26xx/cc26x0-web-demo
  • 2.3 Since 6lbr/Contiki-NG only supports RPL-CLASSIC now, we use "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC  cc26xx-web-demo.bin" to build cc26xx-web-demo for LAUNCHXL-CC1310.
  • 2.4 Download cc26xx-web-demo.bin to another LAUNCHXL-CC1310 to join Raspberry Pi 6lbr later.

3. Build 6lbr/Contiki-NG on Rasperry Pi
  • 3.1 SSH login to Raspberry Pi.
  • 3.2 Change directory to home folder and git clone --recursive https://github.com/cetic/6lbr.git
  • 3.3 Change directory to 6lbr folder and do "git submodule update --init" git checkout contiki-ng
  • 3.4 Change directory to home folder and git clone --recursive https://github.com/cetic/contiki-ng.git
  • 3.5 Change directory to contiki-ng folder and do "git submodule update --init" git checkout sixlbr
  • 3.6 Change directory to 6lbr/examples/6lbr folder and run the following build command
    "make WITH_CONTIKI=0 CONTIKI=~/contiki-ng WERROR=0 all"
  • 3.7  After build successfully, do "sudo make install". You will see "install: cannot stat ‘tools/nvm_tool’: No such file or directory" issue since nvm_tool doens't make properly for current version. It might be fixed later but you can use nvm_tool built by previous 6lbr to do the following steps.
  • 3.8 Run "sudo /usr/lib/6lbr/bin/nvm_tool --update --channel 25 /etc/6lbr/nvm.dat" to change 6lbr/Contiki-NG to use channel 25.
  • 3.9 Run "/usr/lib/6lbr/bin/nvm_tool --print /etc/6lbr/nvm.dat" to make sure it switches to channel 25.
  • 3.10 Connect LAUNCHXL-CC1310 running slip radio to Raspberry Pi.
  • 3.11 Run "sudo service 6lbr start" to start 6lbr/Contiki-NG and you can use Firefox to access to [bbbb::100]


 4. Power on LAUNCHXL-CC1310 running cc26xx-web-demo and you will see it pops on sensors tab of 6lbr web page. You can test http or coap function on cc26xx-web-demo now.