/ot-rtos

OpenThread RTOS, an integration of OpenThread, LwIP, and FreeRTOS.

Primary LanguageCBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

OpenThread RTOS

The OpenThread RTOS project provides an integration of:

  1. OpenThread, an open-source implementation of the Thread networking protocol.
  2. LwIP, a small independent implementation of the TCP/IP protocol suite.
  3. FreeRTOS, a real time operating system for microcontrollers.

OpenThread RTOS includes a number of application-layer demonstrations, including:

  • MQTT, a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.
  • HTTP, the underlying protocol used by the World Wide Web.
  • TCP, one of the main transport protocols in the Internet protocol suite.

Getting started

Linux simulation

git submodule update --init
mkdir build && cd build
cmake .. -DPLATFORM_NAME=linux
make -j12

Nordic nRF52840

git submodule update --init
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi.cmake -DPLATFORM_NAME=nrf52
make -j12

This will build the demo application of OpenThread command line in build/ot_cli_nrf52840, you can use the command line application by connecting to the serial port of nRF52840.

Test HTTP Client

panid 0x1234
extpanid 1111111122222222
masterkey 00112233445566778899AABBCCDDEEFF
channel 15
networkname OpenThreadDemo
ifconfig up
thread start
test http

You should see http response

Test MQTT Client

Please read the quick start guide for google cloud iot core first and save your private key, also select RS256 for authentication.

You need to put your client config in include/apps/google_cloud_iot/client_cfg.h A sample config is given below:

#ifndef OT_RTOS_CLIENT_CFG_HPP_
#define OT_RTOS_CLIENT_CFG_HPP_

#define CLOUDIOT_SERVER_ADDRESS "mqtt.googleapis.com"
#define CLOUDIOT_DEVICE_ID "{your_device_id}"
#define CLOUDIOT_REGISTRY_ID "{your_registry_name}"
#define CLOUDIOT_PROJECT_ID "{your_project_id}"
#define CLOUDIOT_REGION "{your_region}"
#define CLOUDIOT_CLIENT_ID                                                                                       \
    "projects/" CLOUDIOT_PROJECT_ID "/locations/" CLOUDIOT_REGION "/registries/" CLOUDIOT_REGISTRY_ID "/devices" \
    "/" CLOUDIOT_DEVICE_ID

#define CLOUDIOT_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gEdujm7l3sAg9g1o1Q\n"\
"GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz\n"\
"Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2\n"\
"G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi\n"\
"l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3\n"\
"smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==\n"\
"-----END CERTIFICATE-----"

#endif

CLOUDIOT_CERT is the first certificate from https://pki.google.com/roots.pem

You can use command test mqtt to test connect and publish a message to Google Cloud IoT core.

TCP echo server and client

Commands:

  • tcp_echo_server port starts TCP echo server on given port.
  • tcp_connect ipaddr port connects to given TCP server.
  • tcp_send size count sends count packets with given size to connected TCP server. At the end it prints statistics.
  • tcp_disconnect disconnects from TCP server.

Contributing

We would love for you to contribute to OpenThread RTOS and help make it even better than it is today! See our Contributing Guidelines for more information.

Contributors are required to abide by our Code of Conduct and Coding Conventions and Style Guide.

We follow the philosophy of Scripts to Rule Them All.

License

OpenThread RTOS is released under the BSD 3-Clause license. See the LICENSE file for more information.

Please only use the OpenThread name and marks when accurately referencing this software distribution. Do not use the marks in a way that suggests you are endorsed by or otherwise affiliated with Nest, Google, or The Thread Group.

Need help?

There are numerous avenues for OpenThread support:

The openthread-users Google Group is the recommended place for users to discuss OpenThread and interact directly with the OpenThread team.

OpenThread

To learn more about OpenThread, see the OpenThread repository.