ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
thread.h File Reference

Thread spinel / HDLC-lite framing codec (PROTOCORE_ENABLE_THREAD) - OpenThread RCP. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  SpinelReader
 A read cursor over a spinel property value. More...
 
struct  SpinelWriter
 A write cursor building a spinel property value into a caller buffer. More...
 
struct  SpinelPropInfo
 A registry entry: a property id, its human name, and its primary spinel datatype char. More...
 
struct  ThreadNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Macros

#define HDLC_FLAG   0x7E
 HDLC-lite markers.
 
#define HDLC_ESCAPE   0x7D
 byte-stuffing escape
 
#define SPINEL_CMD_NOOP   0
 Common spinel commands (the property accessors a gateway uses).
 
#define SPINEL_CMD_RESET   1
 
#define SPINEL_CMD_PROP_VALUE_GET   2
 
#define SPINEL_CMD_PROP_VALUE_SET   3
 
#define SPINEL_CMD_PROP_VALUE_INSERT   4
 
#define SPINEL_CMD_PROP_VALUE_REMOVE   5
 
#define SPINEL_CMD_PROP_VALUE_IS   6
 an async property update from the NCP
 
#define SPINEL_CMD_PROP_VALUE_INSERTED   7
 a list property gained an entry
 
#define SPINEL_CMD_PROP_VALUE_REMOVED   8
 a list property lost an entry
 
#define SPINEL_PROP_LAST_STATUS   0
 The spinel property ids a Thread/802.15.4 gateway reads or writes (subset of the spinel property registry, grouped CORE / PHY / MAC / NET / IPv6 / STREAM).
 
#define SPINEL_PROP_PROTOCOL_VERSION   1
 'ii' major, minor
 
#define SPINEL_PROP_NCP_VERSION   2
 'U' NCP version string
 
#define SPINEL_PROP_INTERFACE_TYPE   3
 'i' 3 = Thread
 
#define SPINEL_PROP_VENDOR_ID   4
 'i'
 
#define SPINEL_PROP_CAPS   5
 'A(i)' capability list
 
#define SPINEL_PROP_INTERFACE_COUNT   6
 'C'
 
#define SPINEL_PROP_HWADDR   8
 'E' factory EUI64
 
#define SPINEL_PROP_LOCK   9
 'b'
 
#define SPINEL_PROP_PHY_ENABLED   0x20
 'b'
 
#define SPINEL_PROP_PHY_CHAN   0x21
 'C' 802.15.4 channel
 
#define SPINEL_PROP_PHY_CHAN_SUPPORTED   0x22
 'A(C)'
 
#define SPINEL_PROP_PHY_FREQ   0x23
 'L' kHz
 
#define SPINEL_PROP_PHY_TX_POWER   0x25
 'c' dBm
 
#define SPINEL_PROP_PHY_RSSI   0x26
 'c' dBm
 
#define SPINEL_PROP_MAC_SCAN_STATE   0x30
 'C'
 
#define SPINEL_PROP_MAC_SCAN_MASK   0x31
 'A(C)'
 
#define SPINEL_PROP_MAC_SCAN_PERIOD   0x32
 'S' ms/channel
 
#define SPINEL_PROP_MAC_15_4_LADDR   0x34
 'E' extended (long) address
 
#define SPINEL_PROP_MAC_15_4_SADDR   0x35
 'S' short address
 
#define SPINEL_PROP_MAC_15_4_PANID   0x36
 'S' PAN id
 
#define SPINEL_PROP_NET_SAVED   0x40
 'b'
 
#define SPINEL_PROP_NET_IF_UP   0x41
 'b'
 
#define SPINEL_PROP_NET_STACK_UP   0x42
 'b'
 
#define SPINEL_PROP_NET_ROLE   0x43
 'C' 0 detached,1 child,2 router,3 leader
 
#define SPINEL_PROP_NET_NETWORK_NAME   0x44
 'U'
 
#define SPINEL_PROP_NET_XPANID   0x45
 'D' 8-byte extended PAN id
 
#define SPINEL_PROP_NET_NETWORK_KEY   0x46
 'D' 16-byte network key
 
#define SPINEL_PROP_IPV6_LL_ADDR   0x60
 '6' link-local
 
#define SPINEL_PROP_IPV6_ML_ADDR   0x61
 '6' mesh-local
 
#define SPINEL_PROP_STREAM_DEBUG   0x70
 'U' debug text
 
#define SPINEL_PROP_STREAM_RAW   0x71
 'dD' raw 802.15.4 frame + metadata
 
#define SPINEL_PROP_STREAM_NET   0x72
 'dD' IPv6 datagram + metadata
 
#define SPINEL_STATUS_OK   0
 spinel LAST_STATUS codes (a subset - the ones a gateway acts on).
 
