Network Working Group | R. Quattlebaum |
Internet-Draft | J. Woodyatt |
Intended status: Informational | Nest Labs, Inc. |
Expires: November 10, 2017 | May 9, 2017 |
Spinel Host-Controller Protocol
draft-rquattle-spinel-unified-00
This document describes the Spinel protocol, which facilitates the control and management of IPv6 network interfaces on devices where general purpose application processors offload network functions at their interfaces to network co-processors (NCP) connected by simple communication links like serial data channels. While initially developed to support Thread(R), Spinel's layered design allows it to be easily adapted to other similar network technologies.
This document also describes various Spinel specializations, including support for the Thread(R) low-power mesh network technology.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on November 10, 2017.
Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
This document may not be modified, and derivative works of it may not be created, and it may not be published except as an Internet-Draft.
Spinel is host-controller protocol designed to enable interoperation over simple serial connections between general purpose device operating systems (OS) and network co-processors (NCP) for the purpose of controlling and managing their IPv6 network interfaces, achieving the following goals:
On top of this core framework, we define the properties and commands to enable various features and network protocols.
This document is currently in a draft status and is changing often. This section discusses some ideas for changes to the protocol that haven't yet been fully specified, as well as some of the impetus for the current design.
The eventual intent is to have two documents: A Spinel basis document which discusses the network-technology-agnostic mechanisms and a Thread(R) specialization document which describes all of the Thread(R)-specific implementation details. Currently, this document covers both.
Efforts are currently maintained to try to prevent overtly backward-incompatible changes to the existing protocol, but if you are implementing Spinel in your own products you should expect there to be at least one large renumbering event and major version number change before the standard is considered "baked". All changes will be clearly marked and documented to make such a transition as easy as possible.
To allow conclusive detection of protocol (in)compatibility between the host and the NCP, the following commands and properties are already considered to be "baked" and will not change:
Renumbering would be undertaken in order to better organize the allocation of property IDs and capability IDs. One of the initial goals of this protocol was for it to be possible for a host or NCP to only implement properties with values less than 127 and for the NCP to still be usable---relegating all larger property values for extra features or other capabilities that aren't strictly necessary. This would allow simple implementations to avoid the need to implement support for PUIs (Section 3.2).
As time has gone by and the protocol has become more fleshed out, it has become clear that some of the initial allocations were inadequate and should be revisited if we want to try to achieve the original goal.
A frame is defined simply as the concatenation of
Octets: | 1 | 1-3 | n |
---|---|---|---|
Fields: | HEADER | CMD | CMD_PAYLOAD |
The header byte is broken down as follows:
0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ | FLG | NLI | TID | +---+---+---+---+---+---+---+---+
The flag field of the header byte (FLG) is always set to the value two (or 10 in binary). Any frame received with these bits set to any other value else MUST NOT be considered a Spinel frame.
This convention allows Spinel to be line compatible with BTLE HCI. By defining the first two bit in this way we can disambiguate between Spinel frames and HCI frames (which always start with either 0x01 or 0x04) without any additional framing overhead.
The Network Link Identifier (NLI) is a number between 0 and 3, which is associated by the OS with one of up to four IPv6 zone indices corresponding to conceptual IPv6 interfaces on the NCP. This allows the protocol to support IPv6 nodes connecting simultaneously to more than one IPv6 network link using a single NCP instance. The first Network Link Identifier (0) MUST refer to a distinguished conceptual interface provided by the NCP for its IPv6 link type. The other three Network Link Identifiers (1, 2 and 3) MAY be dissociated from any conceptual interface.
The least significant bits of the header represent the Transaction Identifier(TID). The TID is used for correlating responses to the commands which generated them.
When a command is sent from the host, any reply to that command sent by the NCP will use the same value for the TID. When the host receives a frame that matches the TID of the command it sent, it can easily recognize that frame as the actual response to that command.
The TID value of zero (0) is used for commands to which a correlated response is not expected or needed, such as for unsolicited update commands sent to the host from the NCP.
The command identifier is a 21-bit unsigned integer encoded in up to three bytes using the packed unsigned integer format described in Section 3.2. This encoding allows for up to 2,097,152 individual commands, with the first 127 commands represented as a single byte. Command identifiers larger than 2,097,151 are explicitly forbidden.
CID Range | Description |
---|---|
0 - 63 | Reserved for core commands |
64 - 15,359 | UNALLOCATED |
15,360 - 16,383 | Vendor-specific |
16,384 - 1,999,999 | UNALLOCATED |
2,000,000 - 2,097,151 | Experimental use only |
Depending on the semantics of the command in question, a payload MAY be included in the frame. The exact composition and length of the payload is defined by the command identifier.
Data serialization for properties is performed using a light-weight data packing format which was loosely inspired by D-Bus. The format of a serialization is defined by a specially formatted string.
This packing format is used for notational convenience. While this string-based datatype format has been designed so that the strings may be directly used by a structured data parser, such a thing is not required to implement Spinel. Indeed, higly constrained applications may find such a thing to be too heavyweight.
Goals:
Each primitive datatype has an ASCII character associated with it. Structures can be represented as strings of these characters. For example:
In each case, the data is represented exactly as described. For example, an array of 10 IPv6 address is stored as 160 bytes.
Char | Name | Description |
---|---|---|
. | DATATYPE_VOID | Empty data type. Used internally. |
b | DATATYPE_BOOL | Boolean value. Encoded in 8-bits as either 0x00 or 0x01. All other values are illegal. |
C | DATATYPE_UINT8 | Unsigned 8-bit integer. |
c | DATATYPE_INT8 | Signed 8-bit integer. |
S | DATATYPE_UINT16 | Unsigned 16-bit integer. |
s | DATATYPE_INT16 | Signed 16-bit integer. |
L | DATATYPE_UINT32 | Unsigned 32-bit integer. |
l | DATATYPE_INT32 | Signed 32-bit integer. |
i | DATATYPE_UINT_PACKED | Packed Unsigned Integer. See Section 3.2. |
6 | DATATYPE_IPv6ADDR | IPv6 Address. (Big-endian) |
E | DATATYPE_EUI64 | EUI-64 Address. (Big-endian) |
e | DATATYPE_EUI48 | EUI-48 Address. (Big-endian) |
D | DATATYPE_DATA | Arbitrary data. See Section 3.3. |
d | DATATYPE_DATA_WLEN | Arbitrary data with prepended length. See Section 3.3. |
U | DATATYPE_UTF8 | Zero-terminated UTF8-encoded string. |
t(...) | DATATYPE_STRUCT | Structured datatype with prepended length. See Section 3.4. |
A(...) | DATATYPE_ARRAY | Array of datatypes. Compound type. See Section 3.5. |
All multi-byte values are little-endian unless explicitly stated otherwise.
For certain types of integers, such command or property identifiers, usually have a value on the wire that is less than 127. However, in order to not preclude the use of values larger than 255, we would need to add an extra byte. Doing this would add an extra byte to the majority of instances, which can add up in terms of bandwidth.
The packed unsigned integer format is based on the unsigned integer format in EXI, except that we limit the maximum value to the largest value that can be encoded into three bytes(2,097,151).
For all values less than 127, the packed form of the number is simply a single byte which directly represents the number. For values larger than 127, the following process is used to encode the value:
Where n is the smallest number of 7-bit chunks you can use to represent the given value.
Take the value 1337, for example:
1337 => 0x0539 => [39 0A] => [B9 0A]
To decode the value, you collect the 7-bit chunks until you find an octet with the most significant bit clear.
There are two types for data blobs: d and D.
This dichotomy allows for more efficient encoding by eliminating redundency. If the rest of the buffer is a data blob, encoding the length would be redundant because we already know how many bytes are in the rest of the buffer.
In some cases we use d even if it is the last field in a type signature. We do this to allow for us to be able to append additional fields to the type signature if necessary in the future. This is usually the case with embedded structs, like in the scan results.
For example, let's say we have a buffer that is encoded with the datatype signature of CLLD. In this case, it is pretty easy to tell where the start and end of the data blob is: the start is 9 bytes from the start of the buffer, and its length is the length of the buffer minus 9. (9 is the number of bytes taken up by a byte and two longs)
The datatype signature CLLDU is illegal because we can't determine where the last field (a zero-terminated UTF8 string) starts. But the datatype CLLdU is legal, because the parser can determine the exact length of the data blob-- allowing it to know where the start of the next field would be.
The structure data type (t(...)) is a way of bundling together several fields into a single structure. It can be thought of as a d type except that instead of being opaque, the fields in the content are known. This is useful for things like scan results where you have substructures which are defined by different layers.
For example, consider the type signature Lt(ES)t(6C). In this hypothetical case, the first struct is defined by the MAC layer, and the second struct is defined by the PHY layer. Because of the use of structures, we know exactly what part comes from that layer. Additionally, we can add fields to each structure without introducing backward compatability problems: Data encoded as Lt(ESU)t(6C) (Notice the extra U) will decode just fine as Lt(ES)t(6C). Additionally, if we don't care about the MAC layer and only care about the network layer, we could parse as Lt()t(6C).
Note that data encoded as Lt(ES)t(6C) will also parse as Ldd, with the structures from both layers now being opaque data blobs.
An array is simply a concatenated set of n data encodings. For example, the type A(6) is simply a list of IPv6 addresses---one after the other. The type A(6E) likewise a concatenation of IPv6-address/EUI-64 pairs.
If an array contains many fields, the fields will often be surrounded by a structure (t(...)). This effectively prepends each item in the array with its length. This is useful for improving parsing performance or to allow additional fields to be added in the future in a backward compatible way. If there is a high certainty that additional fields will never be added, the struct may be omitted (saving two bytes per item).
This specification does not define a way to embed an array as a field alongside other fields.
Octets: | 1 | 1 |
---|---|---|
Fields: | HEADER | CMD_NOOP |
No-Operation command. Induces the NCP to send a success status back to the host. This is primarily used for liveliness checks.
The command payload for this command SHOULD be empty. The receiver MUST ignore any non-empty command payload.
There is no error condition for this command.
Octets: | 1 | 1 |
---|---|---|
Fields: | HEADER | CMD_RESET |
Reset NCP command. Causes the NCP to perform a software reset. Due to the nature of this command, the TID is ignored. The host should instead wait for a CMD_PROP_VALUE_IS command from the NCP indicating PROP_LAST_STATUS has been set to STATUS_RESET_SOFTWARE.
The command payload for this command SHOULD be empty. The receiver MUST ignore any non-empty command payload.
If an error occurs, the value of PROP_LAST_STATUS will be emitted instead with the value set to the generated status code for the error.
Octets: | 1 | 1 | 1-3 |
---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_GET | PROP_ID |
Get property value command. Causes the NCP to emit a CMD_PROP_VALUE_IS command for the given property identifier.
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2.
If an error occurs, the value of PROP_LAST_STATUS will be emitted instead with the value set to the generated status code for the error.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_SET | PROP_ID | VALUE |
Set property value command. Instructs the NCP to set the given property to the specific given value, replacing any previous value.
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the property value. The exact format of the property value is defined by the property.
If an error occurs, the value of PROP_LAST_STATUS will be emitted with the value set to the generated status code for the error.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_INSERT | PROP_ID | VALUE |
Insert value into property command. Instructs the NCP to insert the given value into a list-oriented property, without removing other items in the list. The resulting order of items in the list is defined by the individual property being operated on.
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the value to be inserted. The exact format of the value is defined by the property.
If the type signature of the property specified by PROP_ID consists of a single structure enclosed by an array (A(t(...))), then the contents of VALUE MUST contain the contents of the structure (...) rather than the serialization of the whole item (t(...)). Specifically, the length of the structure MUST NOT be prepended to VALUE. This helps to eliminate redundant data.
If an error occurs, the value of PROP_LAST_STATUS will be emitted with the value set to the generated status code for the error.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_REMOVE | PROP_ID | VALUE |
Remove value from property command. Instructs the NCP to remove the given value from a list-oriented property, without affecting other items in the list. The resulting order of items in the list is defined by the individual property being operated on.
Note that this command operates by value, not by index!
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the value to be removed. The exact format of the value is defined by the property.
If the type signature of the property specified by PROP_ID consists of a single structure enclosed by an array (A(t(...))), then the contents of VALUE MUST contain the contents of the structure (...) rather than the serialization of the whole item (t(...)). Specifically, the length of the structure MUST NOT be prepended to VALUE. This helps to eliminate redundant data.
If an error occurs, the value of PROP_LAST_STATUS will be emitted with the value set to the generated status code for the error.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_IS | PROP_ID | VALUE |
Property value notification command. This command can be sent by the NCP in response to a previous command from the host, or it can be sent by the NCP in an unsolicited fashion to notify the host of various state changes asynchronously.
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the current value of the given property.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_INSERTED | PROP_ID | VALUE |
Property value insertion notification command. This command can be sent by the NCP in response to the CMD_PROP_VALUE_INSERT command, or it can be sent by the NCP in an unsolicited fashion to notify the host of various state changes asynchronously.
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the value that was inserted into the given property.
If the type signature of the property specified by PROP_ID consists of a single structure enclosed by an array (A(t(...))), then the contents of VALUE MUST contain the contents of the structure (...) rather than the serialization of the whole item (t(...)). Specifically, the length of the structure MUST NOT be prepended to VALUE. This helps to eliminate redundant data.
The resulting order of items in the list is defined by the given property.
Octets: | 1 | 1 | 1-3 | n |
---|---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_REMOVED | PROP_ID | VALUE |
Property value removal notification command. This command can be sent by the NCP in response to the CMD_PROP_VALUE_REMOVE command, or it can be sent by the NCP in an unsolicited fashion to notify the host of various state changes asynchronously.
Note that this command operates by value, not by index!
The payload for this command is the property identifier encoded in the packed unsigned integer format described in Section 3.2, followed by the value that was removed from the given property.
If the type signature of the property specified by PROP_ID consists of a single structure enclosed by an array (A(t(...))), then the contents of VALUE MUST contain the contents of the structure (...) rather than the serialization of the whole item (t(...)). Specifically, the length of the structure MUST NOT be prepended to VALUE. This helps to eliminate redundant data.
The resulting order of items in the list is defined by the given property.
Octets: | 1 | 1 | 4 | 2 |
---|---|---|---|---|
Fields: | HEADER | CMD_PEEK | ADDRESS | COUNT |
This command allows the NCP to fetch values from the RAM of the NCP for debugging purposes. Upon success, CMD_PEEK_RET is sent from the NCP to the host. Upon failure, PROP_LAST_STATUS is emitted with the appropriate error indication.
Due to the low-level nature of this command, certain error conditions may induce the NCP to reset.
The NCP MAY prevent certain regions of memory from being accessed.
The implementation of this command has security implications. See Section 13 for more information.
This command requires the capability CAP_PEEK_POKE to be present.
Octets: | 1 | 1 | 4 | 2 | n |
---|---|---|---|---|---|
Fields: | HEADER | CMD_PEEK_RET | ADDRESS | COUNT | BYTES |
This command contains the contents of memory that was requested by a previous call to CMD_PEEK.
This command requires the capability CAP_PEEK_POKE to be present.
Octets: | 1 | 1 | 4 | 2 | n |
---|---|---|---|---|---|
Fields: | HEADER | CMD_POKE | ADDRESS | COUNT | BYTES |
This command writes the bytes to the specified memory address for debugging purposes.
Due to the low-level nature of this command, certain error conditions may induce the NCP to reset.
The implementation of this command has security implications. See Section 13 for more information.
This command requires the capability CAP_PEEK_POKE to be present.
Fetch the value of multiple properties in one command. Arguments are an array of property IDs. If all properties are fetched successfully, a CMD_PROP_VALUES_ARE command is sent back to the host containing the propertyid and value of each fetched property. The order of the results in CMD_PROP_VALUES_ARE match the order of properties given in CMD_PROP_VALUE_GET.
Errors fetching individual properties are reflected as indicating a change to PROP_LAST_STATUS for that property's place.
Not all properties can be fetched using this method. As a general rule of thumb, any property that blocks when getting will fail for that individual property with STATUS_INVALID_COMMAND_FOR_PROP.
Octets: | 1 | 1 | n |
---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUE_MULTI_SET | Property/Value Pairs |
With each property/value pair being:
Octets: | 2 | 1-3 | n |
---|---|---|---|
Fields: | LENGTH | PROP_ID | PROP_VALUE |
This command sets the value of several properties at once in the given order. The setting of properties stops at the first error, ignoring any later properties.
The result of this command is generally CMD_PROP_VALUES_ARE unless (for example) a parsing error has occured (in which case CMD_PROP_VALUE_IS for PROP_LAST_STATUS would be the result). The order of the results in CMD_PROP_VALUES_ARE match the order of properties given in CMD_PROP_VALUE_MULTI_SET.
Since the processing of properties to set stops at the first error, the resulting CMD_PROP_VALUES_ARE can contain fewer items than the requested number of properties to set.
Not all properties can be set using this method. As a general rule of thumb, any property that blocks when setting will fail for that individual property with STATUS_INVALID_COMMAND_FOR_PROP.
Octets: | 1 | 1 | n |
---|---|---|---|
Fields: | HEADER | CMD_PROP_VALUES_ARE | Property/Value Pairs |
With each property/value pair being:
Octets: | 2 | 1-3 | n |
---|---|---|---|
Fields: | LENGTH | PROP_ID | PROP_VALUE |
This command is emitted by the NCP as the response to both the CMD_PROP_VALUE_MULTI_GET and CMD_PROP_VALUE_MULTI_SET commands. It is roughly analogous to CMD_PROP_VALUE_IS, except that it contains more than one property.
This command SHOULD NOT be emitted asynchronously, or in response to any command other than CMD_PROP_VALUE_MULTI_GET or CMD_PROP_VALUE_MULTI_SET.
The arguments are a list of structures containing the emitted property and the associated value. These are presented in the same order as given in the associated initiating command. In cases where getting or setting a specific property resulted in an error, the associated slot in this command will describe PROP_LAST_STATUS.
Spinel is largely a property-based protocol, similar to representational state transfer (REST), with a property defined for every attribute that an OS needs to create, read, update or delete in the function of an IPv6 interface. The inspiration of this approach was memory-mapped hardware registers for peripherals. The goal is to avoid, as much as possible, the use of large complicated structures and/or method argument lists. The reason for avoiding these is because they have a tendency to change, especially early in development. Adding or removing a property from a structure can render the entire protocol incompatible. By using properties, you simply extend the protocol with an additional property.
Almost all features and capabilities are implemented using properties. Most new features that are initially proposed as commands can be adapted to be property-based instead. Notable exceptions include "Host Buffer Offload" (Section 9) and "Network Save" (Section 8).
In Spinel, properties are keyed by an unsigned integer between 0 and 2,097,151 (See Section 3.2).
Properties may support one or more of the following methods:
Additionally, the NCP can send updates to the host (either synchronously or asynchronously) that inform the host about changes to specific properties:
Conceptually, there are three different types of properties:
Single-value properties are properties that have a simple representation of a single value. Examples would be:
The valid operations on these sorts of properties are GET and SET.
Multiple-Value Properties have more than one value associated with them. Examples would be:
The valid operations on these sorts of properties are VALUE_GET, VALUE_SET, VALUE_INSERT, and VALUE_REMOVE.
When the value is fetched using VALUE_GET, the returned value is the concatenation of all of the individual values in the list. If the length of the value for an individual item in the list is not defined by the type then each item returned in the list is prepended with a length (See Section 3.5). The order of the returned items, unless explicitly defined for that specific property, is undefined.
VALUE_SET provides a way to completely replace all previous values. Calling VALUE_SET with an empty value effectively instructs the NCP to clear the value of that property.
VALUE_INSERT and VALUE_REMOVE provide mechanisms for the insertion or removal of individual items by value. The payload for these commands is a plain single value.
Stream properties are special properties representing streams of data. Examples would be:
All such properties emit changes asynchronously using the VALUE_IS command, sent from the NCP to the host. For example, as IPv6 traffic is received by the NCP, the IPv6 packets are sent to the host by way of asynchronous VALUE_IS notifications.
Some of these properties also support the host send data back to the NCP. For example, this is how the host sends IPv6 traffic to the NCP.
These types of properties generally do not support VALUE_GET, as it is meaningless.
While the majority of the properties that allow the configuration of network connectivity are network protocol specific, there are several properties that are required in all implementations.
Future property allocations SHALL be made from the following allocation plan:
Property ID Range | Description |
---|---|
0 - 127 | Reserved for frequently-used properties |
128 - 15,359 | Unallocated |
15,360 - 16,383 | Vendor-specific |
16,384 - 1,999,999 | Unallocated |
2,000,000 - 2,097,151 | Experimental use only |
For an explanation of the data format encoding shorthand used throughout this document, see Section 3.
The currently assigned properties are broken up into several sections, each with reserved ranges of property identifiers. These ranges are:
Name | Range (Inclusive) | Documentation |
---|---|---|
Core | 0x00 - 0x1F, 0x1000 - 0x11FF | Section 5.5 |
PHY | 0x20 - 0x2F, 0x1200 - 0x12FF | Section 5.7 |
MAC | 0x30 - 0x3F, 0x1300 - 0x13FF | Section 5.8 |
NET | 0x40 - 0x4F, 0x1400 - 0x14FF | Section 5.9 |
Tech | 0x50 - 0x5F, 0x1500 - 0x15FF | Technology-specific |
IPv6 | 0x60 - 0x6F, 0x1600 - 0x16FF | Section 5.10 |
Stream | 0x70 - 0x7F, 0x1700 - 0x17FF | Section 5.5 |
Debug | 0x4000 - 0x4400 | Section 5.11 |
Note that some of the property sections have two reserved ranges: a primary range (which is encoded as a single byte) and an extended range (which is encoded as two bytes). properties which are used more frequently are generally allocated from the former range.
Octets: | 1-3 |
---|---|
Fields: | LAST_STATUS |
Describes the status of the last operation. Encoded as a packed unsigned integer.
This property is emitted often to indicate the result status of pretty much any Host-to-NCP operation.
It is emitted automatically at NCP startup with a value indicating the reset reason.
See Section 6 for the complete list of status codes.
Octets: | 1-3 | 1-3 |
---|---|---|
Fields: | MAJOR_VERSION | MINOR_VERSION |
Describes the protocol version information. This property contains four fields, each encoded as a packed unsigned integer:
This document describes major version 4, minor version 1 of this protocol.
The major version number is used to identify large and incompatible differences between protocol versions.
The host MUST enter a FAULT state if it does not explicitly support the given major version number.
The minor version number is used to identify small but otherwise compatible differences between protocol versions. A mismatch between the advertised minor version number and the minor version that is supported by the host SHOULD NOT be fatal to the operation of the host.
Octets: | n |
---|---|
Fields: | NCP_VESION_STRING |
Contains a string which describes the firmware currently running on the NCP. Encoded as a zero-terminated UTF-8 string.
The format of the string is not strictly defined, but it is intended to present similarly to the "User-Agent" string from HTTP. The RECOMMENDED format of the string is as follows:
STACK-NAME/STACK-VERSION[BUILD_INFO][; OTHER_INFO]; BUILD_DATE_AND_TIME
Examples:
Octets: | 1-3 |
---|---|
Fields: | INTERFACE_TYPE |
This integer identifies what the network protocol for this NCP. Currently defined values are:
The host MUST enter a FAULT state if it does not recognize the protocol given by the NCP.
Octets: | 1-3 |
---|---|
Fields: | VENDOR_ID |
Vendor identifier.
Octets: | 1-3 | 1-3 | ... |
---|---|---|---|
Fields: | CAP_1 | CAP_2 | ... |
Describes the supported capabilities of this NCP. Encoded as a list of packed unsigned integers.
A capability is defined as a 21-bit integer that describes a subset of functionality which is supported by the NCP.
Currently defined values are:
Additionally, future capability allocations SHALL be made from the following allocation plan:
Capability Range | Description |
---|---|
0 - 127 | Reserved for core capabilities |
128 - 15,359 | UNALLOCATED |
15,360 - 16,383 | Vendor-specific |
16,384 - 1,999,999 | UNALLOCATED |
2,000,000 - 2,097,151 | Experimental use only |
Octets: | 1 |
---|---|
Fields: | INTERFACE_COUNT |
Describes the number of concurrent interfaces supported by this NCP. Since the concurrent interface mechanism is still TBD, this value MUST always be one.
This value is encoded as an unsigned 8-bit integer.
Octets: | 1 |
---|---|
Fields: | POWER_STATE |
Describes the current power state of the NCP. By writing to this property you can manage the lower state of the NCP. Enumeration is encoded as a single unsigned byte.
Defined values are:
Octets: | 8 |
---|---|
Fields: | HWADDR |
The static EUI64 address of the device, used as a serial number. This value is read-only, but may be writable under certain vendor-defined circumstances.
Octets: | 1 |
---|---|
Fields: | LOCK |
Property lock. Used for grouping changes to several properties to take effect at once, or to temporarily prevent the automatic updating of property values. When this property is set, the execution of the NCP is effectively frozen until it is cleared.
This property is only supported if the CAP_LOCK capability is present.
Unlike most other properties, setting this property to true when the value of the property is already true MUST fail with a last status of STATUS_ALREADY.
Octets: | n |
---|---|
Fields: | UTF8_DATA |
This property is a streaming property, meaning that you cannot explicitly fetch the value of this property. The stream provides human-readable debugging output which may be displayed in the host logs.
The location of newline characters is not assumed by the host: it is the NCP's responsibility to insert newline characters where needed, just like with any other text stream.
To receive the debugging stream, you wait for CMD_PROP_VALUE_IS commands for this property from the NCP.
Octets: | 2 | n | n |
---|---|---|---|
Fields: | FRAME_DATA_LEN | FRAME_DATA | FRAME_METADATA |
This stream provides the capability of sending and receiving raw packets to and from the radio. The exact format of the frame metadata and data is dependent on the MAC and PHY being used.
This property is a streaming property, meaning that you cannot explicitly fetch the value of this property. To receive traffic, you wait for CMD_PROP_VALUE_IS commands with this property id from the NCP.
Implementations may OPTIONALLY support the ability to transmit arbitrary raw packets. Support for this feature is indicated by the presence of the CAP_WRITABLE_RAW_STREAM capability.
If the capability CAP_WRITABLE_RAW_STREAM is set, then packets written to this stream with CMD_PROP_VALUE_SET will be sent out over the radio. This allows the caller to use the radio directly, with the stack being implemented on the host instead of the NCP.
Any data past the end of FRAME_DATA_LEN is considered metadata and is OPTIONAL. Frame metadata MAY be empty or partially specified. Partially specified metadata MUST be accepted. Default values are used for all unspecified fields.
The same general format is used for PROP_STREAM_RAW, PROP_STREAM_NET, and PROP_STREAM_NET_INSECURE. It can be used for frames sent from the NCP to the host as well as frames sent from the host to the NCP.
The frame metadata field consists of the following fields:
Field | Description | Type | Len | Default |
---|---|---|---|---|
MD_POWER | (dBm) RSSI/TX-Power | c int8 | 1 | -128 |
MD_NOISE | (dBm) Noise floor | c int8 | 1 | -128 |
MD_FLAG | Flags (defined below) | S uint16 | 2 | |
MD_PHY | PHY-specific data | d data | >=2 | |
MD_VEND | Vendor-specific data | d data | >=2 |
The following fields are ignored by the NCP for packets sent to it from the host:
When specifying MD_POWER for a packet to be transmitted, the actual transmit power is never larger than the current value of PROP_PHY_TX_POWER (Section 5.7.6). When left unspecified (or set to the value -128), an appropriate transmit power will be chosen by the NCP.
The bit values in MD_FLAG are defined as follows:
Bit | Mask | Name | Description if set |
---|---|---|---|
15 | 0x0001 | MD_FLAG_TX | Packet was transmitted, not received. |
13 | 0x0004 | MD_FLAG_BAD_FCS | Packet was received with bad FCS |
12 | 0x0008 | MD_FLAG_DUPE | Packet seems to be a duplicate |
0-11, 14 | 0xFFF2 | MD_FLAG_RESERVED | Flags reserved for future use. |
The format of MD_PHY is specified by the PHY layer currently in use, and may contain information such as the channel, LQI, antenna, or other pertainent information.
Octets: | 2 | n | n |
---|---|---|---|
Fields: | FRAME_DATA_LEN | FRAME_DATA | FRAME_METADATA |
This stream provides the capability of sending and receiving data packets to and from the currently attached network. The exact format of the frame metadata and data is dependent on the network protocol being used.
This property is a streaming property, meaning that you cannot explicitly fetch the value of this property. To receive traffic, you wait for CMD_PROP_VALUE_IS commands with this property id from the NCP.
To send network packets, you call CMD_PROP_VALUE_SET on this property with the value of the packet.
Any data past the end of FRAME_DATA_LEN is considered metadata, the format of which is described in Section 5.6.2.1.
Octets: | 2 | n | n |
---|---|---|---|
Fields: | FRAME_DATA_LEN | FRAME_DATA | FRAME_METADATA |
This stream provides the capability of sending and receiving unencrypted and unauthenticated data packets to and from nearby devices for the purposes of device commissioning. The exact format of the frame metadata and data is dependent on the network protocol being used.
This property is a streaming property, meaning that you cannot explicitly fetch the value of this property. To receive traffic, you wait for CMD_PROP_VALUE_IS commands with this property id from the NCP.
To send network packets, you call CMD_PROP_VALUE_SET on this property with the value of the packet.
Any data past the end of FRAME_DATA_LEN is considered metadata, the format of which is described in Section 5.6.2.1.
Set to 1 if the PHY is enabled, set to 0 otherwise. May be directly enabled to bypass higher-level packet processing in order to implement things like packet sniffers.
Value is the current channel. Must be set to one of the values contained in PROP_PHY_CHAN_SUPPORTED.
Value is a list of channel values that are supported by the hardware.
Value is the radio frequency (in kilohertz) of the current channel.
Value is the CCA (clear-channel assessment) threshold. Set to -128 to disable.
When setting, the value will be rounded down to a value that is supported by the underlying radio hardware.
Value is the transmit power of the radio.
When setting, the value will be rounded down to a value that is supported by the underlying radio hardware.
Value is the current RSSI (Received signal strength indication) from the radio. This value can be used in energy scans and for determining the ambient noise floor for the operating environment.
Value is the radio receive sensitivity. This value can be used as lower bound noise floor for link metrics computation.
Possible Values:
Set to SCAN_STATE_BEACON to start an active scan. Beacons will be emitted from PROP_MAC_SCAN_BEACON.
Set to SCAN_STATE_ENERGY to start an energy scan. Channel energy result will be reported by emissions of PROP_MAC_ENERGY_SCAN_RESULT (per channel).
Set to SCAN_STATE_DISOVER to start a Thread MLE discovery scan operation. Discovery scan result will be emitted from PROP_MAC_SCAN_BEACON.
Value switches to SCAN_STATE_IDLE when scan is complete.
Octets: | 1 | 1 | 2 | n | 2 | n |
---|---|---|---|---|---|---|
Fields: | CH | RSSI | MAC_LEN | MAC_DATA | NET_LEN | NET_DATA |
Scan beacons have two embedded structures which contain information about the MAC layer and the NET layer. Their format depends on the MAC and NET layer currently in use. The format below is for an 802.15.4 MAC with Thread:
Extra parameters may be added to each of the structures in the future, so care should be taken to read the length that prepends each structure.
The 802.15.4 long address of this node.
This property is only present on NCPs which implement 802.15.4
The 802.15.4 short address of this node.
This property is only present on NCPs which implement 802.15.4
The 802.15.4 PANID this node is associated with.
This property is only present on NCPs which implement 802.15.4
Set to true to enable raw MAC frames to be emitted from PROP_STREAM_RAW. See Section 5.6.2.
Possible Values:
Id | Name | Description |
---|---|---|
0 | MAC_PROMISCUOUS_MODE_OFF | Normal MAC filtering is in place. |
1 | MAC_PROMISCUOUS_MODE_NETWORK | All MAC packets matching network are passed up the stack. |
2 | MAC_PROMISCUOUS_MODE_FULL | All decoded MAC packets are passed up the stack. |
See Section 5.6.2.
This property is emitted during energy scan operation per scanned channel with following format:
Structure Parameters:
Returns true if there is a network state stored/saved.
Network interface up/down status. Non-zero (set to 1) indicates up, zero indicates down.
Thread stack operational status. Non-zero (set to 1) indicates up, zero indicates down.
Values:
The partition ID of the partition that this node is a member of.
IPv6 Address
IPv6 Address + Prefix Length
IPv6 Prefix + Prefix Length
Array of structures containing:
Allow the NCP to directly respond to ICMP ping requests. If this is turned on, ping request ICMP packets will not be passed to the host.
Default value is false.
Reading this property will cause an assert on the NCP. This is intended for testing the assert functionality of underlying platform/NCP. Assert should ideally cause the NCP to reset, but if assert is not supported or disabled boolean value of false is returned in response.
Provides access to the NCP log level. Currently defined values are (which follows the RFC 5424):
If the NCP supports dynamic log level control, setting this property changes the log level accordingly. Getting the value returns the current log level. If the dynamic log level control is not supported, setting this property returns a PROP_LAST_STATUS with STATUS_INVALID_COMMAND_FOR_PROP.
Status codes are sent from the NCP to the host via PROP_LAST_STATUS using the CMD_VALUE_IS command to indicate the return status of a previous command. As with any response, the TID field of the FLAG byte is used to correlate the response with the request.
Note that most successfully executed commands do not indicate a last status of STATUS_OK. The usual way the NCP indicates a successful command is to mirror the property change back to the host. For example, if you do a CMD_VALUE_SET on PROP_PHY_ENABLED, the NCP would indicate success by responding with a CMD_VALUE_IS for PROP_PHY_ENABLED. If the command failed, PROP_LAST_STATUS would be emitted instead.
See Section 5.5.1 for more information on PROP_LAST_STATUS.
This section describes all of the properties and semantics required for managing a Thread(R) NCP.
Thread(R) NCPs have the following requirements:
All serious implementations of an NCP SHOULD also support the network save feature (See Section 8).
The Thread(R) technology defines the following capabilities:
Properties for Thread(R) are allocated out of the Tech property section (see Section 5.4).
The IPv6 address of the leader. (Note: May change to long and short address of leader)
The long address and short address of the parent of this node.
Table containing the long and short addresses of all the children of this node.
The router-id of the current leader.
The leader weight of the current leader.
The leader weight for this node.
The local network data.
The local stable network data.
Data per item is:
Data per item is:
Set to true before changing local net data. Set to false when finished. This allows changes to be aggregated into single events.
This property contains the value of the mode TLV for this node. The meaning of the bits in this bitfield are defined by section 4.5.2 of the Thread(R) specification.
Used when operating in the Child role.
Allows you to get or set the Thread(R) NETWORK_ID_TIMEOUT constant, as defined by the Thread(R) specification.
Note that some implementations may not support CMD_GET_VALUE router ids, but may support CMD_REMOVE_VALUE when the node is a leader.
Allow the HOST to directly observe all IPv6 packets received by the NCP, including ones sent to the RLOC16 address.
Default value is false.
Allow the HOST to indicate whether or not the router role is enabled. If current role is a router, setting this property to false starts a re-attach process as an end-device.
Specifies the self imposed random delay in seconds a REED waits before registering to become an Active Router.
Specifies the preferred Router Id. Upon becoming a router/leader the node attempts to use this Router Id. If the preferred Router Id is not set or if it can not be used, a randomly generated router id is picked. This property can be set only when the device role is either detached or disabled.
Data per item is:
Specifies the maximum number of children currently allowed. This parameter can only be set when Thread(R) protocol operation has been stopped.
The leader network data.
The stable leader network data.
Data per item is:
Passess Pre-Shared Key for the Device to the NCP in the commissioning process. When the Extended address is ommited all Devices which provided a valid PSKd are allowed to join the Thread(R) Network.
Set to true to enable the native commissioner. It is mandatory before adding the joiner to the network.
Set to true to enable the border agent proxy.
Data per item is:
Octects: | 2 | n | 2 | 2 |
---|---|---|---|---|
Fields: | Length | CoAP | locator | port |
This property allows the host to send and receive border-agent-related CoAP requests/responses from the NCP's RLOC address. This allows the host driver to implement a Thread(R) border agent.
This property specifies the value used in Thread(R) MLE Discovery Request TLV during discovery scan operation. Default value is false.
This property is used to enable/disable EUI64 filtering during discovery scan operation. Default value is false.
This property specifies the PANID used for filtering during discovery scan operation. Default value is 0xffff (broadcast PANID) which disables PANID filtering.
This property can be used to set the steering data for MLE Discovery Response messages.
The network save/recall feature is an optional NCP capability that, when present, allows the host to save and recall network credentials and state to and from nonvolatile storage.
The presence of the save/recall feature can be detected by checking for the presence of the CAP_NET_SAVE capability in PROP_CAPS.
Network clear feature allows host to erase all network credentials and state from non-volatile memory.
Octets: | 1 | 1 |
---|---|---|
Fields: | HEADER | CMD_NET_SAVE |
Save network state command. Saves any current network credentials and state necessary to reconnect to the current network to non-volatile memory.
This operation affects non-volatile memory only. The current network information stored in volatile memory is unaffected.
The response to this command is always a CMD_PROP_VALUE_IS for PROP_LAST_STATUS, indicating the result of the operation.
This command is only available if the CAP_NET_SAVE capability is set.
Octets: | 1 | 1 |
---|---|---|
Fields: | HEADER | CMD_NET_CLEAR |
Clear saved network settings command. Erases all network credentials and state from non-volatile memory. The erased settings include any data saved automatically by the network stack firmware and/or data saved by CMD_NET_SAVE operation.
This operation affects non-volatile memory only. The current network information stored in volatile memory is unaffected.
The response to this command is always a CMD_PROP_VALUE_IS for PROP_LAST_STATUS, indicating the result of the operation.
This command is always available independent of the value of CAP_NET_SAVE capability.
Octets: | 1 | 1 |
---|---|---|
Fields: | HEADER | CMD_NET_RECALL |
Recall saved network state command. Recalls any previously saved network credentials and state previously stored by CMD_NET_SAVE from non-volatile memory.
This command will typically generated several unsolicited property updates as the network state is loaded. At the conclusion of loading, the authoritative response to this command is always a CMD_PROP_VALUE_IS for PROP_LAST_STATUS, indicating the result of the operation.
This command is only available if the CAP_NET_SAVE capability is set.
The memory on an NCP may be much more limited than the memory on the host processor. In such situations, it is sometimes useful for the NCP to offload buffers to the host processor temporarily so that it can perform other operations.
Host buffer offload is an optional NCP capability that, when present, allows the NCP to store data buffers on the host processor that can be recalled at a later time.
The presence of this feature can be detected by the host by checking for the presence of the CAP_HBO capability in PROP_CAPS.
Octets: | 4 |
---|---|
Fields: | PROP_HBO_MEM_MAX |
Describes the number of bytes that may be offloaded from the NCP to the host. Default value is zero, so this property must be set by the host to a non-zero value before the NCP will begin offloading blocks.
This value is encoded as an unsigned 32-bit integer.
This property is only available if the CAP_HBO capability is present in PROP_CAPS.
Octets: | 2 |
---|---|
Fields: | PROP_HBO_BLOCK_MAX |
Describes the number of blocks that may be offloaded from the NCP to the host. Default value is 32. Setting this value to zero will cause host block offload to be effectively disabled.
This value is encoded as an unsigned 16-bit integer.
This property is only available if the CAP_HBO capability is present in PROP_CAPS.
Jamming detection is a feature that allows the NCP to report when it detects high levels of interference that are characteristic of intentional signal jamming.
The presence of this feature can be detected by checking for the presence of the CAP_JAM_DETECT (value 6) capability in PROP_CAPS.
Octets: | 1 |
---|---|
Fields: | PROP_JAM_DETECT_ENABLE |
Indicates if jamming detection is enabled or disabled. Set to true to enable jamming detection.
This property is only available if the CAP_JAM_DETECT capability is present in PROP_CAPS.
Octets: | 1 |
---|---|
Fields: | PROP_JAM_DETECTED |
Set to true if radio jamming is detected. Set to false otherwise.
When jamming detection is enabled, changes to the value of this property are emitted asynchronously via CMD_PROP_VALUE_IS.
This property is only available if the CAP_JAM_DETECT capability is present in PROP_CAPS.
This parameter describes the threshold RSSI level (measured in dBm) above which the jamming detection will consider the channel blocked.
This parameter describes the window period for signal jamming detection.
This parameter describes the number of aggregate seconds within the detection window where the RSSI must be above PROP_JAM_DETECT_RSSI_THRESHOLD to trigger detection.
The behavior of the jamming detection feature when PROP_JAM_DETECT_BUSY is larger than PROP_JAM_DETECT_WINDOW is undefined.
This value provides information about current state of jamming detection module for monitoring/debugging purpose. It returns a 64-bit value where each bit corresponds to one second interval starting with bit 0 for the most recent interval and bit 63 for the oldest intervals (63 sec earlier). The bit is set to 1 if the jamming detection module observed/detected high signal level during the corresponding one second interval. The value is read-only and is encoded as two L (uint32) values in little-endian format (first L (uint32) value gives the lower bits corresponding to more recent history).
This feature allows the host to have control over some or all of the GPIO pins on the NCP. The host can determine which GPIOs are available by examining PROP_GPIO_CONFIG, described below. This API supports a maximum of 256 individual GPIO pins.
Support for this feature can be determined by the presence of CAP_GPIO.
An array of structures which contain the following fields:
GPIOs which do not have a corresponding entry are not supported.
The configuration parameter contains the configuration flags for the GPIO:
0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ |DIR|PUP|PDN|TRIGGER| RESERVED | +---+---+---+---+---+---+---+---+ |O/D| +---+
As an optional feature, the configuration of individual pins may be modified using the CMD_PROP_VALUE_INSERT command. Only the GPIO number and flags fields MUST be present, the GPIO name (if present) would be ignored. This command can only be used to modify the configuration of GPIOs which are already exposed---it cannot be used by the host to add addional GPIOs.
Contains a bit field identifying the state of the GPIOs. The length of the data associated with these properties depends on the number of GPIOs. If you have 10 GPIOs, you'd have two bytes. GPIOs are numbered from most significant bit to least significant bit, so 0x80 is GPIO 0, 0x40 is GPIO 1, etc.
For GPIOs configured as inputs:
For GPIOs configured as outputs:
For GPIOs which are not specified in PROP_GPIO_CONFIG:
When writing, unspecified bits are assumed to be zero.
Allows for the state of various output GPIOs to be set without affecting other GPIO states. Contains a bit field identifying the output GPIOs that should have their state set to 1.
When writing, unspecified bits are assumed to be zero. The value of any bits for GPIOs which are not specified in PROP_GPIO_CONFIG MUST be ignored.
Allows for the state of various output GPIOs to be cleared without affecting other GPIO states. Contains a bit field identifying the output GPIOs that should have their state cleared to 0.
When writing, unspecified bits are assumed to be zero. The value of any bits for GPIOs which are not specified in PROP_GPIO_CONFIG MUST be ignored.
This feature allows the host to have access to any strong hardware random number generator that might be present on the NCP, for things like key generation or seeding PRNGs.
Support for this feature can be determined by the presence of CAP_TRNG.
Note well that implementing a cryptographically-strong software-based true random number generator (that is impervious to things like temperature changes, manufacturing differences across devices, or unexpected output correlations) is non-trivial without a well-designed, dedicated hardware random number generator. Implementors who have little or no experience in this area are encouraged to not advertise this capability.
Fetching this property returns a strong random 32-bit integer that is suitable for use as a PRNG seed or for cryptographic use.
While the exact mechanism behind the calculation of this value is implementation-specific, the implementation must satisfy the following requirements:
Support for this property is REQUIRED if CAP_TRNG is included in the device capabilities.
Fetching this property returns 16 bytes of strong random data suitable for direct cryptographic use without further processing(For example, as an AES key).
While the exact mechanism behind the calculation of this value is implementation-specific, the implementation must satisfy the following requirements:
Support for this property is REQUIRED if CAP_TRNG is included in the device capabilities.
This property is primarily used to diagnose and debug the behavior of the entropy source used for strong random number generation.
When queried, returns the raw output from the entropy source used to generate PROP_TRNG_32, prior to any reduction/whitening and/or mixing with prior state.
The length of the returned buffer is implementation specific and should be expected to be non-deterministic.
Support for this property is RECOMMENDED if CAP_TRNG is included in the device capabilities.
Spinel MAY be used as an API boundary for allowing processes to configure the NCP. However, such a system MUST NOT give unprivileged processess the ability to send or receive arbitrary command frames to the NCP. Only the specific commands and properties that are required should be allowed to be passed, and then only after being checked for proper format.
Since this NCP protocol is defined independently of the physical transport or framing, any number of transports and framing protocols could be used successfully. However, in the interests of compatibility, this document provides some recommendations.
The recommended default UART settings are:
These values may be adjusted depending on the individual needs of the application or product, but some sort of flow control MUST be used. Hardware flow control is preferred over software flow control. In the absence of hardware flow control, software flow control (XON/XOFF) MUST be used instead.
We also RECOMMEND an Arduino-style hardware reset, where the DTR signal is coupled to the R̅E̅S̅ pin through a 0.01µF capacitor. This causes the NCP to automatically reset whenever the serial port is opened. At the very least we RECOMMEND dedicating one of your host pins to controlling the R̅E̅S̅ pin on the NCP, so that you can easily perform a hardware reset if necessary.
When using a UART, the issue of an appropriate bit rate must be considered. A bitrate of 115200 bits per second has become a defacto standard baud rate for many serial peripherals. This rate, however, is slower than the theoretical maximum bitrate of the 802.15.4 2.4GHz PHY (250kbit). In most circumstances this mismatch is not significant because the overall bitrate will be much lower than either of these rates, but there are circumstances where a faster UART bitrate is desirable. Thus, this document proposes a simple bitrate detection scheme that can be employed by the host to detect when the attached NCP is initially running at a higher bitrate.
The algorithm is to send successive NOOP commands to the NCP at increasing bitrates. When a valid CMD_LAST_STATUS response has been received, we have identified the correct bitrate.
In order to limit the time spent hunting for the appropriate bitrate, we RECOMMEND that only the following bitrates be checked:
The bitrate MAY also be changed programmatically by adjusting PROP_UART_BITRATE, if implemented.
HDLC-Lite is the recommended framing protocol for transmitting Spinel frames over a UART. HDLC-Lite consists of only the framing, escaping, and CRC parts of the larger HDLC protocol---all other parts of HDLC are omitted. This protocol was chosen because it works well with software flow control and is widely implemented.
To transmit a frame with HDLC-lite, the 16-bit CRC must first be appended to the frame. The CRC function is defined to be CRC-16/CCITT, otherwise known as the KERMIT CRC.
Individual frames are terminated with a frame delimiter octet called the 'flag' octet (0x7E).
The following octets values are considered special and should be escaped when present in data frames:
Octet Value | Description |
---|---|
0x7E | Frame Delimiter (Flag) |
0x7D | Escape Byte |
0x11 | XON |
0x13 | XOFF |
0xF8 | Vendor-Specific |
When present in a data frame, these octet values are escaped by prepending the escape octet (0x7D) and XORing the value with 0x20.
When receiving a frame, the CRC must be verified after the frame is unescaped. If the CRC value does not match what is calculated for the frame data, the frame MUST be discarded. The implementation MAY indicate the failure to higher levels to handle as they see fit, but MUST NOT attempt to process the deceived frame.
Consecutive flag octets are entirely legal and MUST NOT be treated as a framing error. Consecutive flag octets MAY be used as a way to wake up a sleeping NCP.
When first establishing a connection to the NCP, it is customary to send one or more flag octets to ensure that any previously received data is discarded.
We RECOMMEND the use of the following standard SPI signals:
The I̅N̅T̅ signal is used by the NCP to indicate to the host that the NCP has frames pending to send to it. When asserted, the host SHOULD initiate a SPI transaction in a timely manner.
We RECOMMEND the following SPI properties:
This recommended configuration may be adjusted depending on the individual needs of the application or product.
Each SPI frame starts with a 5-byte frame header:
Octets: | 1 | 2 | 2 |
---|---|---|---|
Fields: | HDR | RECV_LEN | DATA_LEN |
The HDR byte is defined as:
0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ |RST|CRC|CCF| RESERVED |PATTERN| +---+---+---+---+---+---+---+---+
Prior to a sending or receiving a frame, the master MAY send a 5-octet frame with zeros for both the max receive frame size and the the contained frame length. This will induce the slave device to indicate the length of the frame it wants to send (if any) and indicate the largest frame it is capable of receiving at the moment. This allows the master to calculate the size of the next transaction. Alternatively, if the master has a frame to send it can just go ahead and send a frame of that length and determine if the frame was accepted by checking that the RECV_LEN from the slave frame is larger than the frame the master just tried to send. If the RECV_LEN is smaller then the frame wasn't accepted and will need to be transmitted again.
This protocol can be used either unidirectionally or bidirectionally, determined by the behavior of the master and the slave.
If the the master notices PATTERN is not set correctly, the master should consider the transaction to have failed and try again after 10 milliseconds, retrying up to 200 times. After unsuccessfully trying 200 times in a row, the master MAY take appropriate remedial action (like a NCP hardware reset, or indicating a communication failure to a user interface).
At the end of the data of a frame is an optional 16-bit CRC, support for which is indicated by the CRC bit of the HDR byte being set. If these bits are set for both the master and slave frames, then CRC checking is enabled on both sides, effectively requiring that frame sizes be two bytes longer than would be otherwise required. The CRC is calculated using the same mechanism used for the CRC calculation in HDLC-Lite (See Appendix A.1.2). When both of the CRC bits are set, both sides must verify that the CRC is valid before accepting the frame. If not enough bytes were clocked out for the CRC to be read, then the frame must be ignored. If enough bytes were clocked out to perform a CRC check, but the CRC check fails, then the frame must be rejected and the CRC_FAIL bit on the next frame (and ONLY the next frame) MUST be set.
TBD
TBD
Decimal Value | Packet Octet Encoding |
---|---|
0 | 00 |
1 | 01 |
127 | 7F |
128 | 80 01 |
129 | 81 01 |
1,337 | B9 0A |
16,383 | FF 7F |
16,384 | 80 80 01 |
16,385 | 81 80 01 |
2,097,151 | FF FF 7F |
[CREF4]RQ: The PUI test-vector encodings need to be verified.
Frame:
80 01
Frame:
80 06 00 72
Frame:
80 07 33 0F C4 0D 00 B6 40 D4 8C E9 38 F9 52 FF FF D2 04 00 13 00 03 20 73 70 69 6E 65 6C 00 08 00 DE AD 00 BE EF 00 CA FE
CMD_VALUE_IS(PROP_STREAM_NET)
[CREF5]RQ: FIXME: This test vector is incomplete.
CMD_VALUE_SET(PROP_STREAM_NET)
[CREF6]RQ: FIXME: This test vector is incomplete.
Frame:
84 02 5A
IPv6 Prefix | Prefix Length | Stable Flag | Other Flags |
---|---|---|---|
2001:DB8:1:: | 64 | True | ?? |
2001:DB8:2:: | 64 | False | ?? |
Frame:
84 06 5A 13 00 20 01 0D B8 00 01 00 00 00 00 00 00 00 00 00 00 40 01 ?? 13 00 20 01 0D B8 00 02 00 00 00 00 00 00 00 00 00 00 40 00 ??
IPv6 Prefix | Prefix Length | Stable Flag | Other Flags |
---|---|---|---|
2001:DB8:3:: | 64 | True | ?? |
Frame:
85 03 5A 20 01 0D B8 00 03 00 00 00 00 00 00 00 00 00 00 40 01 ?? 01
[CREF7]RQ: FIXME: This test vector is incomplete.
IPv6 Prefix | Prefix Length | Stable Flag | Other Flags |
---|---|---|---|
2001:DB8:3:: | 64 | True | ?? |
Frame:
85 07 5A 20 01 0D B8 00 03 00 00 00 00 00 00 00 00 00 00 40 01 ?? 01
[CREF8]RQ: FIXME: This test vector is incomplete.
Frame:
86 05 5A 20 01 0D B8 00 03 00 00 00 00 00 00 00 00 00 00
Frame:
86 08 5A 20 01 0D B8 00 03 00 00 00 00 00 00 00 00 00 00
[CREF9]RQ: FIXME: This example session is incomplete.
Check the protocol version to see if it is supported:
Check the NCP version to see if a firmware update may be necessary:
Check interface type to make sure that it is what we expect:
If the host supports using vendor-specific commands, the vendor should be verified before using them:
Fetch the capability list so that we know what features this NCP supports:
If the NCP supports CAP_NET_SAVE, then we go ahead and recall the network:
[CREF10]RQ: FIXME: This example session is incomplete.
We make the assumption that the NCP is not currently associated with a network.
Set the network properties, if they were not already set:
Bring the network interface up:
Bring the routing stack up:
Some asynchronous events from the NCP:
[CREF11]RQ: FIXME: This example session is incomplete.
This example session is identical to the above session up to the point where we set PROP_NET_IF_UP to true. From there, the behavior changes.
Bring the routing stack up:
Some asynchronous events from the NCP:
Now let's save the network settings to NVRAM:
This example session is identical to the above session up to the point where we set PROP_NET_IF_UP to true. From there, the behavior changes.
Bring the routing stack up:
Some asynchronous events from the NCP:
TBD
[CREF12]RQ: FIXME: This example session is incomplete.
Recall the saved network if you haven't already done so:
Bring the network interface up:
Bring the routing stack up:
Some asynchronous events from the NCP:
[CREF13]RQ: FIXME: This example session is incomplete.
Then jump to Appendix C.1.
TBD
TBD
[CREF14]RQ: FIXME: This example session is incomplete.
This assumes that the NCP has been initialized.
Optionally set the channel:
Set the filter mode:
Enable the raw stream:
Enable the PHY directly:
Now we will get raw 802.15.4 packets asynchronously on PROP_STREAM_RAW:
This mode may be entered even when associated with a network. In that case, you should set PROP_MAC_PROMISCUOUS_MODE to MAC_PROMISCUOUS_MODE_PROMISCUOUS or MAC_PROMISCUOUS_MODE_NORMAL, so that you can avoid receiving packets from other networks or that are destined for other nodes.
[CREF15]RQ: Alphabetize before finalization.
Thread is a registered trademark of The Thread Group, Inc.
Special thanks to Nick Banks, Jonathan Hui, Abtin Keshavarzian, Piotr Szkotak, Arjuna Sivasithambaresan and Martin Turon for their substantial contributions and feedback related to this document.
This document was prepared using mmark by (Miek Gieben) and xml2rfc (version 2).