0.01.00
ncp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
35 #ifndef NCP_H_
36 #define NCP_H_
37 
38 #include <openthread/types.h>
39 #include <stdarg.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
61 void otNcpInit(otInstance *aInstance);
62 
85 otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen);
86 
87 //-----------------------------------------------------------------------------------------
88 // Peek/Poke memory access control delegates
89 
102 typedef bool (*otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount);
103 
118  otNcpDelegateAllowPeekPoke aAllowPokeDelegate);
119 
120 //-----------------------------------------------------------------------------------------
121 // Legacy network APIs
122 
123 #define OT_NCP_LEGACY_ULA_PREFIX_LENGTH 8
124 
125 
131 typedef void (*otNcpHandlerStartLegacy)(void);
132 
139 typedef void (*otNcpHandlerStopLegacy)(void);
140 
150 typedef void (*otNcpHandlerJoinLegacyNode)(const otExtAddress *aExtAddress);
151 
160 typedef void (*otNcpHandlerSetLegacyUlaPrefix)(const uint8_t *aUlaPrefix);
161 
166 typedef struct otNcpLegacyHandlers
167 {
173 
181 void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr);
182 
190 void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix);
191 
203 void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers);
204 
213 void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap);
214 
220 #ifdef __cplusplus
221 } // extern "C"
222 #endif
223 
224 #endif
void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix)
This callback is invoked by the legacy stack to notify that the legacy ULA prefix has changed...
otNcpHandlerJoinLegacyNode mJoinLegacyNode
Join handler.
Definition: ncp.h:170
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
This file defines the types and structures used in the OpenThread library API.
void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers)
This method registers a set of legacy handlers with NCP.
uint8_t otLogLevel
Log levels.
Definition: types.h:1182
Defines a struct containing all the legacy handlers (function pointers).
Definition: ncp.h:166
void(* otNcpHandlerStopLegacy)(void)
Defines handler (function pointer) type for stopping legacy network.
Definition: ncp.h:139
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap)
Callback to write the OpenThread Log to the NCP Spinel Tunnel.
Definition: ncp_base.cpp:1965
otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
Send data to the host via a specific stream.
Definition: ncp_base.cpp:1951
bool(* otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount)
Defines delegate (function pointer) type to control behavior of peek/poke operation.
Definition: ncp.h:102
otNcpHandlerStartLegacy mStartLegacy
Start handler.
Definition: ncp.h:168
void(* otNcpHandlerSetLegacyUlaPrefix)(const uint8_t *aUlaPrefix)
Defines handler (function pointer) type for setting the legacy ULA prefix.
Definition: ncp.h:160
void otNcpInit(otInstance *aInstance)
Initialize the NCP.
void(* otNcpHandlerStartLegacy)(void)
Defines handler (function pointer) type for starting legacy network.
Definition: ncp.h:131
void(* otNcpHandlerJoinLegacyNode)(const otExtAddress *aExtAddress)
Defines handler (function pointer) type for initiating joining process.
Definition: ncp.h:150
void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr)
This callback is invoked by the legacy stack to notify that a new legacy node did join the network...
This type represents the IEEE 802.15.4 Extended Address.
Definition: types.h:402
otLogRegion
This enum represents log regions.
Definition: types.h:1188
otNcpHandlerStopLegacy mStopLegacy
Stop handler.
Definition: ncp.h:169
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
struct otNcpLegacyHandlers otNcpLegacyHandlers
Defines a struct containing all the legacy handlers (function pointers).
otNcpHandlerSetLegacyUlaPrefix mSetLegacyUlaPrefix
Set ULA handler.
Definition: ncp.h:171
otError otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpDelegateAllowPeekPoke aAllowPokeDelegate)
This method registers peek/poke delegate functions with NCP module.
Definition: ncp_base.cpp:1924