#define SPINEL_STATUS_FAILURE   1
 
#define SPINEL_STATUS_UNIMPLEMENTED   2
 
#define SPINEL_STATUS_INVALID_ARGUMENT   3
 
#define SPINEL_STATUS_INVALID_STATE   4
 
#define SPINEL_STATUS_INVALID_COMMAND   5
 
#define SPINEL_STATUS_INVALID_INTERFACE   6
 
#define SPINEL_STATUS_INTERNAL_ERROR   7
 
#define SPINEL_STATUS_SECURITY_ERROR   8
 
#define SPINEL_STATUS_PARSE_ERROR   9
 
#define SPINEL_STATUS_IN_PROGRESS   10
 
#define SPINEL_STATUS_NOMEM   11
 
#define SPINEL_STATUS_BUSY   12
 
#define SPINEL_STATUS_PROP_NOT_FOUND   13
 
#define SPINEL_STATUS_DROPPED   14
 
#define SPINEL_STATUS_EMPTY   15
 
#define SPINEL_STATUS_RESET_POWER_ON   112
 first of the reset-cause block
 
#define SPINEL_STATUS_RESET_END   128
 one past the block: 112..127 are all reset causes
 

Functions

 PROTOCORE_NS_LAYOUT (ThreadNs, spinel_fcs, spinel_pack_uint, spinel_unpack_uint, spinel_command_build, spinel_command_parse, spinel_reader_init, spinel_get_bool, spinel_get_u8, spinel_get_i8, spinel_get_u16, spinel_get_i16, spinel_get_u32, spinel_get_i32, spinel_get_uint, spinel_get_eui64, spinel_get_ipv6, spinel_get_utf8, spinel_get_data, spinel_get_data_wlen, spinel_reader_ok, spinel_writer_init, spinel_put_bool, spinel_put_u8, spinel_put_i8, spinel_put_u16, spinel_put_i16, spinel_put_u32, spinel_put_i32, spinel_put_uint, spinel_put_eui64, spinel_put_ipv6, spinel_put_utf8, spinel_put_data, spinel_put_data_wlen, spinel_writer_len, spinel_prop_lookup, spinel_prop_name, spinel_status_name, spinel_frame_encode, spinel_frame_decode)
 
uint16_t protocore_thread_spinel_fcs (uint8_t *work, const uint8_t *buf, uint16_t len)
 HDLC frame check sequence: CRC-16/X-25 over buf.
 
