mirror of
https://github.com/espressif/openthread.git
synced 2026-08-27 12:29:54 +00:00
otInstance Declarations (#473)
* Add otInstance type declaration and update ot APIs to take it as input.
This commit is contained in:
@@ -57,11 +57,12 @@ typedef int (*otCliConsoleOutputCallback)(const char *aBuf,
|
||||
/**
|
||||
* Initialize the CLI CONSOLE module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCallback A callback method called to process console output.
|
||||
* @param[in] aContext A user context pointer.
|
||||
*
|
||||
*/
|
||||
void otCliConsoleInit(otCliConsoleOutputCallback aCallback, void *aContext);
|
||||
void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallback aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* This method is called to feed in a console input line.
|
||||
|
||||
@@ -42,8 +42,10 @@ extern "C" {
|
||||
/**
|
||||
* Initialize the CLI UART module.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void otCliUartInit(void);
|
||||
void otCliUartInit(otInstance *aInstance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -49,19 +49,22 @@ extern "C" {
|
||||
/**
|
||||
* This function enables the Thread Commissioner role.
|
||||
*
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
*
|
||||
* @retval kThreadError_None Successfully started the Commissioner role.
|
||||
* @retval kThreadError_InvalidArgs @p aPSKd is invalid.
|
||||
*
|
||||
*/
|
||||
ThreadError otCommissionerStart(const char *aPSKd);
|
||||
ThreadError otCommissionerStart(otInstance *aInstance, const char *aPSKd);
|
||||
|
||||
/**
|
||||
* This function disables the Thread Commissioner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
*/
|
||||
ThreadError otCommissionerStop(void);
|
||||
ThreadError otCommissionerStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -49,19 +49,22 @@ extern "C" {
|
||||
/**
|
||||
* This function enables the Thread Joiner role.
|
||||
*
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPSKd A pointer to the PSKd.
|
||||
*
|
||||
* @retval kThreadError_None Successfully started the Commissioner role.
|
||||
* @retval kThreadError_InvalidArgs @p aPSKd is invalid.
|
||||
*
|
||||
*/
|
||||
ThreadError otJoinerStart(const char *aPSKd);
|
||||
ThreadError otJoinerStart(otInstance *aInstance, const char *aPSKd);
|
||||
|
||||
/**
|
||||
* This function disables the Thread Joiner role.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
*/
|
||||
ThreadError otJoinerStop(void);
|
||||
ThreadError otJoinerStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
+4
-2
@@ -35,7 +35,7 @@
|
||||
#ifndef NCP_H_
|
||||
#define NCP_H_
|
||||
|
||||
#include "../openthread-types.h"
|
||||
#include <openthread-types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -44,8 +44,10 @@ extern "C" {
|
||||
/**
|
||||
* Initialize the NCP.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void otNcpInit(void);
|
||||
void otNcpInit(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @brief Send data to the host via a specific stream.
|
||||
|
||||
@@ -35,11 +35,13 @@
|
||||
#ifndef OPENTHREAD_DIAG_H_
|
||||
#define OPENTHREAD_DIAG_H_
|
||||
|
||||
#include <openthread-types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void diagInit();
|
||||
void diagInit(otInstance *aInstance);
|
||||
|
||||
char *diagProcessCmd(int argc, char *argv[]);
|
||||
|
||||
|
||||
@@ -37,12 +37,18 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This type represents the OpenThread instance structure.
|
||||
*/
|
||||
typedef struct otInstance otInstance;
|
||||
|
||||
/**
|
||||
* This enumeration represents error codes used throughout OpenThread.
|
||||
*/
|
||||
|
||||
+369
-164
File diff suppressed because it is too large
Load Diff
@@ -55,15 +55,18 @@ extern "C" {
|
||||
/**
|
||||
* Set the alarm to fire at @p aDt milliseconds after @p aT0.
|
||||
*
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in milliseconds from @p aT0.
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aT0 The reference time.
|
||||
* @param[in] aDt The time delay in milliseconds from @p aT0.
|
||||
*/
|
||||
void otPlatAlarmStartAt(uint32_t aT0, uint32_t aDt);
|
||||
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt);
|
||||
|
||||
/**
|
||||
* Stop the alarm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
void otPlatAlarmStop(void);
|
||||
void otPlatAlarmStop(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the current time.
|
||||
@@ -74,13 +77,17 @@ uint32_t otPlatAlarmGetNow(void);
|
||||
|
||||
/**
|
||||
* Signal that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatAlarmFired(void);
|
||||
extern void otPlatAlarmFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Signal diagnostics module that the alarm has fired.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
extern void otPlatDiagAlarmFired(void);
|
||||
extern void otPlatDiagAlarmFired(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -44,8 +44,10 @@ extern "C" {
|
||||
/**
|
||||
* This function performs a software reset on the platform, if supported.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void otPlatReset(void);
|
||||
void otPlatReset(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enumeration of possible reset reason codes.
|
||||
@@ -71,8 +73,10 @@ typedef enum
|
||||
/**
|
||||
* This function returns the reason for the last platform reset.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
otPlatResetReason otPlatGetResetReason(void);
|
||||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* This function performs all platform-specific initialization.
|
||||
*
|
||||
@@ -49,8 +48,10 @@ void PlatformInit(int argc, char *argv[]);
|
||||
/**
|
||||
* This function performs all platform-specific processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void PlatformProcessDrivers(void);
|
||||
void PlatformProcessDrivers(otInstance *aInstance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
|
||||
+57
-27
@@ -147,29 +147,34 @@ typedef enum PhyState
|
||||
/**
|
||||
* Set the PAN ID for address filtering.
|
||||
*
|
||||
* @param[in] aPanId The IEEE 802.15.4 PAN ID.
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aPanId The IEEE 802.15.4 PAN ID.
|
||||
*
|
||||
* @retval ::kThreadError_None If the PAN ID was set properly.
|
||||
*/
|
||||
ThreadError otPlatRadioSetPanId(uint16_t aPanId);
|
||||
ThreadError otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId);
|
||||
|
||||
/**
|
||||
* Set the Extended Address for address filtering.
|
||||
*
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aExtendedAddress A pointer to the IEEE 802.15.4 Extended Address.
|
||||
*
|
||||
* @retval ::kThreadError_None If the Extended Address was set properly.
|
||||
*/
|
||||
ThreadError otPlatRadioSetExtendedAddress(uint8_t *aExtendedAddress);
|
||||
ThreadError otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtendedAddress);
|
||||
|
||||
/**
|
||||
* Set the Short Address for address filtering.
|
||||
*
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aShortAddress The IEEE 802.15.4 Short Address.
|
||||
*
|
||||
* @retval ::kThreadError_None If the Short Address was set properly.
|
||||
*/
|
||||
ThreadError otPlatRadioSetShortAddress(uint16_t aShortAddress);
|
||||
ThreadError otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress);
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -189,55 +194,66 @@ ThreadError otPlatRadioSetShortAddress(uint16_t aShortAddress);
|
||||
/**
|
||||
* Enable the radio.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval ::kThreadError_None Successfully transitioned to Sleep.
|
||||
* @retval ::kThreadError_Busy The radio was already enabled.
|
||||
*/
|
||||
ThreadError otPlatRadioEnable(void);
|
||||
ThreadError otPlatRadioEnable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Disable the radio.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval ::kThreadError_None Successfully transitioned to Disabled.
|
||||
*/
|
||||
ThreadError otPlatRadioDisable(void);
|
||||
ThreadError otPlatRadioDisable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Check whether radio is enabled or not.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval ::true radio is enabled.
|
||||
* @retval ::false radio is disabled.
|
||||
*/
|
||||
bool otPlatRadioIsEnabled(void);
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Transition the radio from Receive to Sleep.
|
||||
* Turn off the radio.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval ::kThreadError_None Successfully transitioned to Sleep.
|
||||
* @retval ::kThreadError_Busy The radio was not in the Receive state.
|
||||
*/
|
||||
ThreadError otPlatRadioSleep(void);
|
||||
ThreadError otPlatRadioSleep(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Transitioning the radio from Sleep to Receive.
|
||||
* Turn on the radio.
|
||||
*
|
||||
* @param[in] aChannel The channel to use for receiving.
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aChannel The channel to use for receiving.
|
||||
*
|
||||
* @retval ::kThreadError_None Successfully transitioned to Receive.
|
||||
* @retval ::kThreadError_Busy The radio was not in the Sleep state.
|
||||
*/
|
||||
ThreadError otPlatRadioReceive(uint8_t aChannel);
|
||||
ThreadError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* The radio driver calls this method to notify OpenThread of a received packet.
|
||||
*
|
||||
* @param[in] aPacket A pointer to the received packet or NULL if the receive operation was aborted.
|
||||
* @param[in] aError ::kThreadError_None when successfully received a frame, ::kThreadError_Abort when reception
|
||||
* was aborted and a frame was not received.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aPacket A pointer to the received packet or NULL if the receive operation was aborted.
|
||||
* @param[in] aError ::kThreadError_None when successfully received a frame, ::kThreadError_Abort when reception
|
||||
* was aborted and a frame was not received.
|
||||
*
|
||||
*/
|
||||
extern void otPlatRadioReceiveDone(RadioPacket *aPacket, ThreadError aError);
|
||||
extern void otPlatRadioReceiveDone(otInstance *aInstance, RadioPacket *aPacket, ThreadError aError);
|
||||
|
||||
/**
|
||||
* The radio transitions from Transmit to Receive.
|
||||
@@ -245,10 +261,12 @@ extern void otPlatRadioReceiveDone(RadioPacket *aPacket, ThreadError aError);
|
||||
*
|
||||
* The caller forms the IEEE 802.15.4 frame in this buffer then calls otPlatRadioTransmit() to request transmission.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns A pointer to the transmit buffer.
|
||||
*
|
||||
*/
|
||||
RadioPacket *otPlatRadioGetTransmitBuffer(void);
|
||||
RadioPacket *otPlatRadioGetTransmitBuffer(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This method begins the transmit sequence on the radio.
|
||||
@@ -260,14 +278,17 @@ RadioPacket *otPlatRadioGetTransmitBuffer(void);
|
||||
* 1. Transitioning the radio to Transmit from Receive.
|
||||
* 2. Transmits the psdu on the given channel and at the given transmit power.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval ::kThreadError_None Successfully transitioned to Transmit.
|
||||
* @retval ::kThreadError_Busy The radio was not in the Receive state.
|
||||
*/
|
||||
ThreadError otPlatRadioTransmit(void);
|
||||
ThreadError otPlatRadioTransmit(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The radio driver calls this method to notify OpenThread that the transmission has completed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aFramePending TRUE if an ACK frame was received and the Frame Pending bit was set.
|
||||
* @param[in] aError ::kThreadError_None when the frame was transmitted, ::kThreadError_NoAck when the frame was
|
||||
* transmitted but no ACK was received, ::kThreadError_ChannelAccessFailure when the transmission
|
||||
@@ -275,40 +296,48 @@ ThreadError otPlatRadioTransmit(void);
|
||||
* aborted for other reasons.
|
||||
*
|
||||
*/
|
||||
extern void otPlatRadioTransmitDone(bool aFramePending, ThreadError aError);
|
||||
extern void otPlatRadioTransmitDone(otInstance *aInstance, bool aFramePending, ThreadError aError);
|
||||
|
||||
/**
|
||||
* Get the most recent RSSI measurement.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid.
|
||||
*/
|
||||
int8_t otPlatRadioGetRssi(void);
|
||||
int8_t otPlatRadioGetRssi(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the radio capabilities.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @returns The radio capability bit vector. The stack enables or disables some functions based on this value.
|
||||
*/
|
||||
otRadioCaps otPlatRadioGetCaps(void);
|
||||
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the status of promiscuous mode.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
* @retval true Promiscuous mode is enabled.
|
||||
* @retval false Promiscuous mode is disabled.
|
||||
*/
|
||||
bool otPlatRadioGetPromiscuous(void);
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Enable or disable promiscuous mode.
|
||||
*
|
||||
* @param[in] aEnable A value to enable or disable promiscuous mode.
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aEnable A value to enable or disable promiscuous mode.
|
||||
*/
|
||||
void otPlatRadioSetPromiscuous(bool aEnable);
|
||||
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* The radio driver calls this method to notify OpenThread diagnostics module that the transmission has completed.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aFramePending TRUE if an ACK frame was received and the Frame Pending bit was set.
|
||||
* @param[in] aError ::kThreadError_None when the frame was transmitted, ::kThreadError_NoAck when the frame was
|
||||
* transmitted but no ACK was received, ::kThreadError_ChannelAccessFailure when the transmission
|
||||
@@ -316,17 +345,18 @@ void otPlatRadioSetPromiscuous(bool aEnable);
|
||||
* aborted for other reasons.
|
||||
*
|
||||
*/
|
||||
extern void otPlatDiagRadioTransmitDone(bool aFramePending, ThreadError aError);
|
||||
extern void otPlatDiagRadioTransmitDone(otInstance *aInstance, bool aFramePending, ThreadError aError);
|
||||
|
||||
/**
|
||||
* The radio driver calls this method to notify OpenThread diagnostics module of a received packet.
|
||||
*
|
||||
* @param[in] aPacket A pointer to the received packet or NULL if the receive operation was aborted.
|
||||
* @param[in] aError ::kThreadError_None when successfully received a frame, ::kThreadError_Abort when reception
|
||||
* was aborted and a frame was not received.
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aPacket A pointer to the received packet or NULL if the receive operation was aborted.
|
||||
* @param[in] aError ::kThreadError_None when successfully received a frame, ::kThreadError_Abort when reception
|
||||
* was aborted and a frame was not received.
|
||||
*
|
||||
*/
|
||||
extern void otPlatDiagRadioReceiveDone(RadioPacket *aPacket, ThreadError aError);
|
||||
extern void otPlatDiagRadioReceiveDone(otInstance *aInstance, RadioPacket *aPacket, ThreadError aError);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user