Network Co-Processor#

This module includes functions that control the Thread stack's execution.

Typedefs#

typedef int(*
otNcpHdlcSendCallback)(const uint8_t *aBuf, uint16_t aBufLength)

Pointer is called to send HDLC encoded NCP data.

typedef bool(*
otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount)

Defines delegate (function pointer) type to control behavior of peek/poke operation.

Functions#

void

Is called after NCP send finished.

void
otNcpHdlcReceive(const uint8_t *aBuf, uint16_t aBufLength)

Is called after HDLC encoded NCP data received.

void
otNcpHdlcInit(otInstance *aInstance, otNcpHdlcSendCallback aSendCallback)

Initialize the NCP based on HDLC framing.

void
otNcpHdlcInitMulti(otInstance **aInstance, uint8_t aCount, otNcpHdlcSendCallback aSendCallback)

Initialize the NCP based on HDLC framing.

void
otNcpSpiInit(otInstance *aInstance)

Initialize the NCP based on SPI framing.

otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)

Send data to the host via a specific stream.

void
otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)

Writes OpenThread Log using otNcpStreamWrite.

void
otNcpRegisterPeekPokeDelegates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpDelegateAllowPeekPoke aAllowPokeDelegate)

Registers peek/poke delegate functions with NCP module.

Typedef Documentation#

otNcpHdlcSendCallback#

typedef int(* otNcpHdlcSendCallback) (const uint8_t *aBuf, uint16_t aBufLength) )(const uint8_t *aBuf, uint16_t aBufLength)

Pointer is called to send HDLC encoded NCP data.

Parameters
TypeDirectionArgument NameDescription
[in]aBuf

A pointer to a buffer with an output.

[in]aBufLength

A length of the output data stored in the buffer.

Returns

  • Number of bytes processed by the callback.


otNcpDelegateAllowPeekPoke#

typedef bool(* otNcpDelegateAllowPeekPoke) (uint32_t aAddress, uint16_t aCount) )(uint32_t aAddress, uint16_t aCount)

Defines delegate (function pointer) type to control behavior of peek/poke operation.

Parameters
TypeDirectionArgument NameDescription
[in]aAddress

Start address of memory region.

[in]aCount

Number of bytes to peek or poke.

This delegate function is called to decide whether to allow peek or poke of a specific memory region. It is used if NCP support for peek/poke commands is enabled.

Returns

  • TRUE to allow peek/poke of the given memory region, FALSE otherwise.


Function Documentation#

otNcpHdlcSendDone#

void otNcpHdlcSendDone (void )

Is called after NCP send finished.

Parameters
TypeDirectionArgument NameDescription
voidN/A

otNcpHdlcReceive#

void otNcpHdlcReceive (const uint8_t * aBuf, uint16_t aBufLength)

Is called after HDLC encoded NCP data received.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]aBuf

A pointer to a buffer.

uint16_t[in]aBufLength

The length of the data stored in the buffer.


otNcpHdlcInit#

void otNcpHdlcInit (otInstance * aInstance, otNcpHdlcSendCallback aSendCallback)

Initialize the NCP based on HDLC framing.

Parameters
TypeDirectionArgument NameDescription
otInstance *[in]aInstance

The OpenThread instance structure.

otNcpHdlcSendCallback[in]aSendCallback

The function pointer used to send NCP data.


otNcpHdlcInitMulti#

void otNcpHdlcInitMulti (otInstance ** aInstance, uint8_t aCount, otNcpHdlcSendCallback aSendCallback)

Initialize the NCP based on HDLC framing.

Parameters
TypeDirectionArgument NameDescription
otInstance **[in]aInstance

The OpenThread instance pointers array.

uint8_t[in]aCount

Number of elements in the array.

otNcpHdlcSendCallback[in]aSendCallback

The function pointer used to send NCP data.


otNcpSpiInit#

void otNcpSpiInit (otInstance * aInstance)

Initialize the NCP based on SPI framing.

Parameters
TypeDirectionArgument NameDescription
otInstance *[in]aInstance

The OpenThread instance structure.


otNcpStreamWrite#

otError otNcpStreamWrite (int aStreamId, const uint8_t * aDataPtr, int aDataLen)

Send data to the host via a specific stream.

Parameters
TypeDirectionArgument NameDescription
int[in]aStreamId

A numeric identifier for the stream to write to. If set to '0', will default to the debug stream.

const uint8_t *[in]aDataPtr

A pointer to the data to send on the stream. If aDataLen is non-zero, this param MUST NOT be NULL.

int[in]aDataLen

The number of bytes of data from aDataPtr to send.

Attempts to send the given data to the host using the given aStreamId. This is useful for reporting error messages, implementing debug/diagnostic consoles, and potentially other types of datastreams.

The write either is accepted in its entirety or rejected. Partial writes are not attempted.


otNcpPlatLogv#

void otNcpPlatLogv (otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, va_list aArgs)

Writes OpenThread Log using otNcpStreamWrite.

Parameters
TypeDirectionArgument NameDescription
otLogLevel[in]aLogLevel

The log level.

otLogRegion[in]aLogRegion

The log region.

const char *[in]aFormat

A pointer to the format string.

va_list[in]aArgs

va_list matching aFormat.


otNcpRegisterPeekPokeDelegates#

void otNcpRegisterPeekPokeDelegates (otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpDelegateAllowPeekPoke aAllowPokeDelegate)

Registers peek/poke delegate functions with NCP module.

Parameters
TypeDirectionArgument NameDescription
otNcpDelegateAllowPeekPoke[in]aAllowPeekDelegate

Delegate function pointer for peek operation.

otNcpDelegateAllowPeekPoke[in]aAllowPokeDelegate

Delegate function pointer for poke operation.

The delegate functions are called by NCP module to decide whether to allow peek or poke of a specific memory region. If the delegate pointer is set to NULL, it allows peek/poke operation for any address.