uint8_t protocore_thread_spinel_pack_uint (uint8_t *work, uint32_t value, uint8_t *out, uint8_t cap)
 Encode a spinel packed unsigned integer (7 bits/byte, .
 
int protocore_thread_spinel_unpack_uint (uint8_t *work, const uint8_t *raw, uint8_t len, uint32_t *value)
 Decode a spinel packed unsigned integer from the front of raw.
 
uint16_t protocore_thread_spinel_command_build (uint8_t *work, uint8_t header, uint32_t cmd, uint32_t prop, const uint8_t *value, uint16_t value_len, uint8_t *out, uint16_t cap)
 Build a spinel property-command payload (`header | CMD | PROP | .
 
int protocore_thread_spinel_command_parse (uint8_t *work, const uint8_t *payload, uint16_t len, uint8_t *header, uint32_t *cmd, uint32_t *prop, const uint8_t **value, uint16_t *value_len)
 Parse a spinel property-command payload (from a decoded HDLC frame).
 
void protocore_thread_spinel_reader_init (uint8_t *work, SpinelReader *r, const uint8_t *value, uint16_t len)
 Spinel_reader_init.
 
proto_bool protocore_thread_spinel_get_bool (uint8_t *work, SpinelReader *r, proto_bool *out)
 Spinel_get_bool.
 
proto_bool protocore_thread_spinel_get_u8 (uint8_t *work, SpinelReader *r, uint8_t *out)
 Spinel_get_u8.
 
proto_bool protocore_thread_spinel_get_i8 (uint8_t *work, SpinelReader *r, int8_t *out)
 Spinel_get_i8.
 
proto_bool protocore_thread_spinel_get_u16 (uint8_t *work, SpinelReader *r, uint16_t *out)
 Spinel_get_u16.
 
proto_bool protocore_thread_spinel_get_i16 (uint8_t *work, SpinelReader *r, int16_t *out)
 Spinel_get_i16.
 
proto_bool protocore_thread_spinel_get_u32 (uint8_t *work, SpinelReader *r, uint32_t *out)
 Spinel_get_u32.
 
proto_bool protocore_thread_spinel_get_i32 (uint8_t *work, SpinelReader *r, int32_t *out)
 Spinel_get_i32.
 
proto_bool protocore_thread_spinel_get_uint (uint8_t *work, SpinelReader *r, uint32_t *out)
 Spinel_get_uint.
 
proto_bool protocore_thread_spinel_get_eui64 (uint8_t *work, SpinelReader *r, const uint8_t **out8)
 Spinel_get_eui64.
 
proto_bool protocore_thread_spinel_get_ipv6 (uint8_t *work, SpinelReader *r, const uint8_t **out16)
 Spinel_get_ipv6.
 
proto_bool protocore_thread_spinel_get_utf8 (uint8_t *work, SpinelReader *r, const char **out, uint16_t *out_len)
 UTF8 'U': out points into the value, out_len excludes the NUL; .
 
proto_bool protocore_thread_spinel_get_data (uint8_t *work, SpinelReader *r, const uint8_t **out, uint16_t *out_len)
 Data 'D' (to end of value): out points into the value, out_len is .
 
proto_bool protocore_thread_spinel_get_data_wlen (uint8_t *work, SpinelReader *r, const uint8_t **out, uint16_t *out_len)
 Data 'd' (uint16-LE length prefix): reads the count, then that many .
 
proto_bool protocore_thread_spinel_reader_ok (uint8_t *work, const SpinelReader *r)
 True if every read so far stayed in bounds.
 
void protocore_thread_spinel_writer_init (uint8_t *work, SpinelWriter *w, uint8_t *out, uint16_t cap)
 Spinel_writer_init.
 
proto_bool protocore_thread_spinel_put_bool (uint8_t *work, SpinelWriter *w, proto_bool v)
 Spinel_put_bool.
 
proto_bool protocore_thread_spinel_put_u8 (uint8_t *work, SpinelWriter *w, uint8_t v)
 Spinel_put_u8.
 
void protocore_thread_spinel_put_i8 (uint8_t *work, SpinelWriter *w, int8_t v)
 Spinel_put_i8.
 
proto_bool protocore_thread_spinel_put_u16 (uint8_t *work, SpinelWriter *w, uint16_t v)
 Spinel_put_u16.
 
void protocore_thread_spinel_put_i16 (uint8_t *work, SpinelWriter *w, int16_t v)
 Spinel_put_i16.
 
proto_bool protocore_thread_spinel_put_u32 (uint8_t *work, SpinelWriter *w, uint32_t v)
 Spinel_put_u32.
 
void protocore_thread_spinel_put_i32 (uint8_t *work, SpinelWriter *w, int32_t v)
 Spinel_put_i32.
 
proto_bool protocore_thread_spinel_put_uint (uint8_t *work, SpinelWriter *w, uint32_t v)
 Spinel_put_uint.
 
proto_bool protocore_thread_spinel_put_eui64 (uint8_t *work, SpinelWriter *w, const uint8_t *v8)
 Spinel_put_eui64.
 
proto_bool protocore_thread_spinel_put_ipv6 (uint8_t *work, SpinelWriter *w, const uint8_t *v16)
 Spinel_put_ipv6.
 
proto_bool protocore_thread_spinel_put_utf8 (uint8_t *work, SpinelWriter *w, const char *s)
 Spinel_put_utf8.
 
proto_bool protocore_thread_spinel_put_data (uint8_t *work, SpinelWriter *w, const uint8_t *d, uint16_t n)
 Spinel_put_data.
 
proto_bool protocore_thread_spinel_put_data_wlen (uint8_t *work, SpinelWriter *w, const uint8_t *d, uint16_t n)
 Spinel_put_data_wlen.
 
uint16_t protocore_thread_spinel_writer_len (uint8_t *work, const SpinelWriter *w)
 The finished value length, or 0 if any write overflowed.
 
const SpinelPropInfo * protocore_thread_spinel_prop_lookup (uint8_t *work, uint32_t id)
 Look up a property's registry entry, or nullptr if it is not in the .
 
const char * protocore_thread_spinel_prop_name (uint8_t *work, uint32_t id)
 A property's human name, or "UNKNOWN" if unregistered.
 
const char * protocore_thread_spinel_status_name (uint8_t *work, uint32_t status)
 A LAST_STATUS code's human name, or "UNKNOWN" if unregistered.
 
uint16_t protocore_thread_spinel_frame_encode (uint8_t *work, const uint8_t *payload, uint16_t len, uint8_t *out, uint16_t cap)
 Encode an HDLC-lite frame: payload + FCS, byte-stuffed, .
 
int protocore_thread_spinel_frame_decode (uint8_t *work, const uint8_t *raw, uint16_t len, uint8_t *payload, uint16_t pay_cap, uint16_t *pay_len)
 Decode one HDLC-lite frame from the front of raw: find the flag, .
 

Variables

PROTOCORE_NS ThreadNs Thread PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

Thread spinel / HDLC-lite framing codec (PROTOCORE_ENABLE_THREAD) - OpenThread RCP.

The HDLC-lite framing that carries spinel frames to an OpenThread radio co-processor (an nRF52840 / EFR32 RCP) over UART - an 802.15.4 / Thread mesh bridged to IP and the web. HDLC-lite wraps each spinel frame by appending an FCS, byte-stuffing the reserved bytes, and terminating with a Flag:

[spinel payload | FCS(lo,hi)] –byte-stuffed--> ... | 0x7E

The FCS is the HDLC frame check sequence, CRC-16/X-25 (poly 0x1021 reflected, init 0xFFFF, reflected in/out, final XOR 0xFFFF), transmitted low byte first. The reserved bytes stuffed (as 0x7D, byte XOR 0x20) are the Flag 0x7E, the Escape 0x7D, XON 0x11, and XOFF 0x13.

protocore_spinel_frame_encode() wraps a payload; protocore_spinel_frame_decode() finds the flag, removes the stuffing, and verifies the FCS. protocore_spinel_fcs() is the shared checksum. The spinel command inside (a property get/set/insert, an 802.15.4 stream) is the application's. Pure - you carry the bytes over your UART - so it is fully host-testable.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file thread.h.

Macro Definition Documentation

◆ HDLC_FLAG

#define HDLC_FLAG   0x7E

HDLC-lite markers.

frame delimiter

Definition at line 45 of file thread.h.

◆ HDLC_ESCAPE

#define HDLC_ESCAPE   0x7D

byte-stuffing escape

Definition at line 46 of file thread.h.

◆ SPINEL_CMD_NOOP

#define SPINEL_CMD_NOOP   0

Common spinel commands (the property accessors a gateway uses).

Definition at line 49 of file thread.h.

◆ SPINEL_CMD_RESET

#define SPINEL_CMD_RESET   1

Definition at line 50 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_GET

#define SPINEL_CMD_PROP_VALUE_GET   2

Definition at line 51 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_SET

#define SPINEL_CMD_PROP_VALUE_SET   3

Definition at line 52 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_INSERT

#define SPINEL_CMD_PROP_VALUE_INSERT   4

Definition at line 53 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_REMOVE

#define SPINEL_CMD_PROP_VALUE_REMOVE   5

Definition at line 54 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_IS

#define SPINEL_CMD_PROP_VALUE_IS   6

an async property update from the NCP

Definition at line 55 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_INSERTED

#define SPINEL_CMD_PROP_VALUE_INSERTED   7

a list property gained an entry

Definition at line 56 of file thread.h.

◆ SPINEL_CMD_PROP_VALUE_REMOVED

#define SPINEL_CMD_PROP_VALUE_REMOVED   8

a list property lost an entry

Definition at line 57 of file thread.h.

◆ SPINEL_PROP_LAST_STATUS

#define SPINEL_PROP_LAST_STATUS   0

The spinel property ids a Thread/802.15.4 gateway reads or writes (subset of the spinel property registry, grouped CORE / PHY / MAC / NET / IPv6 / STREAM).

'i' last operation status

Definition at line 64 of file thread.h.

◆ SPINEL_PROP_PROTOCOL_VERSION

#define SPINEL_PROP_PROTOCOL_VERSION   1

'ii' major, minor

Definition at line 65 of file thread.h.

◆ SPINEL_PROP_NCP_VERSION

#define SPINEL_PROP_NCP_VERSION   2

'U' NCP version string

Definition at line 66 of file thread.h.

◆ SPINEL_PROP_INTERFACE_TYPE

#define SPINEL_PROP_INTERFACE_TYPE   3

'i' 3 = Thread

Definition at line 67 of file thread.h.

◆ SPINEL_PROP_VENDOR_ID

#define SPINEL_PROP_VENDOR_ID   4

'i'

Definition at line 68 of file thread.h.

◆ SPINEL_PROP_CAPS

#define SPINEL_PROP_CAPS   5

'A(i)' capability list

Definition at line 69 of file thread.h.

◆ SPINEL_PROP_INTERFACE_COUNT

#define SPINEL_PROP_INTERFACE_COUNT   6

'C'

Definition at line 70 of file thread.h.

◆ SPINEL_PROP_HWADDR

#define SPINEL_PROP_HWADDR   8

'E' factory EUI64

Definition at line 71 of file thread.h.

◆ SPINEL_PROP_LOCK

#define SPINEL_PROP_LOCK   9

'b'

Definition at line 72 of file thread.h.

◆ SPINEL_PROP_PHY_ENABLED

#define SPINEL_PROP_PHY_ENABLED   0x20

'b'

Definition at line 75 of file thread.h.

◆ SPINEL_PROP_PHY_CHAN

#define SPINEL_PROP_PHY_CHAN   0x21

'C' 802.15.4 channel

Definition at line 76 of file thread.h.

◆ SPINEL_PROP_PHY_CHAN_SUPPORTED

#define SPINEL_PROP_PHY_CHAN_SUPPORTED   0x22

'A(C)'

Definition at line 77 of file thread.h.

◆ SPINEL_PROP_PHY_FREQ

#define SPINEL_PROP_PHY_FREQ   0x23

'L' kHz

Definition at line 78 of file thread.h.

◆ SPINEL_PROP_PHY_TX_POWER

#define SPINEL_PROP_PHY_TX_POWER   0x25

'c' dBm

Definition at line 79 of file thread.h.

◆ SPINEL_PROP_PHY_RSSI

#define SPINEL_PROP_PHY_RSSI   0x26

'c' dBm

Definition at line 80 of file thread.h.

◆ SPINEL_PROP_MAC_SCAN_STATE

#define SPINEL_PROP_MAC_SCAN_STATE   0x30

'C'

Definition at line 83 of file thread.h.

◆ SPINEL_PROP_MAC_SCAN_MASK

#define SPINEL_PROP_MAC_SCAN_MASK   0x31

'A(C)'

Definition at line 84 of file thread.h.

◆ SPINEL_PROP_MAC_SCAN_PERIOD

#define SPINEL_PROP_MAC_SCAN_PERIOD   0x32

'S' ms/channel

Definition at line 85 of file thread.h.

◆ SPINEL_PROP_MAC_15_4_LADDR

#define SPINEL_PROP_MAC_15_4_LADDR   0x34

'E' extended (long) address

Definition at line 86 of file thread.h.

◆ SPINEL_PROP_MAC_15_4_SADDR

#define SPINEL_PROP_MAC_15_4_SADDR   0x35

'S' short address

Definition at line 87 of file thread.h.

◆ SPINEL_PROP_MAC_15_4_PANID

#define SPINEL_PROP_MAC_15_4_PANID   0x36

'S' PAN id

Definition at line 88 of file thread.h.

◆ SPINEL_PROP_NET_SAVED

#define SPINEL_PROP_NET_SAVED   0x40

'b'

Definition at line 91 of file thread.h.

◆ SPINEL_PROP_NET_IF_UP

#define SPINEL_PROP_NET_IF_UP   0x41

'b'

Definition at line 92 of file thread.h.

◆ SPINEL_PROP_NET_STACK_UP

#define SPINEL_PROP_NET_STACK_UP   0x42

'b'

Definition at line 93 of file thread.h.

◆ SPINEL_PROP_NET_ROLE

#define SPINEL_PROP_NET_ROLE   0x43

'C' 0 detached,1 child,2 router,3 leader

Definition at line 94 of file thread.h.

◆ SPINEL_PROP_NET_NETWORK_NAME

#define SPINEL_PROP_NET_NETWORK_NAME   0x44

'U'

Definition at line 95 of file thread.h.

◆ SPINEL_PROP_NET_XPANID

#define SPINEL_PROP_NET_XPANID   0x45

'D' 8-byte extended PAN id

Definition at line 96 of file thread.h.

◆ SPINEL_PROP_NET_NETWORK_KEY

#define SPINEL_PROP_NET_NETWORK_KEY   0x46

'D' 16-byte network key

Definition at line 97 of file thread.h.

◆ SPINEL_PROP_IPV6_LL_ADDR

#define SPINEL_PROP_IPV6_LL_ADDR   0x60

'6' link-local

Definition at line 100 of file thread.h.

◆ SPINEL_PROP_IPV6_ML_ADDR

#define SPINEL_PROP_IPV6_ML_ADDR   0x61

'6' mesh-local

Definition at line 101 of file thread.h.

◆ SPINEL_PROP_STREAM_DEBUG

#define SPINEL_PROP_STREAM_DEBUG   0x70

'U' debug text

Definition at line 104 of file thread.h.

◆ SPINEL_PROP_STREAM_RAW

#define SPINEL_PROP_STREAM_RAW   0x71

'dD' raw 802.15.4 frame + metadata

Definition at line 105 of file thread.h.

◆ SPINEL_PROP_STREAM_NET

#define SPINEL_PROP_STREAM_NET   0x72

'dD' IPv6 datagram + metadata

Definition at line 106 of file thread.h.

◆ SPINEL_STATUS_OK

#define SPINEL_STATUS_OK   0

spinel LAST_STATUS codes (a subset - the ones a gateway acts on).

Definition at line 109 of file thread.h.

◆ SPINEL_STATUS_FAILURE

#define SPINEL_STATUS_FAILURE   1

Definition at line 110 of file thread.h.

◆ SPINEL_STATUS_UNIMPLEMENTED

#define SPINEL_STATUS_UNIMPLEMENTED   2

Definition at line 111 of file thread.h.

◆ SPINEL_STATUS_INVALID_ARGUMENT

#define SPINEL_STATUS_INVALID_ARGUMENT   3

Definition at line 112 of file thread.h.

◆ SPINEL_STATUS_INVALID_STATE

#define SPINEL_STATUS_INVALID_STATE   4

Definition at line 113 of file thread.h.

◆ SPINEL_STATUS_INVALID_COMMAND

#define SPINEL_STATUS_INVALID_COMMAND   5

Definition at line 114 of file thread.h.

◆ SPINEL_STATUS_INVALID_INTERFACE

#define SPINEL_STATUS_INVALID_INTERFACE   6

Definition at line 115 of file thread.h.

◆ SPINEL_STATUS_INTERNAL_ERROR

#define SPINEL_STATUS_INTERNAL_ERROR   7

Definition at line 116 of file thread.h.

◆ SPINEL_STATUS_SECURITY_ERROR

#define SPINEL_STATUS_SECURITY_ERROR   8

Definition at line 117 of file thread.h.

◆ SPINEL_STATUS_PARSE_ERROR

#define SPINEL_STATUS_PARSE_ERROR   9

Definition at line 118 of file thread.h.

◆ SPINEL_STATUS_IN_PROGRESS

#define SPINEL_STATUS_IN_PROGRESS   10

Definition at line 119 of file thread.h.

◆ SPINEL_STATUS_NOMEM

#define SPINEL_STATUS_NOMEM   11

Definition at line 120 of file thread.h.

◆ SPINEL_STATUS_BUSY

#define SPINEL_STATUS_BUSY   12

Definition at line 121 of file thread.h.

◆ SPINEL_STATUS_PROP_NOT_FOUND

#define SPINEL_STATUS_PROP_NOT_FOUND   13

Definition at line 122 of file thread.h.

◆ SPINEL_STATUS_DROPPED

#define SPINEL_STATUS_DROPPED   14

Definition at line 123 of file thread.h.

◆ SPINEL_STATUS_EMPTY

#define SPINEL_STATUS_EMPTY   15

Definition at line 124 of file thread.h.

◆ SPINEL_STATUS_RESET_POWER_ON

#define SPINEL_STATUS_RESET_POWER_ON   112

first of the reset-cause block

Definition at line 125 of file thread.h.

◆ SPINEL_STATUS_RESET_END

#define SPINEL_STATUS_RESET_END   128

one past the block: 112..127 are all reset causes

Definition at line 126 of file thread.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( ThreadNs  ,
spinel_fcs  ,
spinel_pack_uint  ,
spinel_unpack_uint  ,
spinel_command_build  ,
spinel_command_parse  ,
spinel_reader_init  ,
spinel_get_bool  ,
spinel_get_u8  ,
spinel_get_i8  ,
spinel_get_u16  ,
spinel_get_i16  ,
spinel_get_u32  ,
spinel_get_i32  ,
spinel_get_uint  ,
spinel_get_eui64  ,
spinel_get_ipv6  ,
spinel_get_utf8  ,
spinel_get_data  ,
spinel_get_data_wlen  ,
spinel_reader_ok  ,
spinel_writer_init  ,
spinel_put_bool  ,
spinel_put_u8  ,
spinel_put_i8  ,
spinel_put_u16  ,
spinel_put_i16  ,
spinel_put_u32  ,
spinel_put_i32  ,
spinel_put_uint  ,
spinel_put_eui64  ,
spinel_put_ipv6  ,
spinel_put_utf8  ,
spinel_put_data  ,
spinel_put_data_wlen  ,
spinel_writer_len  ,
spinel_prop_lookup  ,
spinel_prop_name  ,
spinel_status_name  ,
spinel_frame_encode  ,
spinel_frame_decode   
)

◆ protocore_thread_spinel_fcs()

uint16_t protocore_thread_spinel_fcs ( uint8_t *  work,
const uint8_t *  buf,
uint16_t  len 
)

HDLC frame check sequence: CRC-16/X-25 over buf.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
bufBuf
lenLen
Returns
The uint16_t.

◆ protocore_thread_spinel_pack_uint()

uint8_t protocore_thread_spinel_pack_uint ( uint8_t *  work,
uint32_t  value,
uint8_t *  out,
uint8_t  cap 
)

Encode a spinel packed unsigned integer (7 bits/byte, .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
valueValue
outOut
capCap
Returns
The uint8_t.

◆ protocore_thread_spinel_unpack_uint()

int protocore_thread_spinel_unpack_uint ( uint8_t *  work,
const uint8_t *  raw,
uint8_t  len,
uint32_t *  value 
)

Decode a spinel packed unsigned integer from the front of raw.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rawRaw
lenLen
valueValue
Returns
The int.

◆ protocore_thread_spinel_command_build()

uint16_t protocore_thread_spinel_command_build ( uint8_t *  work,
uint8_t  header,
uint32_t  cmd,
uint32_t  prop,
const uint8_t *  value,
uint16_t  value_len,
uint8_t *  out,
uint16_t  cap 
)

Build a spinel property-command payload (`header | CMD | PROP | .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
headerHeader
cmdCmd
propProp
valueValue
value_lenValue len
outOut
capCap
Returns
The uint16_t.

◆ protocore_thread_spinel_command_parse()

int protocore_thread_spinel_command_parse ( uint8_t *  work,
const uint8_t *  payload,
uint16_t  len,
uint8_t *  header,
uint32_t *  cmd,
uint32_t *  prop,
const uint8_t **  value,
uint16_t *  value_len 
)

Parse a spinel property-command payload (from a decoded HDLC frame).

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
payloadPayload
lenLen
headerHeader
cmdCmd
propProp
valueValue
value_lenValue len
Returns
The int.

◆ protocore_thread_spinel_reader_init()

void protocore_thread_spinel_reader_init ( uint8_t *  work,
SpinelReader *  r,
const uint8_t *  value,
uint16_t  len 
)

Spinel_reader_init.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
valueValue
lenLen

◆ protocore_thread_spinel_get_bool()

proto_bool protocore_thread_spinel_get_bool ( uint8_t *  work,
SpinelReader *  r,
proto_bool *  out 
)

Spinel_get_bool.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_u8()

proto_bool protocore_thread_spinel_get_u8 ( uint8_t *  work,
SpinelReader *  r,
uint8_t *  out 
)

Spinel_get_u8.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_i8()

proto_bool protocore_thread_spinel_get_i8 ( uint8_t *  work,
SpinelReader *  r,
int8_t *  out 
)

Spinel_get_i8.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_u16()

proto_bool protocore_thread_spinel_get_u16 ( uint8_t *  work,
SpinelReader *  r,
uint16_t *  out 
)

Spinel_get_u16.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_i16()

proto_bool protocore_thread_spinel_get_i16 ( uint8_t *  work,
SpinelReader *  r,
int16_t *  out 
)

Spinel_get_i16.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_u32()

proto_bool protocore_thread_spinel_get_u32 ( uint8_t *  work,
SpinelReader *  r,
uint32_t *  out 
)

Spinel_get_u32.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_i32()

proto_bool protocore_thread_spinel_get_i32 ( uint8_t *  work,
SpinelReader *  r,
int32_t *  out 
)

Spinel_get_i32.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_uint()

proto_bool protocore_thread_spinel_get_uint ( uint8_t *  work,
SpinelReader *  r,
uint32_t *  out 
)

Spinel_get_uint.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_eui64()

proto_bool protocore_thread_spinel_get_eui64 ( uint8_t *  work,
SpinelReader *  r,
const uint8_t **  out8 
)

Spinel_get_eui64.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
out8Out8
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_ipv6()

proto_bool protocore_thread_spinel_get_ipv6 ( uint8_t *  work,
SpinelReader *  r,
const uint8_t **  out16 
)

Spinel_get_ipv6.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
out16Out16
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_utf8()

proto_bool protocore_thread_spinel_get_utf8 ( uint8_t *  work,
SpinelReader *  r,
const char **  out,
uint16_t *  out_len 
)

UTF8 'U': out points into the value, out_len excludes the NUL; .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
out_lenOut len
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_data()

proto_bool protocore_thread_spinel_get_data ( uint8_t *  work,
SpinelReader *  r,
const uint8_t **  out,
uint16_t *  out_len 
)

Data 'D' (to end of value): out points into the value, out_len is .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
out_lenOut len
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_get_data_wlen()

proto_bool protocore_thread_spinel_get_data_wlen ( uint8_t *  work,
SpinelReader *  r,
const uint8_t **  out,
uint16_t *  out_len 
)

Data 'd' (uint16-LE length prefix): reads the count, then that many .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
outOut
out_lenOut len
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_reader_ok()

proto_bool protocore_thread_spinel_reader_ok ( uint8_t *  work,
const SpinelReader *  r 
)

True if every read so far stayed in bounds.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rR
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_writer_init()

void protocore_thread_spinel_writer_init ( uint8_t *  work,
SpinelWriter *  w,
uint8_t *  out,
uint16_t  cap 
)

Spinel_writer_init.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
outOut
capCap

◆ protocore_thread_spinel_put_bool()

proto_bool protocore_thread_spinel_put_bool ( uint8_t *  work,
SpinelWriter *  w,
proto_bool  v 
)

Spinel_put_bool.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_u8()

proto_bool protocore_thread_spinel_put_u8 ( uint8_t *  work,
SpinelWriter *  w,
uint8_t  v 
)

Spinel_put_u8.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_i8()

void protocore_thread_spinel_put_i8 ( uint8_t *  work,
SpinelWriter *  w,
int8_t  v 
)

Spinel_put_i8.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV

◆ protocore_thread_spinel_put_u16()

proto_bool protocore_thread_spinel_put_u16 ( uint8_t *  work,
SpinelWriter *  w,
uint16_t  v 
)

Spinel_put_u16.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_i16()

void protocore_thread_spinel_put_i16 ( uint8_t *  work,
SpinelWriter *  w,
int16_t  v 
)

Spinel_put_i16.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV

◆ protocore_thread_spinel_put_u32()

proto_bool protocore_thread_spinel_put_u32 ( uint8_t *  work,
SpinelWriter *  w,
uint32_t  v 
)

Spinel_put_u32.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_i32()

void protocore_thread_spinel_put_i32 ( uint8_t *  work,
SpinelWriter *  w,
int32_t  v 
)

Spinel_put_i32.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV

◆ protocore_thread_spinel_put_uint()

proto_bool protocore_thread_spinel_put_uint ( uint8_t *  work,
SpinelWriter *  w,
uint32_t  v 
)

Spinel_put_uint.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
vV
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_eui64()

proto_bool protocore_thread_spinel_put_eui64 ( uint8_t *  work,
SpinelWriter *  w,
const uint8_t *  v8 
)

Spinel_put_eui64.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
v8V8
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_ipv6()

proto_bool protocore_thread_spinel_put_ipv6 ( uint8_t *  work,
SpinelWriter *  w,
const uint8_t *  v16 
)

Spinel_put_ipv6.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
v16V16
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_utf8()

proto_bool protocore_thread_spinel_put_utf8 ( uint8_t *  work,
SpinelWriter *  w,
const char *  s 
)

Spinel_put_utf8.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
sS
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_data()

proto_bool protocore_thread_spinel_put_data ( uint8_t *  work,
SpinelWriter *  w,
const uint8_t *  d,
uint16_t  n 
)

Spinel_put_data.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
dD
nN
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_put_data_wlen()

proto_bool protocore_thread_spinel_put_data_wlen ( uint8_t *  work,
SpinelWriter *  w,
const uint8_t *  d,
uint16_t  n 
)

Spinel_put_data_wlen.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
dD
nN
Returns
PROTO_TRUE on success.

◆ protocore_thread_spinel_writer_len()

uint16_t protocore_thread_spinel_writer_len ( uint8_t *  work,
const SpinelWriter *  w 
)

The finished value length, or 0 if any write overflowed.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
wW
Returns
The uint16_t.

◆ protocore_thread_spinel_prop_lookup()

const SpinelPropInfo * protocore_thread_spinel_prop_lookup ( uint8_t *  work,
uint32_t  id 
)

Look up a property's registry entry, or nullptr if it is not in the .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
idId
Returns
The const SpinelPropInfo *.

◆ protocore_thread_spinel_prop_name()

const char * protocore_thread_spinel_prop_name ( uint8_t *  work,
uint32_t  id 
)

A property's human name, or "UNKNOWN" if unregistered.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
idId
Returns
The const char *.

◆ protocore_thread_spinel_status_name()

const char * protocore_thread_spinel_status_name ( uint8_t *  work,
uint32_t  status 
)

A LAST_STATUS code's human name, or "UNKNOWN" if unregistered.

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
statusStatus
Returns
The const char *.

◆ protocore_thread_spinel_frame_encode()

uint16_t protocore_thread_spinel_frame_encode ( uint8_t *  work,
const uint8_t *  payload,
uint16_t  len,
uint8_t *  out,
uint16_t  cap 
)

Encode an HDLC-lite frame: payload + FCS, byte-stuffed, .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
payloadPayload
lenLen
outOut
capCap
Returns
The uint16_t.

◆ protocore_thread_spinel_frame_decode()

int protocore_thread_spinel_frame_decode ( uint8_t *  work,
const uint8_t *  raw,
uint16_t  len,
uint8_t *  payload,
uint16_t  pay_cap,
uint16_t *  pay_len 
)

Decode one HDLC-lite frame from the front of raw: find the flag, .

Parameters
workPROTOCORE_THREAD_BORROW bytes the caller took. Not held past the call.
rawRaw
lenLen
payloadPayload
pay_capPay cap
pay_lenPay len
Returns
The int.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS ThreadNs Thread PROTOCORE_UNUSED

Module namespace.

Definition at line 568 of file thread.h.