Table of Contents

Class OpenThread

Namespace
nanoFramework.Networking.Thread
Assembly
nanoFramework.Networking.Thread.dll

OpenThread main class for constructing and starting the OpenThread mesh network.

public class OpenThread : IDisposable
Inheritance
OpenThread
Implements
Inherited Members
Extension Methods

Properties

Dataset

Gets or Sets the active dataset.

public OpenThreadDataset Dataset { get; set; }

Property Value

OpenThreadDataset

MeshLocalAddress

Returns the Local Mesh IPV6 address.

public IPAddress MeshLocalAddress { get; }

Property Value

IPAddress

OpenThreadError

The OpenThread error result of last JoinerStart command.

public int OpenThreadError { get; }

Property Value

int

Role

Return devices current role.

public ThreadDeviceRole Role { get; }

Property Value

ThreadDeviceRole

Methods

CommandLineInput(string)

Send a Command line input (CLI command) and don't wait for response. All results will be fired as OnConsoleOutputAvailable event.

public void CommandLineInput(string input)

Parameters

input string

Command to send

CommandLineInputAndWaitResponse(string)

Send a Command line input (CLI command) and wait for result.

public string[] CommandLineInputAndWaitResponse(string input)

Parameters

input string

Command to send

Returns

string[]

CreateThreadWithNativeRadio(ThreadDeviceType)

Create an OpenThread object for use with inbuilt radio.

public static OpenThread CreateThreadWithNativeRadio(ThreadDeviceType threadDeviceType = ThreadDeviceType.Router)

Parameters

threadDeviceType ThreadDeviceType

The type of the device in the Thread mesh network. An end device or router.

Returns

OpenThread

OpenThread object.

CreateThreadWithSpiRadio(ThreadDeviceType, int)

Create an OpenThread object for use with a RCP radio connected via a SPI port.

public static OpenThread CreateThreadWithSpiRadio(ThreadDeviceType threadDeviceType, int spiDeviceNumber)

Parameters

threadDeviceType ThreadDeviceType

The type of the device in the Thread mesh network. An end device or router.

spiDeviceNumber int

The SPI number where radio is connected. If required the pins used by SPI port must be set up before this call.

Returns

OpenThread

OpenThread object.

CreateThreadWithUartRadio(ThreadDeviceType, int, int)

Create an OpenThread object for use with a RCP radio connected via a UART.

public static OpenThread CreateThreadWithUartRadio(ThreadDeviceType threadDeviceType, int comPortNumber, int speed = 460800)

Parameters

threadDeviceType ThreadDeviceType

The type of the device in the Thread mesh network. An end device or router.

comPortNumber int

The COM port number to use for radio. If required the pins used by COM port must be configured before this call.

speed int

The serial speed of connection. Defaults to 460800 bps.

Returns

OpenThread

OpenThread Object.

Dispose()

Dispose OpenThread object and release native memory.

public void Dispose()

Dispose(bool)

Dispose

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Finalize()

OpenThread finalize r

protected override void Finalize()

JoinerStart(string)

Start the Joiner role for commissioning the device. This can only be called before the OpenThread has been started. Will return when the commissioning has completed or failed.

public bool JoinerStart(string pskc)

Parameters

pskc string

Pre-shared key for the commissioner.

Returns

bool

Returns true is commissioning has completed successfully. If an error the OpenThread error code is stored in the property JoinerStartError

Start()

Start OpenThread stack running. The device will try to connect to existing thread network based on defined dataset.

public void Start()

Exceptions

InvalidOperationException

OpenThread stack already started.

Stop()

Stop OpenThread stack running.

public void Stop()

Exceptions

InvalidOperationException

OpenThread stack not running.

Events

OnConsoleOutputAvailable

This is an event that is triggered when there is output available on the console as a result of a command or as an unsolicited message.

public event OpenThread.OpenThreadConsoleOutputAvailableEventHandler OnConsoleOutputAvailable

Event Type

OpenThread.OpenThreadConsoleOutputAvailableEventHandler

OnRoleChanged

This is an event that is triggered when the device role changes.

public event OpenThread.OpenThreadRoleChangedEventHandler OnRoleChanged

Event Type

OpenThread.OpenThreadRoleChangedEventHandler

OnStatusChanged

This is an event that is triggered when the status of OpenThread changes.

public event OpenThread.OpenThreadStatusChangedEventHandler OnStatusChanged

Event Type

OpenThread.OpenThreadStatusChangedEventHandler