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
MeshLocalAddress
Returns the Local Mesh IPV6 address.
public IPAddress MeshLocalAddress { get; }
Property Value
OpenThreadError
The OpenThread error result of last JoinerStart command.
public int OpenThreadError { get; }
Property Value
Role
Return devices current role.
public ThreadDeviceRole Role { get; }
Property Value
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
stringCommand to send
CommandLineInputAndWaitResponse(string)
Send a Command line input (CLI command) and wait for result.
public string[] CommandLineInputAndWaitResponse(string input)
Parameters
input
stringCommand 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
ThreadDeviceTypeThe 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
ThreadDeviceTypeThe type of the device in the Thread mesh network. An end device or router.
spiDeviceNumber
intThe 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
ThreadDeviceTypeThe type of the device in the Thread mesh network. An end device or router.
comPortNumber
intThe COM port number to use for radio. If required the pins used by COM port must be configured before this call.
speed
intThe 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
stringPre-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
OnRoleChanged
This is an event that is triggered when the device role changes.
public event OpenThread.OpenThreadRoleChangedEventHandler OnRoleChanged
Event Type
OnStatusChanged
This is an event that is triggered when the status of OpenThread changes.
public event OpenThread.OpenThreadStatusChangedEventHandler OnStatusChanged