Imported more library files

Not compiling currently
This commit is contained in:
2025-04-12 23:37:19 +01:00
parent 264a3462e0
commit 9d06f983af
2518 changed files with 1021900 additions and 52 deletions

View File

@@ -0,0 +1,227 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Backbone Router Ftd APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/backbone_router_ftd.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otBackboneRouterState OT_API_REAL_NAME(otBackboneRouterGetState)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBackboneRouterGetDomainPrefix)(otInstance *aInstance, otBorderRouterConfig *aConfig);
extern otError OT_API_REAL_NAME(otBackboneRouterGetNdProxyInfo)(otInstance *aInstance,
const otIp6Address *aDua,
otBackboneRouterNdProxyInfo *aNdProxyInfo);
extern otError OT_API_REAL_NAME(otBackboneRouterMulticastListenerAdd)(otInstance *aInstance,
const otIp6Address *aAddress,
uint32_t aTimeout);
extern otError OT_API_REAL_NAME(otBackboneRouterMulticastListenerGetNext)(
otInstance *aInstance,
otBackboneRouterMulticastListenerIterator *aIterator,
otBackboneRouterMulticastListenerInfo *aListenerInfo);
extern otError OT_API_REAL_NAME(otBackboneRouterRegister)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBackboneRouterSetConfig)(otInstance *aInstance,
const otBackboneRouterConfig *aConfig);
extern uint8_t OT_API_REAL_NAME(otBackboneRouterGetRegistrationJitter)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBackboneRouterConfigNextDuaRegistrationResponse)(otInstance *aInstance,
const otIp6InterfaceIdentifier *aMlIid,
uint8_t aStatus);
extern void OT_API_REAL_NAME(otBackboneRouterConfigNextMulticastListenerRegistrationResponse)(otInstance *aInstance,
uint8_t aStatus);
extern void OT_API_REAL_NAME(otBackboneRouterGetConfig)(otInstance *aInstance, otBackboneRouterConfig *aConfig);
extern void OT_API_REAL_NAME(otBackboneRouterMulticastListenerClear)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBackboneRouterSetDomainPrefixCallback)(otInstance *aInstance,
otBackboneRouterDomainPrefixCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otBackboneRouterSetEnabled)(otInstance *aInstance, bool aEnable);
extern void OT_API_REAL_NAME(otBackboneRouterSetMulticastListenerCallback)(
otInstance *aInstance,
otBackboneRouterMulticastListenerCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otBackboneRouterSetNdProxyCallback)(otInstance *aInstance,
otBackboneRouterNdProxyCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otBackboneRouterSetRegistrationJitter)(otInstance *aInstance, uint8_t aJitter);
otBackboneRouterState OT_API_WRAPPER_NAME(otBackboneRouterGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otBackboneRouterState ret = OT_API_REAL_NAME(otBackboneRouterGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterGetDomainPrefix)(otInstance *aInstance, otBorderRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterGetDomainPrefix)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterGetNdProxyInfo)(otInstance *aInstance,
const otIp6Address *aDua,
otBackboneRouterNdProxyInfo *aNdProxyInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterGetNdProxyInfo)(aInstance, aDua, aNdProxyInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterMulticastListenerAdd)(otInstance *aInstance,
const otIp6Address *aAddress,
uint32_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterMulticastListenerAdd)(aInstance, aAddress, aTimeout);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterMulticastListenerGetNext)(
otInstance *aInstance,
otBackboneRouterMulticastListenerIterator *aIterator,
otBackboneRouterMulticastListenerInfo *aListenerInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterMulticastListenerGetNext)(aInstance, aIterator, aListenerInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterRegister)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterRegister)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBackboneRouterSetConfig)(otInstance *aInstance, const otBackboneRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterSetConfig)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otBackboneRouterGetRegistrationJitter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otBackboneRouterGetRegistrationJitter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otBackboneRouterConfigNextDuaRegistrationResponse)(otInstance *aInstance,
const otIp6InterfaceIdentifier *aMlIid,
uint8_t aStatus)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterConfigNextDuaRegistrationResponse)(aInstance, aMlIid, aStatus);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterConfigNextMulticastListenerRegistrationResponse)(otInstance *aInstance,
uint8_t aStatus)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterConfigNextMulticastListenerRegistrationResponse)(aInstance, aStatus);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterGetConfig)(otInstance *aInstance, otBackboneRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterGetConfig)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterMulticastListenerClear)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterMulticastListenerClear)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterSetDomainPrefixCallback)(otInstance *aInstance,
otBackboneRouterDomainPrefixCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterSetDomainPrefixCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterSetEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterSetEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterSetMulticastListenerCallback)(
otInstance *aInstance,
otBackboneRouterMulticastListenerCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterSetMulticastListenerCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterSetNdProxyCallback)(otInstance *aInstance,
otBackboneRouterNdProxyCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterSetNdProxyCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBackboneRouterSetRegistrationJitter)(otInstance *aInstance, uint8_t aJitter)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBackboneRouterSetRegistrationJitter)(aInstance, aJitter);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,57 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Backbone Router APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/backbone_router.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otBackboneRouterGetPrimary)(otInstance *aInstance, otBackboneRouterConfig *aConfig);
otError OT_API_WRAPPER_NAME(otBackboneRouterGetPrimary)(otInstance *aInstance, otBackboneRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBackboneRouterGetPrimary)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,316 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Ble Secure APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/ble_secure.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otBleSecureGetInstallCodeVerifyStatus)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otBleSecureIsCommandClassAuthorized)(otInstance *aInstance,
otTcatCommandClass aCommandClass);
extern bool OT_API_REAL_NAME(otBleSecureIsConnected)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otBleSecureIsConnectionActive)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otBleSecureIsTcatEnabled)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBleSecureConnect)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBleSecureFlush)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBleSecureGetPeerCertificateBase64)(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength);
extern otError OT_API_REAL_NAME(otBleSecureGetPeerSubjectAttributeByOid)(otInstance *aInstance,
const char *aOid,
size_t aOidLength,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength,
int *aAsn1Type);
extern otError OT_API_REAL_NAME(otBleSecureGetThreadAttributeFromOwnCertificate)(otInstance *aInstance,
int aThreadOidDescriptor,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength);
extern otError OT_API_REAL_NAME(otBleSecureGetThreadAttributeFromPeerCertificate)(otInstance *aInstance,
int aThreadOidDescriptor,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength);
extern otError OT_API_REAL_NAME(otBleSecureSend)(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength);
extern otError OT_API_REAL_NAME(otBleSecureSendApplicationTlv)(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength);
extern otError OT_API_REAL_NAME(otBleSecureSendMessage)(otInstance *aInstance, otMessage *aMessage);
extern otError OT_API_REAL_NAME(otBleSecureSetTcatVendorInfo)(otInstance *aInstance,
const otTcatVendorInfo *aVendorInfo);
extern otError OT_API_REAL_NAME(otBleSecureStart)(otInstance *aInstance,
otHandleBleSecureConnect aConnectHandler,
otHandleBleSecureReceive aReceiveHandler,
bool aTlvMode,
void *aContext);
extern otError OT_API_REAL_NAME(otBleSecureTcatStart)(otInstance *aInstance, otHandleTcatJoin aHandler);
extern void OT_API_REAL_NAME(otBleSecureDisconnect)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBleSecureSetCaCertificateChain)(otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength);
extern void OT_API_REAL_NAME(otBleSecureSetCertificate)(otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
uint32_t aPrivateKeyLength);
extern void OT_API_REAL_NAME(otBleSecureSetPsk)(otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
uint16_t aPskIdLength);
extern void OT_API_REAL_NAME(otBleSecureSetSslAuthMode)(otInstance *aInstance, bool aVerifyPeerCertificate);
extern void OT_API_REAL_NAME(otBleSecureStop)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otBleSecureGetInstallCodeVerifyStatus)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBleSecureGetInstallCodeVerifyStatus)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otBleSecureIsCommandClassAuthorized)(otInstance *aInstance, otTcatCommandClass aCommandClass)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBleSecureIsCommandClassAuthorized)(aInstance, aCommandClass);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otBleSecureIsConnected)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBleSecureIsConnected)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otBleSecureIsConnectionActive)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBleSecureIsConnectionActive)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otBleSecureIsTcatEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBleSecureIsTcatEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureConnect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureConnect)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureFlush)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureFlush)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureGetPeerCertificateBase64)(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureGetPeerCertificateBase64)(aInstance, aPeerCert, aCertLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureGetPeerSubjectAttributeByOid)(otInstance *aInstance,
const char *aOid,
size_t aOidLength,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength,
int *aAsn1Type)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureGetPeerSubjectAttributeByOid)(aInstance,
aOid,
aOidLength,
aAttributeBuffer,
aAttributeLength,
aAsn1Type);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureGetThreadAttributeFromOwnCertificate)(otInstance *aInstance,
int aThreadOidDescriptor,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureGetThreadAttributeFromOwnCertificate)(aInstance,
aThreadOidDescriptor,
aAttributeBuffer,
aAttributeLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureGetThreadAttributeFromPeerCertificate)(otInstance *aInstance,
int aThreadOidDescriptor,
uint8_t *aAttributeBuffer,
size_t *aAttributeLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureGetThreadAttributeFromPeerCertificate)(aInstance,
aThreadOidDescriptor,
aAttributeBuffer,
aAttributeLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureSend)(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureSend)(aInstance, aBuf, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureSendApplicationTlv)(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureSendApplicationTlv)(aInstance, aBuf, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureSendMessage)(otInstance *aInstance, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureSendMessage)(aInstance, aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureSetTcatVendorInfo)(otInstance *aInstance, const otTcatVendorInfo *aVendorInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureSetTcatVendorInfo)(aInstance, aVendorInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureStart)(otInstance *aInstance,
otHandleBleSecureConnect aConnectHandler,
otHandleBleSecureReceive aReceiveHandler,
bool aTlvMode,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureStart)(aInstance, aConnectHandler, aReceiveHandler, aTlvMode, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBleSecureTcatStart)(otInstance *aInstance, otHandleTcatJoin aHandler)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBleSecureTcatStart)(aInstance, aHandler);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otBleSecureDisconnect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureDisconnect)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBleSecureSetCaCertificateChain)(otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureSetCaCertificateChain)(aInstance, aX509CaCertificateChain, aX509CaCertChainLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBleSecureSetCertificate)(otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
uint32_t aPrivateKeyLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureSetCertificate)(aInstance, aX509Cert, aX509Length, aPrivateKey, aPrivateKeyLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBleSecureSetPsk)(otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
uint16_t aPskIdLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureSetPsk)(aInstance, aPsk, aPskLength, aPskIdentity, aPskIdLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBleSecureSetSslAuthMode)(otInstance *aInstance, bool aVerifyPeerCertificate)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureSetSslAuthMode)(aInstance, aVerifyPeerCertificate);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBleSecureStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBleSecureStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,145 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Border Agent APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/border_agent.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otBorderAgentIsEphemeralKeyActive)(otInstance *aInstance);
extern const otBorderAgentCounters *OT_API_REAL_NAME(otBorderAgentGetCounters)(otInstance *aInstance);
extern otBorderAgentState OT_API_REAL_NAME(otBorderAgentGetState)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBorderAgentGetId)(otInstance *aInstance, otBorderAgentId *aId);
extern otError OT_API_REAL_NAME(otBorderAgentSetEphemeralKey)(otInstance *aInstance,
const char *aKeyString,
uint32_t aTimeout,
uint16_t aUdpPort);
extern otError OT_API_REAL_NAME(otBorderAgentSetId)(otInstance *aInstance, const otBorderAgentId *aId);
extern uint16_t OT_API_REAL_NAME(otBorderAgentGetUdpPort)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBorderAgentClearEphemeralKey)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBorderAgentDisconnect)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBorderAgentSetEphemeralKeyCallback)(otInstance *aInstance,
otBorderAgentEphemeralKeyCallback aCallback,
void *aContext);
bool OT_API_WRAPPER_NAME(otBorderAgentIsEphemeralKeyActive)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otBorderAgentIsEphemeralKeyActive)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otBorderAgentCounters *OT_API_WRAPPER_NAME(otBorderAgentGetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otBorderAgentCounters *ret = OT_API_REAL_NAME(otBorderAgentGetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otBorderAgentState OT_API_WRAPPER_NAME(otBorderAgentGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otBorderAgentState ret = OT_API_REAL_NAME(otBorderAgentGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderAgentGetId)(otInstance *aInstance, otBorderAgentId *aId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderAgentGetId)(aInstance, aId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderAgentSetEphemeralKey)(otInstance *aInstance,
const char *aKeyString,
uint32_t aTimeout,
uint16_t aUdpPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderAgentSetEphemeralKey)(aInstance, aKeyString, aTimeout, aUdpPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderAgentSetId)(otInstance *aInstance, const otBorderAgentId *aId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderAgentSetId)(aInstance, aId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otBorderAgentGetUdpPort)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otBorderAgentGetUdpPort)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otBorderAgentClearEphemeralKey)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderAgentClearEphemeralKey)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderAgentDisconnect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderAgentDisconnect)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderAgentSetEphemeralKeyCallback)(otInstance *aInstance,
otBorderAgentEphemeralKeyCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderAgentSetEphemeralKeyCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,147 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Border Router APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/border_router.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otBorderRouterAddOnMeshPrefix)(otInstance *aInstance,
const otBorderRouterConfig *aConfig);
extern otError OT_API_REAL_NAME(otBorderRouterAddRoute)(otInstance *aInstance, const otExternalRouteConfig *aConfig);
extern otError OT_API_REAL_NAME(otBorderRouterGetNetData)(otInstance *aInstance,
bool aStable,
uint8_t *aData,
uint8_t *aDataLength);
extern otError OT_API_REAL_NAME(otBorderRouterGetNextOnMeshPrefix)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otBorderRouterConfig *aConfig);
extern otError OT_API_REAL_NAME(otBorderRouterGetNextRoute)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otExternalRouteConfig *aConfig);
extern otError OT_API_REAL_NAME(otBorderRouterRegister)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBorderRouterRemoveOnMeshPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otBorderRouterRemoveRoute)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern void OT_API_REAL_NAME(otBorderRouterSetNetDataFullCallback)(otInstance *aInstance,
otBorderRouterNetDataFullCallback aCallback,
void *aContext);
otError OT_API_WRAPPER_NAME(otBorderRouterAddOnMeshPrefix)(otInstance *aInstance, const otBorderRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterAddOnMeshPrefix)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterAddRoute)(otInstance *aInstance, const otExternalRouteConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterAddRoute)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterGetNetData)(otInstance *aInstance,
bool aStable,
uint8_t *aData,
uint8_t *aDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterGetNetData)(aInstance, aStable, aData, aDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterGetNextOnMeshPrefix)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otBorderRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterGetNextOnMeshPrefix)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterGetNextRoute)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otExternalRouteConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterGetNextRoute)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterRegister)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterRegister)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterRemoveOnMeshPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterRemoveOnMeshPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRouterRemoveRoute)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRouterRemoveRoute)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otBorderRouterSetNetDataFullCallback)(otInstance *aInstance,
otBorderRouterNetDataFullCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRouterSetNetDataFullCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,321 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Border Routing APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/border_routing.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otBorderRoutingDhcp6PdState OT_API_REAL_NAME(otBorderRoutingDhcp6PdGetState)(otInstance *aInstance);
extern otBorderRoutingState OT_API_REAL_NAME(otBorderRoutingGetState)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otBorderRoutingGetFavoredNat64Prefix)(otInstance *aInstance,
otIp6Prefix *aPrefix,
otRoutePreference *aPreference);
extern otError OT_API_REAL_NAME(otBorderRoutingGetFavoredOmrPrefix)(otInstance *aInstance,
otIp6Prefix *aPrefix,
otRoutePreference *aPreference);
extern otError OT_API_REAL_NAME(otBorderRoutingGetFavoredOnLinkPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otBorderRoutingGetNat64Prefix)(otInstance *aInstance, otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otBorderRoutingGetNextPeerBrEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingPeerBorderRouterEntry *aEntry);
extern otError OT_API_REAL_NAME(otBorderRoutingGetNextPrefixTableEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingPrefixTableEntry *aEntry);
extern otError OT_API_REAL_NAME(otBorderRoutingGetNextRouterEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingRouterEntry *aEntry);
extern otError OT_API_REAL_NAME(otBorderRoutingGetOmrPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otBorderRoutingGetOnLinkPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otBorderRoutingGetPdOmrPrefix)(otInstance *aInstance,
otBorderRoutingPrefixTableEntry *aPrefixInfo);
extern otError OT_API_REAL_NAME(otBorderRoutingGetPdProcessedRaInfo)(otInstance *aInstance,
otPdProcessedRaInfo *aPdProcessedRaInfo);
extern otError OT_API_REAL_NAME(otBorderRoutingInit)(otInstance *aInstance,
uint32_t aInfraIfIndex,
bool aInfraIfIsRunning);
extern otError OT_API_REAL_NAME(otBorderRoutingSetEnabled)(otInstance *aInstance, bool aEnabled);
extern otError OT_API_REAL_NAME(otBorderRoutingSetExtraRouterAdvertOptions)(otInstance *aInstance,
const uint8_t *aOptions,
uint16_t aLength);
extern otRoutePreference OT_API_REAL_NAME(otBorderRoutingGetRouteInfoOptionPreference)(otInstance *aInstance);
extern otRoutePreference OT_API_REAL_NAME(otBorderRoutingGetRoutePreference)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otBorderRoutingCountPeerBrs)(otInstance *aInstance, uint32_t *aMinAge);
extern void OT_API_REAL_NAME(otBorderRoutingClearRouteInfoOptionPreference)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBorderRoutingClearRoutePreference)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otBorderRoutingDhcp6PdSetEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otBorderRoutingDhcp6PdSetRequestCallback)(otInstance *aInstance,
otBorderRoutingRequestDhcp6PdCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otBorderRoutingPrefixTableInitIterator)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator);
extern void OT_API_REAL_NAME(otBorderRoutingSetOnLinkPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern void OT_API_REAL_NAME(otBorderRoutingSetRouteInfoOptionPreference)(otInstance *aInstance,
otRoutePreference aPreference);
extern void OT_API_REAL_NAME(otBorderRoutingSetRoutePreference)(otInstance *aInstance, otRoutePreference aPreference);
otBorderRoutingDhcp6PdState OT_API_WRAPPER_NAME(otBorderRoutingDhcp6PdGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otBorderRoutingDhcp6PdState ret = OT_API_REAL_NAME(otBorderRoutingDhcp6PdGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otBorderRoutingState OT_API_WRAPPER_NAME(otBorderRoutingGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otBorderRoutingState ret = OT_API_REAL_NAME(otBorderRoutingGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetFavoredNat64Prefix)(otInstance *aInstance,
otIp6Prefix *aPrefix,
otRoutePreference *aPreference)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetFavoredNat64Prefix)(aInstance, aPrefix, aPreference);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetFavoredOmrPrefix)(otInstance *aInstance,
otIp6Prefix *aPrefix,
otRoutePreference *aPreference)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetFavoredOmrPrefix)(aInstance, aPrefix, aPreference);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetFavoredOnLinkPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetFavoredOnLinkPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetNat64Prefix)(otInstance *aInstance, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetNat64Prefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetNextPeerBrEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingPeerBorderRouterEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetNextPeerBrEntry)(aInstance, aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetNextPrefixTableEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingPrefixTableEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetNextPrefixTableEntry)(aInstance, aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetNextRouterEntry)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
otBorderRoutingRouterEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetNextRouterEntry)(aInstance, aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetOmrPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetOmrPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetOnLinkPrefix)(otInstance *aInstance, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetOnLinkPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetPdOmrPrefix)(otInstance *aInstance,
otBorderRoutingPrefixTableEntry *aPrefixInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetPdOmrPrefix)(aInstance, aPrefixInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingGetPdProcessedRaInfo)(otInstance *aInstance,
otPdProcessedRaInfo *aPdProcessedRaInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingGetPdProcessedRaInfo)(aInstance, aPdProcessedRaInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingInit)(otInstance *aInstance, uint32_t aInfraIfIndex, bool aInfraIfIsRunning)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingInit)(aInstance, aInfraIfIndex, aInfraIfIsRunning);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingSetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingSetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otBorderRoutingSetExtraRouterAdvertOptions)(otInstance *aInstance,
const uint8_t *aOptions,
uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otBorderRoutingSetExtraRouterAdvertOptions)(aInstance, aOptions, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otRoutePreference OT_API_WRAPPER_NAME(otBorderRoutingGetRouteInfoOptionPreference)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otRoutePreference ret = OT_API_REAL_NAME(otBorderRoutingGetRouteInfoOptionPreference)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otRoutePreference OT_API_WRAPPER_NAME(otBorderRoutingGetRoutePreference)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otRoutePreference ret = OT_API_REAL_NAME(otBorderRoutingGetRoutePreference)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otBorderRoutingCountPeerBrs)(otInstance *aInstance, uint32_t *aMinAge)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otBorderRoutingCountPeerBrs)(aInstance, aMinAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otBorderRoutingClearRouteInfoOptionPreference)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingClearRouteInfoOptionPreference)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingClearRoutePreference)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingClearRoutePreference)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingDhcp6PdSetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingDhcp6PdSetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingDhcp6PdSetRequestCallback)(otInstance *aInstance,
otBorderRoutingRequestDhcp6PdCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingDhcp6PdSetRequestCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingPrefixTableInitIterator)(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingPrefixTableInitIterator)(aInstance, aIterator);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingSetOnLinkPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingSetOnLinkPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingSetRouteInfoOptionPreference)(otInstance *aInstance,
otRoutePreference aPreference)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingSetRouteInfoOptionPreference)(aInstance, aPreference);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otBorderRoutingSetRoutePreference)(otInstance *aInstance, otRoutePreference aPreference)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otBorderRoutingSetRoutePreference)(aInstance, aPreference);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,205 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Channel Manager APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/channel_manager.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otChannelManagerGetAutoChannelSelectionEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otChannelManagerGetAutoCslChannelSelectionEnabled)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otChannelManagerRequestChannelSelect)(otInstance *aInstance, bool aSkipQualityCheck);
extern otError OT_API_REAL_NAME(otChannelManagerRequestCslChannelSelect)(otInstance *aInstance, bool aSkipQualityCheck);
extern otError OT_API_REAL_NAME(otChannelManagerSetAutoChannelSelectionInterval)(otInstance *aInstance,
uint32_t aInterval);
extern otError OT_API_REAL_NAME(otChannelManagerSetDelay)(otInstance *aInstance, uint16_t aDelay);
extern uint16_t OT_API_REAL_NAME(otChannelManagerGetCcaFailureRateThreshold)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otChannelManagerGetDelay)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otChannelManagerGetAutoChannelSelectionInterval)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otChannelManagerGetFavoredChannels)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otChannelManagerGetSupportedChannels)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otChannelManagerGetRequestedChannel)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otChannelManagerRequestChannelChange)(otInstance *aInstance, uint8_t aChannel);
extern void OT_API_REAL_NAME(otChannelManagerSetAutoChannelSelectionEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otChannelManagerSetAutoCslChannelSelectionEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otChannelManagerSetCcaFailureRateThreshold)(otInstance *aInstance, uint16_t aThreshold);
extern void OT_API_REAL_NAME(otChannelManagerSetFavoredChannels)(otInstance *aInstance, uint32_t aChannelMask);
extern void OT_API_REAL_NAME(otChannelManagerSetSupportedChannels)(otInstance *aInstance, uint32_t aChannelMask);
bool OT_API_WRAPPER_NAME(otChannelManagerGetAutoChannelSelectionEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otChannelManagerGetAutoChannelSelectionEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otChannelManagerGetAutoCslChannelSelectionEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otChannelManagerGetAutoCslChannelSelectionEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otChannelManagerRequestChannelSelect)(otInstance *aInstance, bool aSkipQualityCheck)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otChannelManagerRequestChannelSelect)(aInstance, aSkipQualityCheck);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otChannelManagerRequestCslChannelSelect)(otInstance *aInstance, bool aSkipQualityCheck)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otChannelManagerRequestCslChannelSelect)(aInstance, aSkipQualityCheck);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otChannelManagerSetAutoChannelSelectionInterval)(otInstance *aInstance, uint32_t aInterval)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otChannelManagerSetAutoChannelSelectionInterval)(aInstance, aInterval);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otChannelManagerSetDelay)(otInstance *aInstance, uint16_t aDelay)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otChannelManagerSetDelay)(aInstance, aDelay);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otChannelManagerGetCcaFailureRateThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChannelManagerGetCcaFailureRateThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otChannelManagerGetDelay)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChannelManagerGetDelay)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelManagerGetAutoChannelSelectionInterval)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelManagerGetAutoChannelSelectionInterval)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelManagerGetFavoredChannels)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelManagerGetFavoredChannels)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelManagerGetSupportedChannels)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelManagerGetSupportedChannels)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otChannelManagerGetRequestedChannel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otChannelManagerGetRequestedChannel)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otChannelManagerRequestChannelChange)(otInstance *aInstance, uint8_t aChannel)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerRequestChannelChange)(aInstance, aChannel);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChannelManagerSetAutoChannelSelectionEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerSetAutoChannelSelectionEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChannelManagerSetAutoCslChannelSelectionEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerSetAutoCslChannelSelectionEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChannelManagerSetCcaFailureRateThreshold)(otInstance *aInstance, uint16_t aThreshold)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerSetCcaFailureRateThreshold)(aInstance, aThreshold);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChannelManagerSetFavoredChannels)(otInstance *aInstance, uint32_t aChannelMask)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerSetFavoredChannels)(aInstance, aChannelMask);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChannelManagerSetSupportedChannels)(otInstance *aInstance, uint32_t aChannelMask)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChannelManagerSetSupportedChannels)(aInstance, aChannelMask);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,111 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Channel Monitor APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/channel_monitor.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otChannelMonitorIsEnabled)(otInstance *aInstance);
extern int8_t OT_API_REAL_NAME(otChannelMonitorGetRssiThreshold)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otChannelMonitorSetEnabled)(otInstance *aInstance, bool aEnabled);
extern uint16_t OT_API_REAL_NAME(otChannelMonitorGetChannelOccupancy)(otInstance *aInstance, uint8_t aChannel);
extern uint32_t OT_API_REAL_NAME(otChannelMonitorGetSampleCount)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otChannelMonitorGetSampleInterval)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otChannelMonitorGetSampleWindow)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otChannelMonitorIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otChannelMonitorIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otChannelMonitorGetRssiThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otChannelMonitorGetRssiThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otChannelMonitorSetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otChannelMonitorSetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otChannelMonitorGetChannelOccupancy)(otInstance *aInstance, uint8_t aChannel)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChannelMonitorGetChannelOccupancy)(aInstance, aChannel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelMonitorGetSampleCount)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelMonitorGetSampleCount)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelMonitorGetSampleInterval)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelMonitorGetSampleInterval)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otChannelMonitorGetSampleWindow)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otChannelMonitorGetSampleWindow)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,99 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Child Supervision APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/child_supervision.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern uint16_t OT_API_REAL_NAME(otChildSupervisionGetCheckFailureCounter)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otChildSupervisionGetCheckTimeout)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otChildSupervisionGetInterval)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otChildSupervisionResetCheckFailureCounter)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otChildSupervisionSetCheckTimeout)(otInstance *aInstance, uint16_t aTimeout);
extern void OT_API_REAL_NAME(otChildSupervisionSetInterval)(otInstance *aInstance, uint16_t aInterval);
uint16_t OT_API_WRAPPER_NAME(otChildSupervisionGetCheckFailureCounter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChildSupervisionGetCheckFailureCounter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otChildSupervisionGetCheckTimeout)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChildSupervisionGetCheckTimeout)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otChildSupervisionGetInterval)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otChildSupervisionGetInterval)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otChildSupervisionResetCheckFailureCounter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChildSupervisionResetCheckFailureCounter)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChildSupervisionSetCheckTimeout)(otInstance *aInstance, uint16_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChildSupervisionSetCheckTimeout)(aInstance, aTimeout);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otChildSupervisionSetInterval)(otInstance *aInstance, uint16_t aInterval)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otChildSupervisionSetInterval)(aInstance, aInterval);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Cli APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/cli.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otCliSetUserCommands)(const otCliCommand *aUserCommands,
uint8_t aLength,
void *aContext);
extern void OT_API_REAL_NAME(otCliInit)(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext);
extern void OT_API_REAL_NAME(otCliInputLine)(char *aBuf);
extern int OT_API_REAL_NAME(CliUartOutput)(void *aContext, const char *aFormat, va_list aArguments);
otError OT_API_WRAPPER_NAME(otCliSetUserCommands)(const otCliCommand *aUserCommands, uint8_t aLength, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCliSetUserCommands)(aUserCommands, aLength, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otCliInit)(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCliInit)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCliInputLine)(char *aBuf)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCliInputLine)(aBuf);
sl_ot_rtos_release_stack_mutex();
}
int OT_API_WRAPPER_NAME(CliUartOutput)(void *aContext, const char *aFormat, va_list aArguments)
{
sl_ot_rtos_acquire_stack_mutex();
int ret = OT_API_REAL_NAME(CliUartOutput)(aContext, aFormat, aArguments);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,325 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Coap Secure APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/coap_secure.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otCoapSecureIsClosed)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otCoapSecureIsConnected)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otCoapSecureIsConnectionActive)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otCoapSecureConnect)(otInstance *aInstance,
const otSockAddr *aSockAddr,
otHandleCoapSecureClientConnect aHandler,
void *aContext);
extern otError OT_API_REAL_NAME(otCoapSecureGetPeerCertificateBase64)(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength,
size_t aCertBufferSize);
extern otError OT_API_REAL_NAME(otCoapSecureSendRequest)(otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext);
extern otError OT_API_REAL_NAME(otCoapSecureSendRequestBlockWise)(otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook);
extern otError OT_API_REAL_NAME(otCoapSecureSendResponse)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo);
extern otError OT_API_REAL_NAME(otCoapSecureSendResponseBlockWise)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook);
extern otError OT_API_REAL_NAME(otCoapSecureStart)(otInstance *aInstance, uint16_t aPort);
extern otError OT_API_REAL_NAME(otCoapSecureStartWithMaxConnAttempts)(otInstance *aInstance,
uint16_t aPort,
uint16_t aMaxAttempts,
otCoapSecureAutoStopCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otCoapSecureAddBlockWiseResource)(otInstance *aInstance,
otCoapBlockwiseResource *aResource);
extern void OT_API_REAL_NAME(otCoapSecureAddResource)(otInstance *aInstance, otCoapResource *aResource);
extern void OT_API_REAL_NAME(otCoapSecureDisconnect)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otCoapSecureRemoveBlockWiseResource)(otInstance *aInstance,
otCoapBlockwiseResource *aResource);
extern void OT_API_REAL_NAME(otCoapSecureRemoveResource)(otInstance *aInstance, otCoapResource *aResource);
extern void OT_API_REAL_NAME(otCoapSecureSetCaCertificateChain)(otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength);
extern void OT_API_REAL_NAME(otCoapSecureSetCertificate)(otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
uint32_t aPrivateKeyLength);
extern void OT_API_REAL_NAME(otCoapSecureSetClientConnectEventCallback)(otInstance *aInstance,
otHandleCoapSecureClientConnect aHandler,
void *aContext);
extern void OT_API_REAL_NAME(otCoapSecureSetDefaultHandler)(otInstance *aInstance,
otCoapRequestHandler aHandler,
void *aContext);
extern void OT_API_REAL_NAME(otCoapSecureSetPsk)(otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
uint16_t aPskIdLength);
extern void OT_API_REAL_NAME(otCoapSecureSetSslAuthMode)(otInstance *aInstance, bool aVerifyPeerCertificate);
extern void OT_API_REAL_NAME(otCoapSecureStop)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otCoapSecureIsClosed)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otCoapSecureIsClosed)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otCoapSecureIsConnected)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otCoapSecureIsConnected)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otCoapSecureIsConnectionActive)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otCoapSecureIsConnectionActive)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureConnect)(otInstance *aInstance,
const otSockAddr *aSockAddr,
otHandleCoapSecureClientConnect aHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSecureConnect)(aInstance, aSockAddr, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureGetPeerCertificateBase64)(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength,
size_t aCertBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otCoapSecureGetPeerCertificateBase64)(aInstance, aPeerCert, aCertLength, aCertBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureSendRequest)(otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSecureSendRequest)(aInstance, aMessage, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureSendRequestBlockWise)(otInstance *aInstance,
otMessage *aMessage,
otCoapResponseHandler aHandler,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otCoapSecureSendRequestBlockWise)(aInstance, aMessage, aHandler, aContext, aTransmitHook, aReceiveHook);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureSendResponse)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSecureSendResponse)(aInstance, aMessage, aMessageInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureSendResponseBlockWise)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otCoapSecureSendResponseBlockWise)(aInstance, aMessage, aMessageInfo, aContext, aTransmitHook);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureStart)(otInstance *aInstance, uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSecureStart)(aInstance, aPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSecureStartWithMaxConnAttempts)(otInstance *aInstance,
uint16_t aPort,
uint16_t aMaxAttempts,
otCoapSecureAutoStopCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otCoapSecureStartWithMaxConnAttempts)(aInstance, aPort, aMaxAttempts, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otCoapSecureAddBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureAddBlockWiseResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureAddResource)(otInstance *aInstance, otCoapResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureAddResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureDisconnect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureDisconnect)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureRemoveBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureRemoveBlockWiseResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureRemoveResource)(otInstance *aInstance, otCoapResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureRemoveResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetCaCertificateChain)(otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetCaCertificateChain)(aInstance, aX509CaCertificateChain, aX509CaCertChainLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetCertificate)(otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
uint32_t aPrivateKeyLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetCertificate)(aInstance, aX509Cert, aX509Length, aPrivateKey, aPrivateKeyLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetClientConnectEventCallback)(otInstance *aInstance,
otHandleCoapSecureClientConnect aHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetClientConnectEventCallback)(aInstance, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetDefaultHandler)(otInstance *aInstance,
otCoapRequestHandler aHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetDefaultHandler)(aInstance, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetPsk)(otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
uint16_t aPskIdLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetPsk)(aInstance, aPsk, aPskLength, aPskIdentity, aPskIdLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureSetSslAuthMode)(otInstance *aInstance, bool aVerifyPeerCertificate)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureSetSslAuthMode)(aInstance, aVerifyPeerCertificate);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSecureStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSecureStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,515 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Coap APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/coap.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const char *OT_API_REAL_NAME(otCoapMessageCodeToString)(const otMessage *aMessage);
extern const otCoapOption *OT_API_REAL_NAME(otCoapOptionIteratorGetFirstOption)(otCoapOptionIterator *aIterator);
extern const otCoapOption *OT_API_REAL_NAME(otCoapOptionIteratorGetFirstOptionMatching)(otCoapOptionIterator *aIterator,
uint16_t aOption);
extern const otCoapOption *OT_API_REAL_NAME(otCoapOptionIteratorGetNextOption)(otCoapOptionIterator *aIterator);
extern const otCoapOption *OT_API_REAL_NAME(otCoapOptionIteratorGetNextOptionMatching)(otCoapOptionIterator *aIterator,
uint16_t aOption);
extern const uint8_t *OT_API_REAL_NAME(otCoapMessageGetToken)(const otMessage *aMessage);
extern otCoapCode OT_API_REAL_NAME(otCoapMessageGetCode)(const otMessage *aMessage);
extern otCoapType OT_API_REAL_NAME(otCoapMessageGetType)(const otMessage *aMessage);
extern otError OT_API_REAL_NAME(otCoapMessageAppendBlock1Option)(otMessage *aMessage,
uint32_t aNum,
bool aMore,
otCoapBlockSzx aSize);
extern otError OT_API_REAL_NAME(otCoapMessageAppendBlock2Option)(otMessage *aMessage,
uint32_t aNum,
bool aMore,
otCoapBlockSzx aSize);
extern otError OT_API_REAL_NAME(otCoapMessageAppendContentFormatOption)(otMessage *aMessage,
otCoapOptionContentFormat aContentFormat);
extern otError OT_API_REAL_NAME(otCoapMessageAppendMaxAgeOption)(otMessage *aMessage, uint32_t aMaxAge);
extern otError OT_API_REAL_NAME(otCoapMessageAppendObserveOption)(otMessage *aMessage, uint32_t aObserve);
extern otError OT_API_REAL_NAME(otCoapMessageAppendOption)(otMessage *aMessage,
uint16_t aNumber,
uint16_t aLength,
const void *aValue);
extern otError OT_API_REAL_NAME(otCoapMessageAppendProxyUriOption)(otMessage *aMessage, const char *aUriPath);
extern otError OT_API_REAL_NAME(otCoapMessageAppendUintOption)(otMessage *aMessage, uint16_t aNumber, uint32_t aValue);
extern otError OT_API_REAL_NAME(otCoapMessageAppendUriPathOptions)(otMessage *aMessage, const char *aUriPath);
extern otError OT_API_REAL_NAME(otCoapMessageAppendUriQueryOption)(otMessage *aMessage, const char *aUriQuery);
extern otError OT_API_REAL_NAME(otCoapMessageAppendUriQueryOptions)(otMessage *aMessage, const char *aUriQuery);
extern otError OT_API_REAL_NAME(otCoapMessageInitResponse)(otMessage *aResponse,
const otMessage *aRequest,
otCoapType aType,
otCoapCode aCode);
extern otError OT_API_REAL_NAME(otCoapMessageSetPayloadMarker)(otMessage *aMessage);
extern otError OT_API_REAL_NAME(otCoapMessageSetToken)(otMessage *aMessage,
const uint8_t *aToken,
uint8_t aTokenLength);
extern otError OT_API_REAL_NAME(otCoapOptionIteratorGetOptionUintValue)(otCoapOptionIterator *aIterator,
uint64_t *aValue);
extern otError OT_API_REAL_NAME(otCoapOptionIteratorGetOptionValue)(otCoapOptionIterator *aIterator, void *aValue);
extern otError OT_API_REAL_NAME(otCoapOptionIteratorInit)(otCoapOptionIterator *aIterator, const otMessage *aMessage);
extern otError OT_API_REAL_NAME(otCoapSendRequestBlockWiseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
void *aContext,
const otCoapTxParameters *aTxParameters,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook);
extern otError OT_API_REAL_NAME(otCoapSendRequestWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
void *aContext,
const otCoapTxParameters *aTxParameters);
extern otError OT_API_REAL_NAME(otCoapSendResponseBlockWiseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otCoapTxParameters *aTxParameters,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook);
extern otError OT_API_REAL_NAME(otCoapSendResponseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otCoapTxParameters *aTxParameters);
extern otError OT_API_REAL_NAME(otCoapStart)(otInstance *aInstance, uint16_t aPort);
extern otError OT_API_REAL_NAME(otCoapStop)(otInstance *aInstance);
extern otMessage *OT_API_REAL_NAME(otCoapNewMessage)(otInstance *aInstance, const otMessageSettings *aSettings);
extern uint16_t OT_API_REAL_NAME(otCoapBlockSizeFromExponent)(otCoapBlockSzx aSize);
extern uint16_t OT_API_REAL_NAME(otCoapMessageGetMessageId)(const otMessage *aMessage);
extern uint8_t OT_API_REAL_NAME(otCoapMessageGetTokenLength)(const otMessage *aMessage);
extern void OT_API_REAL_NAME(otCoapAddBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource);
extern void OT_API_REAL_NAME(otCoapAddResource)(otInstance *aInstance, otCoapResource *aResource);
extern void OT_API_REAL_NAME(otCoapMessageGenerateToken)(otMessage *aMessage, uint8_t aTokenLength);
extern void OT_API_REAL_NAME(otCoapMessageInit)(otMessage *aMessage, otCoapType aType, otCoapCode aCode);
extern void OT_API_REAL_NAME(otCoapMessageSetCode)(otMessage *aMessage, otCoapCode aCode);
extern void OT_API_REAL_NAME(otCoapRemoveBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource);
extern void OT_API_REAL_NAME(otCoapRemoveResource)(otInstance *aInstance, otCoapResource *aResource);
extern void OT_API_REAL_NAME(otCoapSetDefaultHandler)(otInstance *aInstance,
otCoapRequestHandler aHandler,
void *aContext);
const char *OT_API_WRAPPER_NAME(otCoapMessageCodeToString)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otCoapMessageCodeToString)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otCoapOption *OT_API_WRAPPER_NAME(otCoapOptionIteratorGetFirstOption)(otCoapOptionIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
const otCoapOption *ret = OT_API_REAL_NAME(otCoapOptionIteratorGetFirstOption)(aIterator);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otCoapOption *OT_API_WRAPPER_NAME(otCoapOptionIteratorGetFirstOptionMatching)(otCoapOptionIterator *aIterator,
uint16_t aOption)
{
sl_ot_rtos_acquire_stack_mutex();
const otCoapOption *ret = OT_API_REAL_NAME(otCoapOptionIteratorGetFirstOptionMatching)(aIterator, aOption);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otCoapOption *OT_API_WRAPPER_NAME(otCoapOptionIteratorGetNextOption)(otCoapOptionIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
const otCoapOption *ret = OT_API_REAL_NAME(otCoapOptionIteratorGetNextOption)(aIterator);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otCoapOption *OT_API_WRAPPER_NAME(otCoapOptionIteratorGetNextOptionMatching)(otCoapOptionIterator *aIterator,
uint16_t aOption)
{
sl_ot_rtos_acquire_stack_mutex();
const otCoapOption *ret = OT_API_REAL_NAME(otCoapOptionIteratorGetNextOptionMatching)(aIterator, aOption);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint8_t *OT_API_WRAPPER_NAME(otCoapMessageGetToken)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
const uint8_t *ret = OT_API_REAL_NAME(otCoapMessageGetToken)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otCoapCode OT_API_WRAPPER_NAME(otCoapMessageGetCode)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otCoapCode ret = OT_API_REAL_NAME(otCoapMessageGetCode)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otCoapType OT_API_WRAPPER_NAME(otCoapMessageGetType)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otCoapType ret = OT_API_REAL_NAME(otCoapMessageGetType)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendBlock1Option)(otMessage *aMessage,
uint32_t aNum,
bool aMore,
otCoapBlockSzx aSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendBlock1Option)(aMessage, aNum, aMore, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendBlock2Option)(otMessage *aMessage,
uint32_t aNum,
bool aMore,
otCoapBlockSzx aSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendBlock2Option)(aMessage, aNum, aMore, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendContentFormatOption)(otMessage *aMessage,
otCoapOptionContentFormat aContentFormat)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendContentFormatOption)(aMessage, aContentFormat);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendMaxAgeOption)(otMessage *aMessage, uint32_t aMaxAge)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendMaxAgeOption)(aMessage, aMaxAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendObserveOption)(otMessage *aMessage, uint32_t aObserve)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendObserveOption)(aMessage, aObserve);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendOption)(otMessage *aMessage,
uint16_t aNumber,
uint16_t aLength,
const void *aValue)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendOption)(aMessage, aNumber, aLength, aValue);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendProxyUriOption)(otMessage *aMessage, const char *aUriPath)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendProxyUriOption)(aMessage, aUriPath);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendUintOption)(otMessage *aMessage, uint16_t aNumber, uint32_t aValue)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendUintOption)(aMessage, aNumber, aValue);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendUriPathOptions)(otMessage *aMessage, const char *aUriPath)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendUriPathOptions)(aMessage, aUriPath);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendUriQueryOption)(otMessage *aMessage, const char *aUriQuery)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendUriQueryOption)(aMessage, aUriQuery);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageAppendUriQueryOptions)(otMessage *aMessage, const char *aUriQuery)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageAppendUriQueryOptions)(aMessage, aUriQuery);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageInitResponse)(otMessage *aResponse,
const otMessage *aRequest,
otCoapType aType,
otCoapCode aCode)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageInitResponse)(aResponse, aRequest, aType, aCode);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageSetPayloadMarker)(otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageSetPayloadMarker)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapMessageSetToken)(otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapMessageSetToken)(aMessage, aToken, aTokenLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapOptionIteratorGetOptionUintValue)(otCoapOptionIterator *aIterator, uint64_t *aValue)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapOptionIteratorGetOptionUintValue)(aIterator, aValue);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapOptionIteratorGetOptionValue)(otCoapOptionIterator *aIterator, void *aValue)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapOptionIteratorGetOptionValue)(aIterator, aValue);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapOptionIteratorInit)(otCoapOptionIterator *aIterator, const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapOptionIteratorInit)(aIterator, aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSendRequestBlockWiseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
void *aContext,
const otCoapTxParameters *aTxParameters,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSendRequestBlockWiseWithParameters)(aInstance,
aMessage,
aMessageInfo,
aHandler,
aContext,
aTxParameters,
aTransmitHook,
aReceiveHook);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSendRequestWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
void *aContext,
const otCoapTxParameters *aTxParameters)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otCoapSendRequestWithParameters)(aInstance, aMessage, aMessageInfo, aHandler, aContext, aTxParameters);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSendResponseBlockWiseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otCoapTxParameters *aTxParameters,
void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSendResponseBlockWiseWithParameters)(aInstance,
aMessage,
aMessageInfo,
aTxParameters,
aContext,
aTransmitHook);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapSendResponseWithParameters)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otCoapTxParameters *aTxParameters)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapSendResponseWithParameters)(aInstance, aMessage, aMessageInfo, aTxParameters);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapStart)(otInstance *aInstance, uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapStart)(aInstance, aPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCoapStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCoapStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otCoapNewMessage)(otInstance *aInstance, const otMessageSettings *aSettings)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otCoapNewMessage)(aInstance, aSettings);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otCoapBlockSizeFromExponent)(otCoapBlockSzx aSize)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otCoapBlockSizeFromExponent)(aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otCoapMessageGetMessageId)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otCoapMessageGetMessageId)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otCoapMessageGetTokenLength)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otCoapMessageGetTokenLength)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otCoapAddBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapAddBlockWiseResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapAddResource)(otInstance *aInstance, otCoapResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapAddResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapMessageGenerateToken)(otMessage *aMessage, uint8_t aTokenLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapMessageGenerateToken)(aMessage, aTokenLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapMessageInit)(otMessage *aMessage, otCoapType aType, otCoapCode aCode)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapMessageInit)(aMessage, aType, aCode);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapMessageSetCode)(otMessage *aMessage, otCoapCode aCode)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapMessageSetCode)(aMessage, aCode);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapRemoveBlockWiseResource)(otInstance *aInstance, otCoapBlockwiseResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapRemoveBlockWiseResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapRemoveResource)(otInstance *aInstance, otCoapResource *aResource)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapRemoveResource)(aInstance, aResource);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCoapSetDefaultHandler)(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCoapSetDefaultHandler)(aInstance, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,282 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Commissioner APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/commissioner.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const char *OT_API_REAL_NAME(otCommissionerGetId)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otCommissionerGetProvisioningUrl)(otInstance *aInstance);
extern otCommissionerState OT_API_REAL_NAME(otCommissionerGetState)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otCommissionerAddJoiner)(otInstance *aInstance,
const otExtAddress *aEui64,
const char *aPskd,
uint32_t aTimeout);
extern otError OT_API_REAL_NAME(otCommissionerAddJoinerWithDiscerner)(otInstance *aInstance,
const otJoinerDiscerner *aDiscerner,
const char *aPskd,
uint32_t aTimeout);
extern otError OT_API_REAL_NAME(otCommissionerAnnounceBegin)(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
const otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otCommissionerEnergyScan)(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
uint16_t aScanDuration,
const otIp6Address *aAddress,
otCommissionerEnergyReportCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otCommissionerGetNextJoinerInfo)(otInstance *aInstance,
uint16_t *aIterator,
otJoinerInfo *aJoiner);
extern otError OT_API_REAL_NAME(otCommissionerPanIdQuery)(otInstance *aInstance,
uint16_t aPanId,
uint32_t aChannelMask,
const otIp6Address *aAddress,
otCommissionerPanIdConflictCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otCommissionerRemoveJoiner)(otInstance *aInstance, const otExtAddress *aEui64);
extern otError OT_API_REAL_NAME(otCommissionerRemoveJoinerWithDiscerner)(otInstance *aInstance,
const otJoinerDiscerner *aDiscerner);
extern otError OT_API_REAL_NAME(otCommissionerSendMgmtGet)(otInstance *aInstance,
const uint8_t *aTlvs,
uint8_t aLength);
extern otError OT_API_REAL_NAME(otCommissionerSendMgmtSet)(otInstance *aInstance,
const otCommissioningDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength);
extern otError OT_API_REAL_NAME(otCommissionerSetId)(otInstance *aInstance, const char *aId);
extern otError OT_API_REAL_NAME(otCommissionerSetProvisioningUrl)(otInstance *aInstance, const char *aProvisioningUrl);
extern otError OT_API_REAL_NAME(otCommissionerStart)(otInstance *aInstance,
otCommissionerStateCallback aStateCallback,
otCommissionerJoinerCallback aJoinerCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otCommissionerStop)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otCommissionerGetSessionId)(otInstance *aInstance);
const char *OT_API_WRAPPER_NAME(otCommissionerGetId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otCommissionerGetId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otCommissionerGetProvisioningUrl)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otCommissionerGetProvisioningUrl)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otCommissionerState OT_API_WRAPPER_NAME(otCommissionerGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otCommissionerState ret = OT_API_REAL_NAME(otCommissionerGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerAddJoiner)(otInstance *aInstance,
const otExtAddress *aEui64,
const char *aPskd,
uint32_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerAddJoiner)(aInstance, aEui64, aPskd, aTimeout);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerAddJoinerWithDiscerner)(otInstance *aInstance,
const otJoinerDiscerner *aDiscerner,
const char *aPskd,
uint32_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerAddJoinerWithDiscerner)(aInstance, aDiscerner, aPskd, aTimeout);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerAnnounceBegin)(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerAnnounceBegin)(aInstance, aChannelMask, aCount, aPeriod, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerEnergyScan)(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
uint16_t aScanDuration,
const otIp6Address *aAddress,
otCommissionerEnergyReportCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerEnergyScan)(aInstance,
aChannelMask,
aCount,
aPeriod,
aScanDuration,
aAddress,
aCallback,
aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerGetNextJoinerInfo)(otInstance *aInstance,
uint16_t *aIterator,
otJoinerInfo *aJoiner)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerGetNextJoinerInfo)(aInstance, aIterator, aJoiner);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerPanIdQuery)(otInstance *aInstance,
uint16_t aPanId,
uint32_t aChannelMask,
const otIp6Address *aAddress,
otCommissionerPanIdConflictCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otCommissionerPanIdQuery)(aInstance, aPanId, aChannelMask, aAddress, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerRemoveJoiner)(otInstance *aInstance, const otExtAddress *aEui64)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerRemoveJoiner)(aInstance, aEui64);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerRemoveJoinerWithDiscerner)(otInstance *aInstance,
const otJoinerDiscerner *aDiscerner)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerRemoveJoinerWithDiscerner)(aInstance, aDiscerner);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerSendMgmtGet)(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerSendMgmtGet)(aInstance, aTlvs, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerSendMgmtSet)(otInstance *aInstance,
const otCommissioningDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerSendMgmtSet)(aInstance, aDataset, aTlvs, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerSetId)(otInstance *aInstance, const char *aId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerSetId)(aInstance, aId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerSetProvisioningUrl)(otInstance *aInstance, const char *aProvisioningUrl)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerSetProvisioningUrl)(aInstance, aProvisioningUrl);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerStart)(otInstance *aInstance,
otCommissionerStateCallback aStateCallback,
otCommissionerJoinerCallback aJoinerCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerStart)(aInstance, aStateCallback, aJoinerCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otCommissionerStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otCommissionerStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otCommissionerGetSessionId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otCommissionerGetSessionId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,47 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Config APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/config.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Crypto APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/crypto.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern void OT_API_REAL_NAME(otCryptoAesCcm)(const otCryptoKey *aKey,
uint8_t aTagLength,
const void *aNonce,
uint8_t aNonceLength,
const void *aHeader,
uint32_t aHeaderLength,
void *aPlainText,
void *aCipherText,
uint32_t aLength,
bool aEncrypt,
void *aTag);
extern void OT_API_REAL_NAME(otCryptoHmacSha256)(const otCryptoKey *aKey,
const uint8_t *aBuf,
uint16_t aBufLength,
otCryptoSha256Hash *aHash);
void OT_API_WRAPPER_NAME(otCryptoAesCcm)(const otCryptoKey *aKey,
uint8_t aTagLength,
const void *aNonce,
uint8_t aNonceLength,
const void *aHeader,
uint32_t aHeaderLength,
void *aPlainText,
void *aCipherText,
uint32_t aLength,
bool aEncrypt,
void *aTag)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCryptoAesCcm)
(aKey, aTagLength, aNonce, aNonceLength, aHeader, aHeaderLength, aPlainText, aCipherText, aLength, aEncrypt, aTag);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otCryptoHmacSha256)(const otCryptoKey *aKey,
const uint8_t *aBuf,
uint16_t aBufLength,
otCryptoSha256Hash *aHash)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otCryptoHmacSha256)(aKey, aBuf, aBufLength, aHash);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dataset Ftd APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dataset_ftd.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otDatasetCreateNewNetwork)(otInstance *aInstance, otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetSetDelayTimerMinimal)(otInstance *aInstance, uint32_t aDelayTimerMinimal);
extern uint32_t OT_API_REAL_NAME(otDatasetGetDelayTimerMinimal)(otInstance *aInstance);
otError OT_API_WRAPPER_NAME(otDatasetCreateNewNetwork)(otInstance *aInstance, otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetCreateNewNetwork)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSetDelayTimerMinimal)(otInstance *aInstance, uint32_t aDelayTimerMinimal)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetSetDelayTimerMinimal)(aInstance, aDelayTimerMinimal);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otDatasetGetDelayTimerMinimal)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otDatasetGetDelayTimerMinimal)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dataset Updater APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dataset_updater.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otDatasetUpdaterIsUpdateOngoing)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otDatasetUpdaterRequestUpdate)(otInstance *aInstance,
const otOperationalDataset *aDataset,
otDatasetUpdaterCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otDatasetUpdaterCancelUpdate)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otDatasetUpdaterIsUpdateOngoing)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otDatasetUpdaterIsUpdateOngoing)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetUpdaterRequestUpdate)(otInstance *aInstance,
const otOperationalDataset *aDataset,
otDatasetUpdaterCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetUpdaterRequestUpdate)(aInstance, aDataset, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDatasetUpdaterCancelUpdate)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDatasetUpdaterCancelUpdate)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,263 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dataset APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dataset.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otDatasetIsCommissioned)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otDatasetGeneratePskc)(const char *aPassPhrase,
const otNetworkName *aNetworkName,
const otExtendedPanId *aExtPanId,
otPskc *aPskc);
extern otError OT_API_REAL_NAME(otDatasetGetActive)(otInstance *aInstance, otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetGetActiveTlvs)(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
extern otError OT_API_REAL_NAME(otDatasetGetPending)(otInstance *aInstance, otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetGetPendingTlvs)(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
extern otError OT_API_REAL_NAME(otDatasetParseTlvs)(const otOperationalDatasetTlvs *aDatasetTlvs,
otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetSendMgmtActiveGet)(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
const uint8_t *aTlvTypes,
uint8_t aLength,
const otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otDatasetSendMgmtActiveSet)(otInstance *aInstance,
const otOperationalDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otDatasetSendMgmtPendingGet)(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
const uint8_t *aTlvTypes,
uint8_t aLength,
const otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otDatasetSendMgmtPendingSet)(otInstance *aInstance,
const otOperationalDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otDatasetSetActive)(otInstance *aInstance, const otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetSetActiveTlvs)(otInstance *aInstance,
const otOperationalDatasetTlvs *aDataset);
extern otError OT_API_REAL_NAME(otDatasetSetPending)(otInstance *aInstance, const otOperationalDataset *aDataset);
extern otError OT_API_REAL_NAME(otDatasetSetPendingTlvs)(otInstance *aInstance,
const otOperationalDatasetTlvs *aDataset);
extern otError OT_API_REAL_NAME(otDatasetUpdateTlvs)(const otOperationalDataset *aDataset,
otOperationalDatasetTlvs *aDatasetTlvs);
extern otError OT_API_REAL_NAME(otNetworkNameFromString)(otNetworkName *aNetworkName, const char *aNameString);
extern void OT_API_REAL_NAME(otDatasetConvertToTlvs)(const otOperationalDataset *aDataset,
otOperationalDatasetTlvs *aDatasetTlvs);
bool OT_API_WRAPPER_NAME(otDatasetIsCommissioned)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otDatasetIsCommissioned)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetGeneratePskc)(const char *aPassPhrase,
const otNetworkName *aNetworkName,
const otExtendedPanId *aExtPanId,
otPskc *aPskc)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetGeneratePskc)(aPassPhrase, aNetworkName, aExtPanId, aPskc);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetGetActive)(otInstance *aInstance, otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetGetActive)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetGetActiveTlvs)(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetGetActiveTlvs)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetGetPending)(otInstance *aInstance, otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetGetPending)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetGetPendingTlvs)(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetGetPendingTlvs)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetParseTlvs)(const otOperationalDatasetTlvs *aDatasetTlvs,
otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetParseTlvs)(aDatasetTlvs, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSendMgmtActiveGet)(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
const uint8_t *aTlvTypes,
uint8_t aLength,
const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otDatasetSendMgmtActiveGet)(aInstance, aDatasetComponents, aTlvTypes, aLength, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSendMgmtActiveSet)(otInstance *aInstance,
const otOperationalDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otDatasetSendMgmtActiveSet)(aInstance, aDataset, aTlvs, aLength, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSendMgmtPendingGet)(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
const uint8_t *aTlvTypes,
uint8_t aLength,
const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otDatasetSendMgmtPendingGet)(aInstance, aDatasetComponents, aTlvTypes, aLength, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSendMgmtPendingSet)(otInstance *aInstance,
const otOperationalDataset *aDataset,
const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otDatasetSendMgmtPendingSet)(aInstance, aDataset, aTlvs, aLength, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSetActive)(otInstance *aInstance, const otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetSetActive)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSetActiveTlvs)(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetSetActiveTlvs)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSetPending)(otInstance *aInstance, const otOperationalDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetSetPending)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetSetPendingTlvs)(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetSetPendingTlvs)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDatasetUpdateTlvs)(const otOperationalDataset *aDataset,
otOperationalDatasetTlvs *aDatasetTlvs)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDatasetUpdateTlvs)(aDataset, aDatasetTlvs);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetworkNameFromString)(otNetworkName *aNetworkName, const char *aNameString)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetworkNameFromString)(aNetworkName, aNameString);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDatasetConvertToTlvs)(const otOperationalDataset *aDataset,
otOperationalDatasetTlvs *aDatasetTlvs)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDatasetConvertToTlvs)(aDataset, aDatasetTlvs);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,85 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Diag APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/diag.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otDiagIsEnabled)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otDiagProcessCmd)(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[]);
extern otError OT_API_REAL_NAME(otDiagProcessCmdLine)(otInstance *aInstance, const char *aString);
extern void OT_API_REAL_NAME(otDiagSetOutputCallback)(otInstance *aInstance,
otDiagOutputCallback aCallback,
void *aContext);
bool OT_API_WRAPPER_NAME(otDiagIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otDiagIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDiagProcessCmd)(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[])
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDiagProcessCmd)(aInstance, aArgsLength, aArgs);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDiagProcessCmdLine)(otInstance *aInstance, const char *aString)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDiagProcessCmdLine)(aInstance, aString);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDiagSetOutputCallback)(otInstance *aInstance, otDiagOutputCallback aCallback, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDiagSetOutputCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,289 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dns Client APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dns_client.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const otDnsQueryConfig *OT_API_REAL_NAME(otDnsClientGetDefaultConfig)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otDnsAddressResponseGetAddress)(const otDnsAddressResponse *aResponse,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl);
extern otError OT_API_REAL_NAME(otDnsAddressResponseGetHostName)(const otDnsAddressResponse *aResponse,
char *aNameBuffer,
uint16_t aNameBufferSize);
extern otError OT_API_REAL_NAME(otDnsBrowseResponseGetHostAddress)(const otDnsBrowseResponse *aResponse,
const char *aHostName,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl);
extern otError OT_API_REAL_NAME(otDnsBrowseResponseGetServiceInfo)(const otDnsBrowseResponse *aResponse,
const char *aInstanceLabel,
otDnsServiceInfo *aServiceInfo);
extern otError OT_API_REAL_NAME(otDnsBrowseResponseGetServiceInstance)(const otDnsBrowseResponse *aResponse,
uint16_t aIndex,
char *aLabelBuffer,
uint8_t aLabelBufferSize);
extern otError OT_API_REAL_NAME(otDnsBrowseResponseGetServiceName)(const otDnsBrowseResponse *aResponse,
char *aNameBuffer,
uint16_t aNameBufferSize);
extern otError OT_API_REAL_NAME(otDnsClientBrowse)(otInstance *aInstance,
const char *aServiceName,
otDnsBrowseCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig);
extern otError OT_API_REAL_NAME(otDnsClientResolveAddress)(otInstance *aInstance,
const char *aHostName,
otDnsAddressCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig);
extern otError OT_API_REAL_NAME(otDnsClientResolveIp4Address)(otInstance *aInstance,
const char *aHostName,
otDnsAddressCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig);
extern otError OT_API_REAL_NAME(otDnsClientResolveService)(otInstance *aInstance,
const char *aInstanceLabel,
const char *aServiceName,
otDnsServiceCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig);
extern otError OT_API_REAL_NAME(otDnsClientResolveServiceAndHostAddress)(otInstance *aInstance,
const char *aInstanceLabel,
const char *aServiceName,
otDnsServiceCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig);
extern otError OT_API_REAL_NAME(otDnsServiceResponseGetHostAddress)(const otDnsServiceResponse *aResponse,
const char *aHostName,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl);
extern otError OT_API_REAL_NAME(otDnsServiceResponseGetServiceInfo)(const otDnsServiceResponse *aResponse,
otDnsServiceInfo *aServiceInfo);
extern otError OT_API_REAL_NAME(otDnsServiceResponseGetServiceName)(const otDnsServiceResponse *aResponse,
char *aLabelBuffer,
uint8_t aLabelBufferSize,
char *aNameBuffer,
uint16_t aNameBufferSize);
extern void OT_API_REAL_NAME(otDnsClientSetDefaultConfig)(otInstance *aInstance, const otDnsQueryConfig *aConfig);
const otDnsQueryConfig *OT_API_WRAPPER_NAME(otDnsClientGetDefaultConfig)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otDnsQueryConfig *ret = OT_API_REAL_NAME(otDnsClientGetDefaultConfig)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsAddressResponseGetAddress)(const otDnsAddressResponse *aResponse,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsAddressResponseGetAddress)(aResponse, aIndex, aAddress, aTtl);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsAddressResponseGetHostName)(const otDnsAddressResponse *aResponse,
char *aNameBuffer,
uint16_t aNameBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsAddressResponseGetHostName)(aResponse, aNameBuffer, aNameBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsBrowseResponseGetHostAddress)(const otDnsBrowseResponse *aResponse,
const char *aHostName,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsBrowseResponseGetHostAddress)(aResponse, aHostName, aIndex, aAddress, aTtl);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsBrowseResponseGetServiceInfo)(const otDnsBrowseResponse *aResponse,
const char *aInstanceLabel,
otDnsServiceInfo *aServiceInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsBrowseResponseGetServiceInfo)(aResponse, aInstanceLabel, aServiceInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsBrowseResponseGetServiceInstance)(const otDnsBrowseResponse *aResponse,
uint16_t aIndex,
char *aLabelBuffer,
uint8_t aLabelBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otDnsBrowseResponseGetServiceInstance)(aResponse, aIndex, aLabelBuffer, aLabelBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsBrowseResponseGetServiceName)(const otDnsBrowseResponse *aResponse,
char *aNameBuffer,
uint16_t aNameBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsBrowseResponseGetServiceName)(aResponse, aNameBuffer, aNameBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsClientBrowse)(otInstance *aInstance,
const char *aServiceName,
otDnsBrowseCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsClientBrowse)(aInstance, aServiceName, aCallback, aContext, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsClientResolveAddress)(otInstance *aInstance,
const char *aHostName,
otDnsAddressCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsClientResolveAddress)(aInstance, aHostName, aCallback, aContext, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsClientResolveIp4Address)(otInstance *aInstance,
const char *aHostName,
otDnsAddressCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsClientResolveIp4Address)(aInstance, aHostName, aCallback, aContext, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsClientResolveService)(otInstance *aInstance,
const char *aInstanceLabel,
const char *aServiceName,
otDnsServiceCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otDnsClientResolveService)(aInstance, aInstanceLabel, aServiceName, aCallback, aContext, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsClientResolveServiceAndHostAddress)(otInstance *aInstance,
const char *aInstanceLabel,
const char *aServiceName,
otDnsServiceCallback aCallback,
void *aContext,
const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otDnsClientResolveServiceAndHostAddress)(aInstance, aInstanceLabel, aServiceName, aCallback, aContext, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsServiceResponseGetHostAddress)(const otDnsServiceResponse *aResponse,
const char *aHostName,
uint16_t aIndex,
otIp6Address *aAddress,
uint32_t *aTtl)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsServiceResponseGetHostAddress)(aResponse, aHostName, aIndex, aAddress, aTtl);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsServiceResponseGetServiceInfo)(const otDnsServiceResponse *aResponse,
otDnsServiceInfo *aServiceInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsServiceResponseGetServiceInfo)(aResponse, aServiceInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsServiceResponseGetServiceName)(const otDnsServiceResponse *aResponse,
char *aLabelBuffer,
uint8_t aLabelBufferSize,
char *aNameBuffer,
uint16_t aNameBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otDnsServiceResponseGetServiceName)(aResponse, aLabelBuffer, aLabelBufferSize, aNameBuffer, aNameBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDnsClientSetDefaultConfig)(otInstance *aInstance, const otDnsQueryConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnsClientSetDefaultConfig)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,101 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dns APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dns.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otDnsIsNameCompressionEnabled)(void);
extern otError OT_API_REAL_NAME(otDnsEncodeTxtData)(const otDnsTxtEntry *aTxtEntries,
uint16_t aNumTxtEntries,
uint8_t *aTxtData,
uint16_t *aTxtDataLength);
extern otError OT_API_REAL_NAME(otDnsGetNextTxtEntry)(otDnsTxtEntryIterator *aIterator, otDnsTxtEntry *aEntry);
extern void OT_API_REAL_NAME(otDnsInitTxtEntryIterator)(otDnsTxtEntryIterator *aIterator,
const uint8_t *aTxtData,
uint16_t aTxtDataLength);
extern void OT_API_REAL_NAME(otDnsSetNameCompressionEnabled)(bool aEnabled);
bool OT_API_WRAPPER_NAME(otDnsIsNameCompressionEnabled)(void)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otDnsIsNameCompressionEnabled)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsEncodeTxtData)(const otDnsTxtEntry *aTxtEntries,
uint16_t aNumTxtEntries,
uint8_t *aTxtData,
uint16_t *aTxtDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsEncodeTxtData)(aTxtEntries, aNumTxtEntries, aTxtData, aTxtDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otDnsGetNextTxtEntry)(otDnsTxtEntryIterator *aIterator, otDnsTxtEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otDnsGetNextTxtEntry)(aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDnsInitTxtEntryIterator)(otDnsTxtEntryIterator *aIterator,
const uint8_t *aTxtData,
uint16_t aTxtDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnsInitTxtEntryIterator)(aIterator, aTxtData, aTxtDataLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otDnsSetNameCompressionEnabled)(bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnsSetNameCompressionEnabled)(aEnabled);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,132 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Dnssd Server APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/dnssd_server.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otDnssdUpstreamQueryIsEnabled)(otInstance *aInstance);
extern const otDnssdCounters *OT_API_REAL_NAME(otDnssdGetCounters)(otInstance *aInstance);
extern const otDnssdQuery *OT_API_REAL_NAME(otDnssdGetNextQuery)(otInstance *aInstance, const otDnssdQuery *aQuery);
extern otDnssdQueryType OT_API_REAL_NAME(otDnssdGetQueryTypeAndName)(const otDnssdQuery *aQuery,
char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE]);
extern void OT_API_REAL_NAME(otDnssdQueryHandleDiscoveredHost)(otInstance *aInstance,
const char *aHostFullName,
otDnssdHostInfo *aHostInfo);
extern void OT_API_REAL_NAME(otDnssdQueryHandleDiscoveredServiceInstance)(otInstance *aInstance,
const char *aServiceFullName,
otDnssdServiceInstanceInfo *aInstanceInfo);
extern void OT_API_REAL_NAME(otDnssdQuerySetCallbacks)(otInstance *aInstance,
otDnssdQuerySubscribeCallback aSubscribe,
otDnssdQueryUnsubscribeCallback aUnsubscribe,
void *aContext);
extern void OT_API_REAL_NAME(otDnssdUpstreamQuerySetEnabled)(otInstance *aInstance, bool aEnabled);
bool OT_API_WRAPPER_NAME(otDnssdUpstreamQueryIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otDnssdUpstreamQueryIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otDnssdCounters *OT_API_WRAPPER_NAME(otDnssdGetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otDnssdCounters *ret = OT_API_REAL_NAME(otDnssdGetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otDnssdQuery *OT_API_WRAPPER_NAME(otDnssdGetNextQuery)(otInstance *aInstance, const otDnssdQuery *aQuery)
{
sl_ot_rtos_acquire_stack_mutex();
const otDnssdQuery *ret = OT_API_REAL_NAME(otDnssdGetNextQuery)(aInstance, aQuery);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otDnssdQueryType OT_API_WRAPPER_NAME(otDnssdGetQueryTypeAndName)(const otDnssdQuery *aQuery,
char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE])
{
sl_ot_rtos_acquire_stack_mutex();
otDnssdQueryType ret = OT_API_REAL_NAME(otDnssdGetQueryTypeAndName)(aQuery, aNameOutput);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otDnssdQueryHandleDiscoveredHost)(otInstance *aInstance,
const char *aHostFullName,
otDnssdHostInfo *aHostInfo)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnssdQueryHandleDiscoveredHost)(aInstance, aHostFullName, aHostInfo);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otDnssdQueryHandleDiscoveredServiceInstance)(otInstance *aInstance,
const char *aServiceFullName,
otDnssdServiceInstanceInfo *aInstanceInfo)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnssdQueryHandleDiscoveredServiceInstance)(aInstance, aServiceFullName, aInstanceInfo);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otDnssdQuerySetCallbacks)(otInstance *aInstance,
otDnssdQuerySubscribeCallback aSubscribe,
otDnssdQueryUnsubscribeCallback aUnsubscribe,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnssdQuerySetCallbacks)(aInstance, aSubscribe, aUnsubscribe, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otDnssdUpstreamQuerySetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otDnssdUpstreamQuerySetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,57 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Error APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/error.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const char *OT_API_REAL_NAME(otThreadErrorToString)(otError aError);
const char *OT_API_WRAPPER_NAME(otThreadErrorToString)(otError aError)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadErrorToString)(aError);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Heap APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/heap.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern void *OT_API_REAL_NAME(otHeapCAlloc)(size_t aCount, size_t aSize);
extern void OT_API_REAL_NAME(otHeapFree)(void *aPointer);
void *OT_API_WRAPPER_NAME(otHeapCAlloc)(size_t aCount, size_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
void *ret = OT_API_REAL_NAME(otHeapCAlloc)(aCount, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otHeapFree)(void *aPointer)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otHeapFree)(aPointer);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,200 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread History Tracker APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/history_tracker.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const otHistoryTrackerExternalRouteInfo *OT_API_REAL_NAME(otHistoryTrackerIterateExternalRouteHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerMessageInfo *OT_API_REAL_NAME(
otHistoryTrackerIterateRxHistory)(otInstance *aInstance, otHistoryTrackerIterator *aIterator, uint32_t *aEntryAge);
extern const otHistoryTrackerMessageInfo *OT_API_REAL_NAME(
otHistoryTrackerIterateTxHistory)(otInstance *aInstance, otHistoryTrackerIterator *aIterator, uint32_t *aEntryAge);
extern const otHistoryTrackerMulticastAddressInfo *OT_API_REAL_NAME(otHistoryTrackerIterateMulticastAddressHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerNeighborInfo *OT_API_REAL_NAME(otHistoryTrackerIterateNeighborHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerNetworkInfo *OT_API_REAL_NAME(otHistoryTrackerIterateNetInfoHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerOnMeshPrefixInfo *OT_API_REAL_NAME(otHistoryTrackerIterateOnMeshPrefixHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerRouterInfo *OT_API_REAL_NAME(otHistoryTrackerIterateRouterHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern const otHistoryTrackerUnicastAddressInfo *OT_API_REAL_NAME(otHistoryTrackerIterateUnicastAddressHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge);
extern void OT_API_REAL_NAME(otHistoryTrackerEntryAgeToString)(uint32_t aEntryAge, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otHistoryTrackerInitIterator)(otHistoryTrackerIterator *aIterator);
const otHistoryTrackerExternalRouteInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateExternalRouteHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerExternalRouteInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateExternalRouteHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerMessageInfo *OT_API_WRAPPER_NAME(
otHistoryTrackerIterateRxHistory)(otInstance *aInstance, otHistoryTrackerIterator *aIterator, uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerMessageInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateRxHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerMessageInfo *OT_API_WRAPPER_NAME(
otHistoryTrackerIterateTxHistory)(otInstance *aInstance, otHistoryTrackerIterator *aIterator, uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerMessageInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateTxHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerMulticastAddressInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateMulticastAddressHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerMulticastAddressInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateMulticastAddressHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerNeighborInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateNeighborHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerNeighborInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateNeighborHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerNetworkInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateNetInfoHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerNetworkInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateNetInfoHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerOnMeshPrefixInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateOnMeshPrefixHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerOnMeshPrefixInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateOnMeshPrefixHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerRouterInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateRouterHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerRouterInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateRouterHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otHistoryTrackerUnicastAddressInfo *OT_API_WRAPPER_NAME(otHistoryTrackerIterateUnicastAddressHistory)(
otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
uint32_t *aEntryAge)
{
sl_ot_rtos_acquire_stack_mutex();
const otHistoryTrackerUnicastAddressInfo *ret =
OT_API_REAL_NAME(otHistoryTrackerIterateUnicastAddressHistory)(aInstance, aIterator, aEntryAge);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otHistoryTrackerEntryAgeToString)(uint32_t aEntryAge, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otHistoryTrackerEntryAgeToString)(aEntryAge, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otHistoryTrackerInitIterator)(otHistoryTrackerIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otHistoryTrackerInitIterator)(aIterator);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,89 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Icmp6 APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/icmp6.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otIcmp6RegisterHandler)(otInstance *aInstance, otIcmp6Handler *aHandler);
extern otError OT_API_REAL_NAME(otIcmp6SendEchoRequest)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
uint16_t aIdentifier);
extern otIcmp6EchoMode OT_API_REAL_NAME(otIcmp6GetEchoMode)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otIcmp6SetEchoMode)(otInstance *aInstance, otIcmp6EchoMode aMode);
otError OT_API_WRAPPER_NAME(otIcmp6RegisterHandler)(otInstance *aInstance, otIcmp6Handler *aHandler)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIcmp6RegisterHandler)(aInstance, aHandler);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIcmp6SendEchoRequest)(otInstance *aInstance,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
uint16_t aIdentifier)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIcmp6SendEchoRequest)(aInstance, aMessage, aMessageInfo, aIdentifier);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otIcmp6EchoMode OT_API_WRAPPER_NAME(otIcmp6GetEchoMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otIcmp6EchoMode ret = OT_API_REAL_NAME(otIcmp6GetEchoMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otIcmp6SetEchoMode)(otInstance *aInstance, otIcmp6EchoMode aMode)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIcmp6SetEchoMode)(aInstance, aMode);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,203 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Instance APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/instance.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otInstanceIsInitialized)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otGetRadioVersionString)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otGetVersionString)(void);
extern otError OT_API_REAL_NAME(otInstanceErasePersistentInfo)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otInstanceResetToBootloader)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otSetStateChangedCallback)(otInstance *aInstance,
otStateChangedCallback aCallback,
void *aContext);
extern otInstance *OT_API_REAL_NAME(otInstanceInit)(void *aInstanceBuffer, size_t *aInstanceBufferSize);
extern otInstance *OT_API_REAL_NAME(otInstanceInitMultiple)(uint8_t aIdx);
extern otInstance *OT_API_REAL_NAME(otInstanceInitSingle)(void);
extern uint32_t OT_API_REAL_NAME(otInstanceGetId)(otInstance *aInstance);
extern uint64_t OT_API_REAL_NAME(otInstanceGetUptime)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otInstanceFactoryReset)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otInstanceFinalize)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otInstanceGetUptimeAsString)(otInstance *aInstance, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otInstanceReset)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otInstanceResetRadioStack)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otRemoveStateChangeCallback)(otInstance *aInstance,
otStateChangedCallback aCallback,
void *aContext);
bool OT_API_WRAPPER_NAME(otInstanceIsInitialized)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otInstanceIsInitialized)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otGetRadioVersionString)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otGetRadioVersionString)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otGetVersionString)(void)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otGetVersionString)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otInstanceErasePersistentInfo)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otInstanceErasePersistentInfo)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otInstanceResetToBootloader)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otInstanceResetToBootloader)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSetStateChangedCallback)(otInstance *aInstance,
otStateChangedCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSetStateChangedCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otInstance *OT_API_WRAPPER_NAME(otInstanceInit)(void *aInstanceBuffer, size_t *aInstanceBufferSize)
{
sl_ot_rtos_acquire_stack_mutex();
otInstance *ret = OT_API_REAL_NAME(otInstanceInit)(aInstanceBuffer, aInstanceBufferSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otInstance *OT_API_WRAPPER_NAME(otInstanceInitMultiple)(uint8_t aIdx)
{
sl_ot_rtos_acquire_stack_mutex();
otInstance *ret = OT_API_REAL_NAME(otInstanceInitMultiple)(aIdx);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otInstance *OT_API_WRAPPER_NAME(otInstanceInitSingle)(void)
{
sl_ot_rtos_acquire_stack_mutex();
otInstance *ret = OT_API_REAL_NAME(otInstanceInitSingle)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otInstanceGetId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otInstanceGetId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint64_t OT_API_WRAPPER_NAME(otInstanceGetUptime)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint64_t ret = OT_API_REAL_NAME(otInstanceGetUptime)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otInstanceFactoryReset)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otInstanceFactoryReset)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otInstanceFinalize)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otInstanceFinalize)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otInstanceGetUptimeAsString)(otInstance *aInstance, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otInstanceGetUptimeAsString)(aInstance, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otInstanceReset)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otInstanceReset)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otInstanceResetRadioStack)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otInstanceResetRadioStack)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otRemoveStateChangeCallback)(otInstance *aInstance,
otStateChangedCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otRemoveStateChangeCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,413 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Ip6 APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/ip6.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otIp6ArePrefixesEqual)(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond);
extern bool OT_API_REAL_NAME(otIp6HasUnicastAddress)(otInstance *aInstance, const otIp6Address *aAddress);
extern bool OT_API_REAL_NAME(otIp6IsAddressEqual)(const otIp6Address *aFirst, const otIp6Address *aSecond);
extern bool OT_API_REAL_NAME(otIp6IsAddressUnspecified)(const otIp6Address *aAddress);
extern bool OT_API_REAL_NAME(otIp6IsEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otIp6IsReceiveFilterEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otIp6IsSlaacEnabled)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otIp6ProtoToString)(uint8_t aIpProto);
extern const otBorderRoutingCounters *OT_API_REAL_NAME(otIp6GetBorderRoutingCounters)(otInstance *aInstance);
extern const otNetifAddress *OT_API_REAL_NAME(otIp6GetUnicastAddresses)(otInstance *aInstance);
extern const otNetifMulticastAddress *OT_API_REAL_NAME(otIp6GetMulticastAddresses)(otInstance *aInstance);
extern const uint16_t *OT_API_REAL_NAME(otIp6GetUnsecurePorts)(otInstance *aInstance, uint8_t *aNumEntries);
extern otError OT_API_REAL_NAME(otIp6AddUnicastAddress)(otInstance *aInstance, const otNetifAddress *aAddress);
extern otError OT_API_REAL_NAME(otIp6AddUnsecurePort)(otInstance *aInstance, uint16_t aPort);
extern otError OT_API_REAL_NAME(otIp6AddressFromString)(const char *aString, otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otIp6PrefixFromString)(const char *aString, otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otIp6RegisterMulticastListeners)(otInstance *aInstance,
const otIp6Address *aAddresses,
uint8_t aAddressNum,
const uint32_t *aTimeout,
otIp6RegisterMulticastListenersCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otIp6RemoveUnicastAddress)(otInstance *aInstance, const otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otIp6RemoveUnsecurePort)(otInstance *aInstance, uint16_t aPort);
extern otError OT_API_REAL_NAME(otIp6SelectSourceAddress)(otInstance *aInstance, otMessageInfo *aMessageInfo);
extern otError OT_API_REAL_NAME(otIp6Send)(otInstance *aInstance, otMessage *aMessage);
extern otError OT_API_REAL_NAME(otIp6SetEnabled)(otInstance *aInstance, bool aEnabled);
extern otError OT_API_REAL_NAME(otIp6SetMeshLocalIid)(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid);
extern otError OT_API_REAL_NAME(otIp6SubscribeMulticastAddress)(otInstance *aInstance, const otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otIp6UnsubscribeMulticastAddress)(otInstance *aInstance, const otIp6Address *aAddress);
extern otMessage *OT_API_REAL_NAME(otIp6NewMessage)(otInstance *aInstance, const otMessageSettings *aSettings);
extern otMessage *OT_API_REAL_NAME(otIp6NewMessageFromBuffer)(otInstance *aInstance,
const uint8_t *aData,
uint16_t aDataLength,
const otMessageSettings *aSettings);
extern uint8_t OT_API_REAL_NAME(otIp6PrefixMatch)(const otIp6Address *aFirst, const otIp6Address *aSecond);
extern void OT_API_REAL_NAME(otIp6AddressToString)(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otIp6GetPrefix)(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix);
extern void OT_API_REAL_NAME(otIp6PrefixToString)(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otIp6RemoveAllUnsecurePorts)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otIp6ResetBorderRoutingCounters)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otIp6SetAddressCallback)(otInstance *aInstance,
otIp6AddressCallback aCallback,
void *aCallbackContext);
extern void OT_API_REAL_NAME(otIp6SetReceiveCallback)(otInstance *aInstance,
otIp6ReceiveCallback aCallback,
void *aCallbackContext);
extern void OT_API_REAL_NAME(otIp6SetReceiveFilterEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otIp6SetSlaacEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otIp6SetSlaacPrefixFilter)(otInstance *aInstance, otIp6SlaacPrefixFilter aFilter);
extern void OT_API_REAL_NAME(otIp6SockAddrToString)(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize);
bool OT_API_WRAPPER_NAME(otIp6ArePrefixesEqual)(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6ArePrefixesEqual)(aFirst, aSecond);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6HasUnicastAddress)(otInstance *aInstance, const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6HasUnicastAddress)(aInstance, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6IsAddressEqual)(const otIp6Address *aFirst, const otIp6Address *aSecond)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6IsAddressEqual)(aFirst, aSecond);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6IsAddressUnspecified)(const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6IsAddressUnspecified)(aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6IsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6IsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6IsReceiveFilterEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6IsReceiveFilterEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otIp6IsSlaacEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp6IsSlaacEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otIp6ProtoToString)(uint8_t aIpProto)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otIp6ProtoToString)(aIpProto);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otBorderRoutingCounters *OT_API_WRAPPER_NAME(otIp6GetBorderRoutingCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otBorderRoutingCounters *ret = OT_API_REAL_NAME(otIp6GetBorderRoutingCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otNetifAddress *OT_API_WRAPPER_NAME(otIp6GetUnicastAddresses)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otNetifAddress *ret = OT_API_REAL_NAME(otIp6GetUnicastAddresses)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otNetifMulticastAddress *OT_API_WRAPPER_NAME(otIp6GetMulticastAddresses)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otNetifMulticastAddress *ret = OT_API_REAL_NAME(otIp6GetMulticastAddresses)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint16_t *OT_API_WRAPPER_NAME(otIp6GetUnsecurePorts)(otInstance *aInstance, uint8_t *aNumEntries)
{
sl_ot_rtos_acquire_stack_mutex();
const uint16_t *ret = OT_API_REAL_NAME(otIp6GetUnsecurePorts)(aInstance, aNumEntries);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6AddUnicastAddress)(otInstance *aInstance, const otNetifAddress *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6AddUnicastAddress)(aInstance, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6AddUnsecurePort)(otInstance *aInstance, uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6AddUnsecurePort)(aInstance, aPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6AddressFromString)(const char *aString, otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6AddressFromString)(aString, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6PrefixFromString)(const char *aString, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6PrefixFromString)(aString, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6RegisterMulticastListeners)(otInstance *aInstance,
const otIp6Address *aAddresses,
uint8_t aAddressNum,
const uint32_t *aTimeout,
otIp6RegisterMulticastListenersCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otIp6RegisterMulticastListeners)(aInstance, aAddresses, aAddressNum, aTimeout, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6RemoveUnicastAddress)(otInstance *aInstance, const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6RemoveUnicastAddress)(aInstance, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6RemoveUnsecurePort)(otInstance *aInstance, uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6RemoveUnsecurePort)(aInstance, aPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6SelectSourceAddress)(otInstance *aInstance, otMessageInfo *aMessageInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6SelectSourceAddress)(aInstance, aMessageInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6Send)(otInstance *aInstance, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6Send)(aInstance, aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6SetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6SetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6SetMeshLocalIid)(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6SetMeshLocalIid)(aInstance, aIid);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6SubscribeMulticastAddress)(otInstance *aInstance, const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6SubscribeMulticastAddress)(aInstance, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp6UnsubscribeMulticastAddress)(otInstance *aInstance, const otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp6UnsubscribeMulticastAddress)(aInstance, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otIp6NewMessage)(otInstance *aInstance, const otMessageSettings *aSettings)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otIp6NewMessage)(aInstance, aSettings);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otIp6NewMessageFromBuffer)(otInstance *aInstance,
const uint8_t *aData,
uint16_t aDataLength,
const otMessageSettings *aSettings)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otIp6NewMessageFromBuffer)(aInstance, aData, aDataLength, aSettings);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otIp6PrefixMatch)(const otIp6Address *aFirst, const otIp6Address *aSecond)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otIp6PrefixMatch)(aFirst, aSecond);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otIp6AddressToString)(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6AddressToString)(aAddress, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6GetPrefix)(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6GetPrefix)(aAddress, aLength, aPrefix);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6PrefixToString)(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6PrefixToString)(aPrefix, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6RemoveAllUnsecurePorts)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6RemoveAllUnsecurePorts)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6ResetBorderRoutingCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6ResetBorderRoutingCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SetAddressCallback)(otInstance *aInstance,
otIp6AddressCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SetAddressCallback)(aInstance, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SetReceiveCallback)(otInstance *aInstance,
otIp6ReceiveCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SetReceiveCallback)(aInstance, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SetReceiveFilterEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SetReceiveFilterEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SetSlaacEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SetSlaacEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SetSlaacPrefixFilter)(otInstance *aInstance, otIp6SlaacPrefixFilter aFilter)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SetSlaacPrefixFilter)(aInstance, aFilter);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp6SockAddrToString)(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp6SockAddrToString)(aSockAddr, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,151 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Jam Detection APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/jam_detection.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otJamDetectionGetState)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otJamDetectionIsEnabled)(otInstance *aInstance);
extern int8_t OT_API_REAL_NAME(otJamDetectionGetRssiThreshold)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otJamDetectionSetBusyPeriod)(otInstance *aInstance, uint8_t aBusyPeriod);
extern otError OT_API_REAL_NAME(otJamDetectionSetRssiThreshold)(otInstance *aInstance, int8_t aRssiThreshold);
extern otError OT_API_REAL_NAME(otJamDetectionSetWindow)(otInstance *aInstance, uint8_t aWindow);
extern otError OT_API_REAL_NAME(otJamDetectionStart)(otInstance *aInstance,
otJamDetectionCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otJamDetectionStop)(otInstance *aInstance);
extern uint64_t OT_API_REAL_NAME(otJamDetectionGetHistoryBitmap)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otJamDetectionGetBusyPeriod)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otJamDetectionGetWindow)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otJamDetectionGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otJamDetectionGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otJamDetectionIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otJamDetectionIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otJamDetectionGetRssiThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otJamDetectionGetRssiThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJamDetectionSetBusyPeriod)(otInstance *aInstance, uint8_t aBusyPeriod)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJamDetectionSetBusyPeriod)(aInstance, aBusyPeriod);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJamDetectionSetRssiThreshold)(otInstance *aInstance, int8_t aRssiThreshold)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJamDetectionSetRssiThreshold)(aInstance, aRssiThreshold);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJamDetectionSetWindow)(otInstance *aInstance, uint8_t aWindow)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJamDetectionSetWindow)(aInstance, aWindow);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJamDetectionStart)(otInstance *aInstance,
otJamDetectionCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJamDetectionStart)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJamDetectionStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJamDetectionStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint64_t OT_API_WRAPPER_NAME(otJamDetectionGetHistoryBitmap)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint64_t ret = OT_API_REAL_NAME(otJamDetectionGetHistoryBitmap)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otJamDetectionGetBusyPeriod)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otJamDetectionGetBusyPeriod)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otJamDetectionGetWindow)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otJamDetectionGetWindow)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,134 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Joiner APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/joiner.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const char *OT_API_REAL_NAME(otJoinerStateToString)(otJoinerState aState);
extern const otExtAddress *OT_API_REAL_NAME(otJoinerGetId)(otInstance *aInstance);
extern const otJoinerDiscerner *OT_API_REAL_NAME(otJoinerGetDiscerner)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otJoinerSetDiscerner)(otInstance *aInstance, otJoinerDiscerner *aDiscerner);
extern otError OT_API_REAL_NAME(otJoinerStart)(otInstance *aInstance,
const char *aPskd,
const char *aProvisioningUrl,
const char *aVendorName,
const char *aVendorModel,
const char *aVendorSwVersion,
const char *aVendorData,
otJoinerCallback aCallback,
void *aContext);
extern otJoinerState OT_API_REAL_NAME(otJoinerGetState)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otJoinerStop)(otInstance *aInstance);
const char *OT_API_WRAPPER_NAME(otJoinerStateToString)(otJoinerState aState)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otJoinerStateToString)(aState);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otExtAddress *OT_API_WRAPPER_NAME(otJoinerGetId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otExtAddress *ret = OT_API_REAL_NAME(otJoinerGetId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otJoinerDiscerner *OT_API_WRAPPER_NAME(otJoinerGetDiscerner)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otJoinerDiscerner *ret = OT_API_REAL_NAME(otJoinerGetDiscerner)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJoinerSetDiscerner)(otInstance *aInstance, otJoinerDiscerner *aDiscerner)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJoinerSetDiscerner)(aInstance, aDiscerner);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otJoinerStart)(otInstance *aInstance,
const char *aPskd,
const char *aProvisioningUrl,
const char *aVendorName,
const char *aVendorModel,
const char *aVendorSwVersion,
const char *aVendorData,
otJoinerCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otJoinerStart)(aInstance,
aPskd,
aProvisioningUrl,
aVendorName,
aVendorModel,
aVendorSwVersion,
aVendorData,
aCallback,
aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otJoinerState OT_API_WRAPPER_NAME(otJoinerGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otJoinerState ret = OT_API_REAL_NAME(otJoinerGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otJoinerStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otJoinerStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,173 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Link Metrics APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/link_metrics.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otLinkMetricsManagerIsEnabled)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkMetricsConfigEnhAckProbing)(
otInstance *aInstance,
const otIp6Address *aDestination,
otLinkMetricsEnhAckFlags aEnhAckFlags,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
void *aCallbackContext,
otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback,
void *aEnhAckCallbackContext);
extern otError OT_API_REAL_NAME(otLinkMetricsConfigForwardTrackingSeries)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
otLinkMetricsSeriesFlags aSeriesFlags,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otLinkMetricsManagerGetMetricsValueByExtAddr)(otInstance *aInstance,
const otExtAddress *aExtAddress,
otLinkMetricsValues *aLinkMetricsValues);
extern otError OT_API_REAL_NAME(otLinkMetricsQuery)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsReportCallback aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otLinkMetricsSendLinkProbe)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
uint8_t aLength);
extern void OT_API_REAL_NAME(otLinkMetricsManagerSetEnabled)(otInstance *aInstance, bool aEnable);
bool OT_API_WRAPPER_NAME(otLinkMetricsManagerIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkMetricsManagerIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkMetricsConfigEnhAckProbing)(
otInstance *aInstance,
const otIp6Address *aDestination,
otLinkMetricsEnhAckFlags aEnhAckFlags,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
void *aCallbackContext,
otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback,
void *aEnhAckCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkMetricsConfigEnhAckProbing)(aInstance,
aDestination,
aEnhAckFlags,
aLinkMetricsFlags,
aCallback,
aCallbackContext,
aEnhAckCallback,
aEnhAckCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkMetricsConfigForwardTrackingSeries)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
otLinkMetricsSeriesFlags aSeriesFlags,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkMetricsConfigForwardTrackingSeries)(aInstance,
aDestination,
aSeriesId,
aSeriesFlags,
aLinkMetricsFlags,
aCallback,
aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkMetricsManagerGetMetricsValueByExtAddr)(otInstance *aInstance,
const otExtAddress *aExtAddress,
otLinkMetricsValues *aLinkMetricsValues)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otLinkMetricsManagerGetMetricsValueByExtAddr)(aInstance, aExtAddress, aLinkMetricsValues);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkMetricsQuery)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsReportCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otLinkMetricsQuery)(aInstance, aDestination, aSeriesId, aLinkMetricsFlags, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkMetricsSendLinkProbe)(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
uint8_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkMetricsSendLinkProbe)(aInstance, aDestination, aSeriesId, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otLinkMetricsManagerSetEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkMetricsManagerSetEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,280 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Link Raw APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/link_raw.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otLinkRawGetPromiscuous)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkRawIsEnabled)(otInstance *aInstance);
extern int8_t OT_API_REAL_NAME(otLinkRawGetRssi)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkRawEnergyScan)(otInstance *aInstance,
uint8_t aScanChannel,
uint16_t aScanDuration,
otLinkRawEnergyScanDone aCallback);
extern otError OT_API_REAL_NAME(otLinkRawReceive)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkRawSetAlternateShortAddress)(otInstance *aInstance, otShortAddress aShortAddress);
extern otError OT_API_REAL_NAME(otLinkRawSetMacFrameCounter)(otInstance *aInstance, uint32_t aMacFrameCounter);
extern otError OT_API_REAL_NAME(otLinkRawSetMacFrameCounterIfLarger)(otInstance *aInstance, uint32_t aMacFrameCounter);
extern otError OT_API_REAL_NAME(otLinkRawSetMacKey)(otInstance *aInstance,
uint8_t aKeyIdMode,
uint8_t aKeyId,
const otMacKey *aPrevKey,
const otMacKey *aCurrKey,
const otMacKey *aNextKey);
extern otError OT_API_REAL_NAME(otLinkRawSetPromiscuous)(otInstance *aInstance, bool aEnable);
extern otError OT_API_REAL_NAME(otLinkRawSetReceiveDone)(otInstance *aInstance, otLinkRawReceiveDone aCallback);
extern otError OT_API_REAL_NAME(otLinkRawSetShortAddress)(otInstance *aInstance, uint16_t aShortAddress);
extern otError OT_API_REAL_NAME(otLinkRawSleep)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchAddExtEntry)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchAddShortEntry)(otInstance *aInstance, uint16_t aShortAddress);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchClearExtEntries)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchClearExtEntry)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchClearShortEntries)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchClearShortEntry)(otInstance *aInstance, uint16_t aShortAddress);
extern otError OT_API_REAL_NAME(otLinkRawSrcMatchEnable)(otInstance *aInstance, bool aEnable);
extern otError OT_API_REAL_NAME(otLinkRawTransmit)(otInstance *aInstance, otLinkRawTransmitDone aCallback);
extern otRadioCaps OT_API_REAL_NAME(otLinkRawGetCaps)(otInstance *aInstance);
extern otRadioFrame *OT_API_REAL_NAME(otLinkRawGetTransmitBuffer)(otInstance *aInstance);
extern uint64_t OT_API_REAL_NAME(otLinkRawGetRadioTime)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otLinkRawGetPromiscuous)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkRawGetPromiscuous)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkRawIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkRawIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otLinkRawGetRssi)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otLinkRawGetRssi)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawEnergyScan)(otInstance *aInstance,
uint8_t aScanChannel,
uint16_t aScanDuration,
otLinkRawEnergyScanDone aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawEnergyScan)(aInstance, aScanChannel, aScanDuration, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawReceive)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawReceive)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetAlternateShortAddress)(otInstance *aInstance, otShortAddress aShortAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetAlternateShortAddress)(aInstance, aShortAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetMacFrameCounter)(otInstance *aInstance, uint32_t aMacFrameCounter)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetMacFrameCounter)(aInstance, aMacFrameCounter);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetMacFrameCounterIfLarger)(otInstance *aInstance, uint32_t aMacFrameCounter)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetMacFrameCounterIfLarger)(aInstance, aMacFrameCounter);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetMacKey)(otInstance *aInstance,
uint8_t aKeyIdMode,
uint8_t aKeyId,
const otMacKey *aPrevKey,
const otMacKey *aCurrKey,
const otMacKey *aNextKey)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetMacKey)(aInstance, aKeyIdMode, aKeyId, aPrevKey, aCurrKey, aNextKey);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetPromiscuous)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetPromiscuous)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetReceiveDone)(otInstance *aInstance, otLinkRawReceiveDone aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetReceiveDone)(aInstance, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSetShortAddress)(otInstance *aInstance, uint16_t aShortAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSetShortAddress)(aInstance, aShortAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSleep)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSleep)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchAddExtEntry)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchAddExtEntry)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchAddShortEntry)(otInstance *aInstance, uint16_t aShortAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchAddShortEntry)(aInstance, aShortAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchClearExtEntries)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchClearExtEntries)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchClearExtEntry)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchClearExtEntry)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchClearShortEntries)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchClearShortEntries)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchClearShortEntry)(otInstance *aInstance, uint16_t aShortAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchClearShortEntry)(aInstance, aShortAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawSrcMatchEnable)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawSrcMatchEnable)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkRawTransmit)(otInstance *aInstance, otLinkRawTransmitDone aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkRawTransmit)(aInstance, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otRadioCaps OT_API_WRAPPER_NAME(otLinkRawGetCaps)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otRadioCaps ret = OT_API_REAL_NAME(otLinkRawGetCaps)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otRadioFrame *OT_API_WRAPPER_NAME(otLinkRawGetTransmitBuffer)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otRadioFrame *ret = OT_API_REAL_NAME(otLinkRawGetTransmitBuffer)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint64_t OT_API_WRAPPER_NAME(otLinkRawGetRadioTime)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint64_t ret = OT_API_REAL_NAME(otLinkRawGetRadioTime)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,698 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Link APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/link.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otLinkIsActiveScanInProgress)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsCslEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsCslSupported)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsEnergyScanInProgress)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsInTransmitState)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsPromiscuous)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsRadioFilterEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otLinkIsWakeupListenEnabled)(otInstance *aInstance);
extern const otExtAddress *OT_API_REAL_NAME(otLinkGetExtendedAddress)(otInstance *aInstance);
extern const otMacCounters *OT_API_REAL_NAME(otLinkGetCounters)(otInstance *aInstance);
extern const uint32_t *OT_API_REAL_NAME(otLinkGetTxDirectRetrySuccessHistogram)(otInstance *aInstance,
uint8_t *aNumberOfEntries);
extern const uint32_t *OT_API_REAL_NAME(otLinkGetTxIndirectRetrySuccessHistogram)(otInstance *aInstance,
uint8_t *aNumberOfEntries);
extern int8_t OT_API_REAL_NAME(otLinkConvertLinkQualityToRss)(otInstance *aInstance, uint8_t aLinkQuality);
extern otError OT_API_REAL_NAME(otLinkActiveScan)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleActiveScanResult aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otLinkEnergyScan)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleEnergyScanResult aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otLinkFilterAddAddress)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern otError OT_API_REAL_NAME(otLinkFilterAddRssIn)(otInstance *aInstance,
const otExtAddress *aExtAddress,
int8_t aRss);
extern otError OT_API_REAL_NAME(otLinkFilterGetNextAddress)(otInstance *aInstance,
otMacFilterIterator *aIterator,
otMacFilterEntry *aEntry);
extern otError OT_API_REAL_NAME(otLinkFilterGetNextRssIn)(otInstance *aInstance,
otMacFilterIterator *aIterator,
otMacFilterEntry *aEntry);
extern otError OT_API_REAL_NAME(otLinkGetRegion)(otInstance *aInstance, uint16_t *aRegionCode);
extern otError OT_API_REAL_NAME(otLinkSendDataRequest)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkSendEmptyData)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otLinkSetChannel)(otInstance *aInstance, uint8_t aChannel);
extern otError OT_API_REAL_NAME(otLinkSetCslChannel)(otInstance *aInstance, uint8_t aChannel);
extern otError OT_API_REAL_NAME(otLinkSetCslPeriod)(otInstance *aInstance, uint32_t aPeriod);
extern otError OT_API_REAL_NAME(otLinkSetCslTimeout)(otInstance *aInstance, uint32_t aTimeout);
extern otError OT_API_REAL_NAME(otLinkSetEnabled)(otInstance *aInstance, bool aEnable);
extern otError OT_API_REAL_NAME(otLinkSetExtendedAddress)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern otError OT_API_REAL_NAME(otLinkSetPanId)(otInstance *aInstance, otPanId aPanId);
extern otError OT_API_REAL_NAME(otLinkSetPollPeriod)(otInstance *aInstance, uint32_t aPollPeriod);
extern otError OT_API_REAL_NAME(otLinkSetPromiscuous)(otInstance *aInstance, bool aPromiscuous);
extern otError OT_API_REAL_NAME(otLinkSetRegion)(otInstance *aInstance, uint16_t aRegionCode);
extern otError OT_API_REAL_NAME(otLinkSetRxOnWhenIdle)(otInstance *aInstance, bool aRxOnWhenIdle);
extern otError OT_API_REAL_NAME(otLinkSetSupportedChannelMask)(otInstance *aInstance, uint32_t aChannelMask);
extern otError OT_API_REAL_NAME(otLinkSetWakeUpListenEnabled)(otInstance *aInstance, bool aEnable);
extern otError OT_API_REAL_NAME(otLinkSetWakeupChannel)(otInstance *aInstance, uint8_t aChannel);
extern otError OT_API_REAL_NAME(otLinkSetWakeupListenParameters)(otInstance *aInstance,
uint32_t aInterval,
uint32_t aDuration);
extern otMacFilterAddressMode OT_API_REAL_NAME(otLinkFilterGetAddressMode)(otInstance *aInstance);
extern otPanId OT_API_REAL_NAME(otLinkGetPanId)(otInstance *aInstance);
extern otShortAddress OT_API_REAL_NAME(otLinkGetAlternateShortAddress)(otInstance *aInstance);
extern otShortAddress OT_API_REAL_NAME(otLinkGetShortAddress)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otLinkGetCcaFailureRate)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otLinkGetCslPeriod)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otLinkGetCslTimeout)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otLinkGetFrameCounter)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otLinkGetPollPeriod)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otLinkGetSupportedChannelMask)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otLinkConvertRssToLinkQuality)(otInstance *aInstance, int8_t aRss);
extern uint8_t OT_API_REAL_NAME(otLinkGetChannel)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otLinkGetCslChannel)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otLinkGetMaxFrameRetriesDirect)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otLinkGetMaxFrameRetriesIndirect)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otLinkGetWakeupChannel)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkFilterClearAddresses)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkFilterClearAllRssIn)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkFilterClearDefaultRssIn)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkFilterRemoveAddress)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern void OT_API_REAL_NAME(otLinkFilterRemoveRssIn)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern void OT_API_REAL_NAME(otLinkFilterSetAddressMode)(otInstance *aInstance, otMacFilterAddressMode aMode);
extern void OT_API_REAL_NAME(otLinkFilterSetDefaultRssIn)(otInstance *aInstance, int8_t aRss);
extern void OT_API_REAL_NAME(otLinkGetFactoryAssignedIeeeEui64)(otInstance *aInstance, otExtAddress *aEui64);
extern void OT_API_REAL_NAME(otLinkGetWakeupListenParameters)(otInstance *aInstance,
uint32_t *aInterval,
uint32_t *aDuration);
extern void OT_API_REAL_NAME(otLinkResetCounters)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkResetTxRetrySuccessHistogram)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otLinkSetMaxFrameRetriesDirect)(otInstance *aInstance, uint8_t aMaxFrameRetriesDirect);
extern void OT_API_REAL_NAME(otLinkSetMaxFrameRetriesIndirect)(otInstance *aInstance, uint8_t aMaxFrameRetriesIndirect);
extern void OT_API_REAL_NAME(otLinkSetPcapCallback)(otInstance *aInstance,
otLinkPcapCallback aPcapCallback,
void *aCallbackContext);
extern void OT_API_REAL_NAME(otLinkSetRadioFilterEnabled)(otInstance *aInstance, bool aFilterEnabled);
bool OT_API_WRAPPER_NAME(otLinkIsActiveScanInProgress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsActiveScanInProgress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsCslEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsCslEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsCslSupported)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsCslSupported)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsEnergyScanInProgress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsEnergyScanInProgress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsInTransmitState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsInTransmitState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsPromiscuous)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsPromiscuous)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsRadioFilterEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsRadioFilterEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otLinkIsWakeupListenEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otLinkIsWakeupListenEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otExtAddress *OT_API_WRAPPER_NAME(otLinkGetExtendedAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otExtAddress *ret = OT_API_REAL_NAME(otLinkGetExtendedAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otMacCounters *OT_API_WRAPPER_NAME(otLinkGetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otMacCounters *ret = OT_API_REAL_NAME(otLinkGetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint32_t *OT_API_WRAPPER_NAME(otLinkGetTxDirectRetrySuccessHistogram)(otInstance *aInstance,
uint8_t *aNumberOfEntries)
{
sl_ot_rtos_acquire_stack_mutex();
const uint32_t *ret = OT_API_REAL_NAME(otLinkGetTxDirectRetrySuccessHistogram)(aInstance, aNumberOfEntries);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint32_t *OT_API_WRAPPER_NAME(otLinkGetTxIndirectRetrySuccessHistogram)(otInstance *aInstance,
uint8_t *aNumberOfEntries)
{
sl_ot_rtos_acquire_stack_mutex();
const uint32_t *ret = OT_API_REAL_NAME(otLinkGetTxIndirectRetrySuccessHistogram)(aInstance, aNumberOfEntries);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otLinkConvertLinkQualityToRss)(otInstance *aInstance, uint8_t aLinkQuality)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otLinkConvertLinkQualityToRss)(aInstance, aLinkQuality);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkActiveScan)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleActiveScanResult aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otLinkActiveScan)(aInstance, aScanChannels, aScanDuration, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkEnergyScan)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleEnergyScanResult aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otLinkEnergyScan)(aInstance, aScanChannels, aScanDuration, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkFilterAddAddress)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkFilterAddAddress)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkFilterAddRssIn)(otInstance *aInstance, const otExtAddress *aExtAddress, int8_t aRss)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkFilterAddRssIn)(aInstance, aExtAddress, aRss);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkFilterGetNextAddress)(otInstance *aInstance,
otMacFilterIterator *aIterator,
otMacFilterEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkFilterGetNextAddress)(aInstance, aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkFilterGetNextRssIn)(otInstance *aInstance,
otMacFilterIterator *aIterator,
otMacFilterEntry *aEntry)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkFilterGetNextRssIn)(aInstance, aIterator, aEntry);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkGetRegion)(otInstance *aInstance, uint16_t *aRegionCode)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkGetRegion)(aInstance, aRegionCode);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSendDataRequest)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSendDataRequest)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSendEmptyData)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSendEmptyData)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetChannel)(otInstance *aInstance, uint8_t aChannel)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetChannel)(aInstance, aChannel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetCslChannel)(otInstance *aInstance, uint8_t aChannel)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetCslChannel)(aInstance, aChannel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetCslPeriod)(otInstance *aInstance, uint32_t aPeriod)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetCslPeriod)(aInstance, aPeriod);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetCslTimeout)(otInstance *aInstance, uint32_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetCslTimeout)(aInstance, aTimeout);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetExtendedAddress)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetExtendedAddress)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetPanId)(otInstance *aInstance, otPanId aPanId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetPanId)(aInstance, aPanId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetPollPeriod)(otInstance *aInstance, uint32_t aPollPeriod)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetPollPeriod)(aInstance, aPollPeriod);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetPromiscuous)(otInstance *aInstance, bool aPromiscuous)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetPromiscuous)(aInstance, aPromiscuous);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetRegion)(otInstance *aInstance, uint16_t aRegionCode)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetRegion)(aInstance, aRegionCode);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetRxOnWhenIdle)(otInstance *aInstance, bool aRxOnWhenIdle)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetRxOnWhenIdle)(aInstance, aRxOnWhenIdle);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetSupportedChannelMask)(otInstance *aInstance, uint32_t aChannelMask)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetSupportedChannelMask)(aInstance, aChannelMask);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetWakeUpListenEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetWakeUpListenEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetWakeupChannel)(otInstance *aInstance, uint8_t aChannel)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetWakeupChannel)(aInstance, aChannel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otLinkSetWakeupListenParameters)(otInstance *aInstance,
uint32_t aInterval,
uint32_t aDuration)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLinkSetWakeupListenParameters)(aInstance, aInterval, aDuration);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMacFilterAddressMode OT_API_WRAPPER_NAME(otLinkFilterGetAddressMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otMacFilterAddressMode ret = OT_API_REAL_NAME(otLinkFilterGetAddressMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otPanId OT_API_WRAPPER_NAME(otLinkGetPanId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otPanId ret = OT_API_REAL_NAME(otLinkGetPanId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otShortAddress OT_API_WRAPPER_NAME(otLinkGetAlternateShortAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otShortAddress ret = OT_API_REAL_NAME(otLinkGetAlternateShortAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otShortAddress OT_API_WRAPPER_NAME(otLinkGetShortAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otShortAddress ret = OT_API_REAL_NAME(otLinkGetShortAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otLinkGetCcaFailureRate)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otLinkGetCcaFailureRate)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otLinkGetCslPeriod)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otLinkGetCslPeriod)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otLinkGetCslTimeout)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otLinkGetCslTimeout)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otLinkGetFrameCounter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otLinkGetFrameCounter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otLinkGetPollPeriod)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otLinkGetPollPeriod)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otLinkGetSupportedChannelMask)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otLinkGetSupportedChannelMask)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkConvertRssToLinkQuality)(otInstance *aInstance, int8_t aRss)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkConvertRssToLinkQuality)(aInstance, aRss);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkGetChannel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkGetChannel)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkGetCslChannel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkGetCslChannel)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkGetMaxFrameRetriesDirect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkGetMaxFrameRetriesDirect)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkGetMaxFrameRetriesIndirect)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkGetMaxFrameRetriesIndirect)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otLinkGetWakeupChannel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otLinkGetWakeupChannel)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otLinkFilterClearAddresses)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterClearAddresses)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterClearAllRssIn)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterClearAllRssIn)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterClearDefaultRssIn)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterClearDefaultRssIn)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterRemoveAddress)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterRemoveAddress)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterRemoveRssIn)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterRemoveRssIn)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterSetAddressMode)(otInstance *aInstance, otMacFilterAddressMode aMode)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterSetAddressMode)(aInstance, aMode);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkFilterSetDefaultRssIn)(otInstance *aInstance, int8_t aRss)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkFilterSetDefaultRssIn)(aInstance, aRss);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkGetFactoryAssignedIeeeEui64)(otInstance *aInstance, otExtAddress *aEui64)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkGetFactoryAssignedIeeeEui64)(aInstance, aEui64);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkGetWakeupListenParameters)(otInstance *aInstance,
uint32_t *aInterval,
uint32_t *aDuration)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkGetWakeupListenParameters)(aInstance, aInterval, aDuration);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkResetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkResetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkResetTxRetrySuccessHistogram)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkResetTxRetrySuccessHistogram)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkSetMaxFrameRetriesDirect)(otInstance *aInstance, uint8_t aMaxFrameRetriesDirect)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkSetMaxFrameRetriesDirect)(aInstance, aMaxFrameRetriesDirect);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkSetMaxFrameRetriesIndirect)(otInstance *aInstance, uint8_t aMaxFrameRetriesIndirect)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkSetMaxFrameRetriesIndirect)(aInstance, aMaxFrameRetriesIndirect);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkSetPcapCallback)(otInstance *aInstance,
otLinkPcapCallback aPcapCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkSetPcapCallback)(aInstance, aPcapCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otLinkSetRadioFilterEnabled)(otInstance *aInstance, bool aFilterEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otLinkSetRadioFilterEnabled)(aInstance, aFilterEnabled);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Logging APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/logging.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otLoggingSetLevel)(otLogLevel aLogLevel);
extern otLogLevel OT_API_REAL_NAME(otLoggingGetLevel)(void);
otError OT_API_WRAPPER_NAME(otLoggingSetLevel)(otLogLevel aLogLevel)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otLoggingSetLevel)(aLogLevel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otLogLevel OT_API_WRAPPER_NAME(otLoggingGetLevel)(void)
{
sl_ot_rtos_acquire_stack_mutex();
otLogLevel ret = OT_API_REAL_NAME(otLoggingGetLevel)();
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,396 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Mdns APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/mdns.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otMdnsIsEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otMdnsIsQuestionUnicastAllowed)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otMdnsGetNextBrowser)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsBrowser *aBrowser,
otMdnsCacheInfo *aInfo);
extern otError OT_API_REAL_NAME(otMdnsGetNextHost)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsHost *aHost,
otMdnsEntryState *aState);
extern otError OT_API_REAL_NAME(otMdnsGetNextIp4AddressResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsAddressResolver *aResolver,
otMdnsCacheInfo *aInfo);
extern otError OT_API_REAL_NAME(otMdnsGetNextIp6AddressResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsAddressResolver *aResolver,
otMdnsCacheInfo *aInfo);
extern otError OT_API_REAL_NAME(otMdnsGetNextKey)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsKey *aKey,
otMdnsEntryState *aState);
extern otError OT_API_REAL_NAME(otMdnsGetNextService)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsService *aService,
otMdnsEntryState *aState);
extern otError OT_API_REAL_NAME(otMdnsGetNextSrvResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsSrvResolver *aResolver,
otMdnsCacheInfo *aInfo);
extern otError OT_API_REAL_NAME(otMdnsGetNextTxtResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsTxtResolver *aResolver,
otMdnsCacheInfo *aInfo);
extern otError OT_API_REAL_NAME(otMdnsRegisterHost)(otInstance *aInstance,
const otMdnsHost *aHost,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback);
extern otError OT_API_REAL_NAME(otMdnsRegisterKey)(otInstance *aInstance,
const otMdnsKey *aKey,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback);
extern otError OT_API_REAL_NAME(otMdnsRegisterService)(otInstance *aInstance,
const otMdnsService *aService,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback);
extern otError OT_API_REAL_NAME(otMdnsSetEnabled)(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex);
extern otError OT_API_REAL_NAME(otMdnsStartBrowser)(otInstance *aInstance, const otMdnsBrowser *aBrowser);
extern otError OT_API_REAL_NAME(otMdnsStartIp4AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStartIp6AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStartSrvResolver)(otInstance *aInstance, const otMdnsSrvResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStartTxtResolver)(otInstance *aInstance, const otMdnsTxtResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStopBrowser)(otInstance *aInstance, const otMdnsBrowser *aBroswer);
extern otError OT_API_REAL_NAME(otMdnsStopIp4AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStopIp6AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStopSrvResolver)(otInstance *aInstance, const otMdnsSrvResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsStopTxtResolver)(otInstance *aInstance, const otMdnsTxtResolver *aResolver);
extern otError OT_API_REAL_NAME(otMdnsUnregisterHost)(otInstance *aInstance, const otMdnsHost *aHost);
extern otError OT_API_REAL_NAME(otMdnsUnregisterKey)(otInstance *aInstance, const otMdnsKey *aKey);
extern otError OT_API_REAL_NAME(otMdnsUnregisterService)(otInstance *aInstance, const otMdnsService *aService);
extern otMdnsIterator *OT_API_REAL_NAME(otMdnsAllocateIterator)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otMdnsFreeIterator)(otInstance *aInstance, otMdnsIterator *aIterator);
extern void OT_API_REAL_NAME(otMdnsSetConflictCallback)(otInstance *aInstance, otMdnsConflictCallback aCallback);
extern void OT_API_REAL_NAME(otMdnsSetQuestionUnicastAllowed)(otInstance *aInstance, bool aAllow);
bool OT_API_WRAPPER_NAME(otMdnsIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otMdnsIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otMdnsIsQuestionUnicastAllowed)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otMdnsIsQuestionUnicastAllowed)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextBrowser)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsBrowser *aBrowser,
otMdnsCacheInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextBrowser)(aInstance, aIterator, aBrowser, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextHost)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsHost *aHost,
otMdnsEntryState *aState)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextHost)(aInstance, aIterator, aHost, aState);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextIp4AddressResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsAddressResolver *aResolver,
otMdnsCacheInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextIp4AddressResolver)(aInstance, aIterator, aResolver, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextIp6AddressResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsAddressResolver *aResolver,
otMdnsCacheInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextIp6AddressResolver)(aInstance, aIterator, aResolver, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextKey)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsKey *aKey,
otMdnsEntryState *aState)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextKey)(aInstance, aIterator, aKey, aState);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextService)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsService *aService,
otMdnsEntryState *aState)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextService)(aInstance, aIterator, aService, aState);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextSrvResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsSrvResolver *aResolver,
otMdnsCacheInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextSrvResolver)(aInstance, aIterator, aResolver, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsGetNextTxtResolver)(otInstance *aInstance,
otMdnsIterator *aIterator,
otMdnsTxtResolver *aResolver,
otMdnsCacheInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsGetNextTxtResolver)(aInstance, aIterator, aResolver, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsRegisterHost)(otInstance *aInstance,
const otMdnsHost *aHost,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsRegisterHost)(aInstance, aHost, aRequestId, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsRegisterKey)(otInstance *aInstance,
const otMdnsKey *aKey,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsRegisterKey)(aInstance, aKey, aRequestId, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsRegisterService)(otInstance *aInstance,
const otMdnsService *aService,
otMdnsRequestId aRequestId,
otMdnsRegisterCallback aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsRegisterService)(aInstance, aService, aRequestId, aCallback);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsSetEnabled)(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsSetEnabled)(aInstance, aEnable, aInfraIfIndex);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStartBrowser)(otInstance *aInstance, const otMdnsBrowser *aBrowser)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStartBrowser)(aInstance, aBrowser);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStartIp4AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStartIp4AddressResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStartIp6AddressResolver)(otInstance *aInstance,
const otMdnsAddressResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStartIp6AddressResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStartSrvResolver)(otInstance *aInstance, const otMdnsSrvResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStartSrvResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStartTxtResolver)(otInstance *aInstance, const otMdnsTxtResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStartTxtResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStopBrowser)(otInstance *aInstance, const otMdnsBrowser *aBroswer)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStopBrowser)(aInstance, aBroswer);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStopIp4AddressResolver)(otInstance *aInstance, const otMdnsAddressResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStopIp4AddressResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStopIp6AddressResolver)(otInstance *aInstance, const otMdnsAddressResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStopIp6AddressResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStopSrvResolver)(otInstance *aInstance, const otMdnsSrvResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStopSrvResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsStopTxtResolver)(otInstance *aInstance, const otMdnsTxtResolver *aResolver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsStopTxtResolver)(aInstance, aResolver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsUnregisterHost)(otInstance *aInstance, const otMdnsHost *aHost)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsUnregisterHost)(aInstance, aHost);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsUnregisterKey)(otInstance *aInstance, const otMdnsKey *aKey)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsUnregisterKey)(aInstance, aKey);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMdnsUnregisterService)(otInstance *aInstance, const otMdnsService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMdnsUnregisterService)(aInstance, aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMdnsIterator *OT_API_WRAPPER_NAME(otMdnsAllocateIterator)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otMdnsIterator *ret = OT_API_REAL_NAME(otMdnsAllocateIterator)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otMdnsFreeIterator)(otInstance *aInstance, otMdnsIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMdnsFreeIterator)(aInstance, aIterator);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMdnsSetConflictCallback)(otInstance *aInstance, otMdnsConflictCallback aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMdnsSetConflictCallback)(aInstance, aCallback);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMdnsSetQuestionUnicastAllowed)(otInstance *aInstance, bool aAllow)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMdnsSetQuestionUnicastAllowed)(aInstance, aAllow);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,139 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Mesh Diag APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/mesh_diag.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otMeshDiagDiscoverTopology)(otInstance *aInstance,
const otMeshDiagDiscoverConfig *aConfig,
otMeshDiagDiscoverCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otMeshDiagGetNextChildInfo)(otMeshDiagChildIterator *aIterator,
otMeshDiagChildInfo *aChildInfo);
extern otError OT_API_REAL_NAME(otMeshDiagGetNextIp6Address)(otMeshDiagIp6AddrIterator *aIterator,
otIp6Address *aIp6Address);
extern otError OT_API_REAL_NAME(otMeshDiagQueryChildTable)(otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagQueryChildTableCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otMeshDiagQueryChildrenIp6Addrs)(otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagChildIp6AddrsCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otMeshDiagQueryRouterNeighborTable)(
otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagQueryRouterNeighborTableCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otMeshDiagCancel)(otInstance *aInstance);
otError OT_API_WRAPPER_NAME(otMeshDiagDiscoverTopology)(otInstance *aInstance,
const otMeshDiagDiscoverConfig *aConfig,
otMeshDiagDiscoverCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagDiscoverTopology)(aInstance, aConfig, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMeshDiagGetNextChildInfo)(otMeshDiagChildIterator *aIterator,
otMeshDiagChildInfo *aChildInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagGetNextChildInfo)(aIterator, aChildInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMeshDiagGetNextIp6Address)(otMeshDiagIp6AddrIterator *aIterator,
otIp6Address *aIp6Address)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagGetNextIp6Address)(aIterator, aIp6Address);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMeshDiagQueryChildTable)(otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagQueryChildTableCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagQueryChildTable)(aInstance, aRloc16, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMeshDiagQueryChildrenIp6Addrs)(otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagChildIp6AddrsCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagQueryChildrenIp6Addrs)(aInstance, aRloc16, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMeshDiagQueryRouterNeighborTable)(otInstance *aInstance,
uint16_t aRloc16,
otMeshDiagQueryRouterNeighborTableCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMeshDiagQueryRouterNeighborTable)(aInstance, aRloc16, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otMeshDiagCancel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMeshDiagCancel)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,273 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Message APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/message.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otMessageIsLinkSecurityEnabled)(const otMessage *aMessage);
extern bool OT_API_REAL_NAME(otMessageIsLoopbackToHostAllowed)(const otMessage *aMessage);
extern bool OT_API_REAL_NAME(otMessageIsMulticastLoopEnabled)(otMessage *aMessage);
extern int OT_API_REAL_NAME(otMessageWrite)(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength);
extern int8_t OT_API_REAL_NAME(otMessageGetRss)(const otMessage *aMessage);
extern otError OT_API_REAL_NAME(otMessageAppend)(otMessage *aMessage, const void *aBuf, uint16_t aLength);
extern otError OT_API_REAL_NAME(otMessageGetThreadLinkInfo)(const otMessage *aMessage, otThreadLinkInfo *aLinkInfo);
extern otError OT_API_REAL_NAME(otMessageSetLength)(otMessage *aMessage, uint16_t aLength);
extern otMessage *OT_API_REAL_NAME(otMessageQueueGetHead)(otMessageQueue *aQueue);
extern otMessage *OT_API_REAL_NAME(otMessageQueueGetNext)(otMessageQueue *aQueue, const otMessage *aMessage);
extern otMessageOrigin OT_API_REAL_NAME(otMessageGetOrigin)(const otMessage *aMessage);
extern uint16_t OT_API_REAL_NAME(otMessageGetLength)(const otMessage *aMessage);
extern uint16_t OT_API_REAL_NAME(otMessageGetOffset)(const otMessage *aMessage);
extern uint16_t OT_API_REAL_NAME(otMessageRead)(const otMessage *aMessage,
uint16_t aOffset,
void *aBuf,
uint16_t aLength);
extern void OT_API_REAL_NAME(otMessageFree)(otMessage *aMessage);
extern void OT_API_REAL_NAME(otMessageGetBufferInfo)(otInstance *aInstance, otBufferInfo *aBufferInfo);
extern void OT_API_REAL_NAME(otMessageQueueDequeue)(otMessageQueue *aQueue, otMessage *aMessage);
extern void OT_API_REAL_NAME(otMessageQueueEnqueue)(otMessageQueue *aQueue, otMessage *aMessage);
extern void OT_API_REAL_NAME(otMessageQueueEnqueueAtHead)(otMessageQueue *aQueue, otMessage *aMessage);
extern void OT_API_REAL_NAME(otMessageQueueInit)(otMessageQueue *aQueue);
extern void OT_API_REAL_NAME(otMessageResetBufferInfo)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otMessageSetDirectTransmission)(otMessage *aMessage, bool aEnabled);
extern void OT_API_REAL_NAME(otMessageSetLoopbackToHostAllowed)(otMessage *aMessage, bool aAllowLoopbackToHost);
extern void OT_API_REAL_NAME(otMessageSetMulticastLoopEnabled)(otMessage *aMessage, bool aEnabled);
extern void OT_API_REAL_NAME(otMessageSetOffset)(otMessage *aMessage, uint16_t aOffset);
extern void OT_API_REAL_NAME(otMessageSetOrigin)(otMessage *aMessage, otMessageOrigin aOrigin);
bool OT_API_WRAPPER_NAME(otMessageIsLinkSecurityEnabled)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otMessageIsLinkSecurityEnabled)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otMessageIsLoopbackToHostAllowed)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otMessageIsLoopbackToHostAllowed)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otMessageIsMulticastLoopEnabled)(otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otMessageIsMulticastLoopEnabled)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int OT_API_WRAPPER_NAME(otMessageWrite)(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
int ret = OT_API_REAL_NAME(otMessageWrite)(aMessage, aOffset, aBuf, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otMessageGetRss)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otMessageGetRss)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMessageAppend)(otMessage *aMessage, const void *aBuf, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMessageAppend)(aMessage, aBuf, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMessageGetThreadLinkInfo)(const otMessage *aMessage, otThreadLinkInfo *aLinkInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMessageGetThreadLinkInfo)(aMessage, aLinkInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otMessageSetLength)(otMessage *aMessage, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMessageSetLength)(aMessage, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otMessageQueueGetHead)(otMessageQueue *aQueue)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otMessageQueueGetHead)(aQueue);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otMessageQueueGetNext)(otMessageQueue *aQueue, const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otMessageQueueGetNext)(aQueue, aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessageOrigin OT_API_WRAPPER_NAME(otMessageGetOrigin)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otMessageOrigin ret = OT_API_REAL_NAME(otMessageGetOrigin)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otMessageGetLength)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otMessageGetLength)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otMessageGetOffset)(const otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otMessageGetOffset)(aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otMessageRead)(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otMessageRead)(aMessage, aOffset, aBuf, aLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otMessageFree)(otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageFree)(aMessage);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageGetBufferInfo)(otInstance *aInstance, otBufferInfo *aBufferInfo)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageGetBufferInfo)(aInstance, aBufferInfo);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageQueueDequeue)(otMessageQueue *aQueue, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageQueueDequeue)(aQueue, aMessage);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageQueueEnqueue)(otMessageQueue *aQueue, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageQueueEnqueue)(aQueue, aMessage);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageQueueEnqueueAtHead)(otMessageQueue *aQueue, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageQueueEnqueueAtHead)(aQueue, aMessage);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageQueueInit)(otMessageQueue *aQueue)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageQueueInit)(aQueue);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageResetBufferInfo)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageResetBufferInfo)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageSetDirectTransmission)(otMessage *aMessage, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageSetDirectTransmission)(aMessage, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageSetLoopbackToHostAllowed)(otMessage *aMessage, bool aAllowLoopbackToHost)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageSetLoopbackToHostAllowed)(aMessage, aAllowLoopbackToHost);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageSetMulticastLoopEnabled)(otMessage *aMessage, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageSetMulticastLoopEnabled)(aMessage, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageSetOffset)(otMessage *aMessage, uint16_t aOffset)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageSetOffset)(aMessage, aOffset);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otMessageSetOrigin)(otMessage *aMessage, otMessageOrigin aOrigin)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otMessageSetOrigin)(aMessage, aOrigin);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,61 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Multi Radio APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/multi_radio.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otMultiRadioGetNeighborInfo)(otInstance *aInstance,
const otExtAddress *aExtAddress,
otMultiRadioNeighborInfo *aNeighborInfo);
otError OT_API_WRAPPER_NAME(otMultiRadioGetNeighborInfo)(otInstance *aInstance,
const otExtAddress *aExtAddress,
otMultiRadioNeighborInfo *aNeighborInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otMultiRadioGetNeighborInfo)(aInstance, aExtAddress, aNeighborInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,255 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Nat64 APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/nat64.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otIp4IsAddressEqual)(const otIp4Address *aFirst, const otIp4Address *aSecond);
extern otError OT_API_REAL_NAME(otIp4AddressFromString)(const char *aString, otIp4Address *aAddress);
extern otError OT_API_REAL_NAME(otIp4CidrFromString)(const char *aString, otIp4Cidr *aCidr);
extern otError OT_API_REAL_NAME(otIp4FromIp4MappedIp6Address)(const otIp6Address *aIp6Address,
otIp4Address *aIp4Address);
extern otError OT_API_REAL_NAME(otNat64GetCidr)(otInstance *aInstance, otIp4Cidr *aCidr);
extern otError OT_API_REAL_NAME(otNat64GetNextAddressMapping)(otInstance *aInstance,
otNat64AddressMappingIterator *aIterator,
otNat64AddressMapping *aMapping);
extern otError OT_API_REAL_NAME(otNat64Send)(otInstance *aInstance, otMessage *aMessage);
extern otError OT_API_REAL_NAME(otNat64SetIp4Cidr)(otInstance *aInstance, const otIp4Cidr *aCidr);
extern otError OT_API_REAL_NAME(otNat64SynthesizeIp6Address)(otInstance *aInstance,
const otIp4Address *aIp4Address,
otIp6Address *aIp6Address);
extern otMessage *OT_API_REAL_NAME(otIp4NewMessage)(otInstance *aInstance, const otMessageSettings *aSettings);
extern otNat64State OT_API_REAL_NAME(otNat64GetPrefixManagerState)(otInstance *aInstance);
extern otNat64State OT_API_REAL_NAME(otNat64GetTranslatorState)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otIp4AddressToString)(const otIp4Address *aAddress, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otIp4CidrToString)(const otIp4Cidr *aCidr, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otIp4ExtractFromIp6Address)(uint8_t aPrefixLength,
const otIp6Address *aIp6Address,
otIp4Address *aIp4Address);
extern void OT_API_REAL_NAME(otIp4ToIp4MappedIp6Address)(const otIp4Address *aIp4Address, otIp6Address *aIp6Address);
extern void OT_API_REAL_NAME(otNat64ClearIp4Cidr)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otNat64GetCounters)(otInstance *aInstance, otNat64ProtocolCounters *aCounters);
extern void OT_API_REAL_NAME(otNat64GetErrorCounters)(otInstance *aInstance, otNat64ErrorCounters *aCounters);
extern void OT_API_REAL_NAME(otNat64InitAddressMappingIterator)(otInstance *aInstance,
otNat64AddressMappingIterator *aIterator);
extern void OT_API_REAL_NAME(otNat64SetEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otNat64SetReceiveIp4Callback)(otInstance *aInstance,
otNat64ReceiveIp4Callback aCallback,
void *aContext);
bool OT_API_WRAPPER_NAME(otIp4IsAddressEqual)(const otIp4Address *aFirst, const otIp4Address *aSecond)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otIp4IsAddressEqual)(aFirst, aSecond);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp4AddressFromString)(const char *aString, otIp4Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp4AddressFromString)(aString, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp4CidrFromString)(const char *aString, otIp4Cidr *aCidr)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp4CidrFromString)(aString, aCidr);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otIp4FromIp4MappedIp6Address)(const otIp6Address *aIp6Address, otIp4Address *aIp4Address)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otIp4FromIp4MappedIp6Address)(aIp6Address, aIp4Address);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNat64GetCidr)(otInstance *aInstance, otIp4Cidr *aCidr)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNat64GetCidr)(aInstance, aCidr);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNat64GetNextAddressMapping)(otInstance *aInstance,
otNat64AddressMappingIterator *aIterator,
otNat64AddressMapping *aMapping)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNat64GetNextAddressMapping)(aInstance, aIterator, aMapping);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNat64Send)(otInstance *aInstance, otMessage *aMessage)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNat64Send)(aInstance, aMessage);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNat64SetIp4Cidr)(otInstance *aInstance, const otIp4Cidr *aCidr)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNat64SetIp4Cidr)(aInstance, aCidr);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNat64SynthesizeIp6Address)(otInstance *aInstance,
const otIp4Address *aIp4Address,
otIp6Address *aIp6Address)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNat64SynthesizeIp6Address)(aInstance, aIp4Address, aIp6Address);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otIp4NewMessage)(otInstance *aInstance, const otMessageSettings *aSettings)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otIp4NewMessage)(aInstance, aSettings);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otNat64State OT_API_WRAPPER_NAME(otNat64GetPrefixManagerState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otNat64State ret = OT_API_REAL_NAME(otNat64GetPrefixManagerState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otNat64State OT_API_WRAPPER_NAME(otNat64GetTranslatorState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otNat64State ret = OT_API_REAL_NAME(otNat64GetTranslatorState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otIp4AddressToString)(const otIp4Address *aAddress, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp4AddressToString)(aAddress, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp4CidrToString)(const otIp4Cidr *aCidr, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp4CidrToString)(aCidr, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp4ExtractFromIp6Address)(uint8_t aPrefixLength,
const otIp6Address *aIp6Address,
otIp4Address *aIp4Address)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp4ExtractFromIp6Address)(aPrefixLength, aIp6Address, aIp4Address);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otIp4ToIp4MappedIp6Address)(const otIp4Address *aIp4Address, otIp6Address *aIp6Address)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otIp4ToIp4MappedIp6Address)(aIp4Address, aIp6Address);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64ClearIp4Cidr)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64ClearIp4Cidr)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64GetCounters)(otInstance *aInstance, otNat64ProtocolCounters *aCounters)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64GetCounters)(aInstance, aCounters);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64GetErrorCounters)(otInstance *aInstance, otNat64ErrorCounters *aCounters)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64GetErrorCounters)(aInstance, aCounters);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64InitAddressMappingIterator)(otInstance *aInstance,
otNat64AddressMappingIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64InitAddressMappingIterator)(aInstance, aIterator);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64SetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64SetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNat64SetReceiveIp4Callback)(otInstance *aInstance,
otNat64ReceiveIp4Callback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNat64SetReceiveIp4Callback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,125 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Ncp APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/ncp.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otNcpStreamWrite)(int aStreamId, const uint8_t *aDataPtr, int aDataLen);
extern void OT_API_REAL_NAME(otNcpHdlcInit)(otInstance *aInstance, otNcpHdlcSendCallback aSendCallback);
extern void OT_API_REAL_NAME(otNcpHdlcInitMulti)(otInstance **aInstance,
uint8_t aCount,
otNcpHdlcSendCallback aSendCallback);
extern void OT_API_REAL_NAME(otNcpHdlcReceive)(const uint8_t *aBuf, uint16_t aBufLength);
extern void OT_API_REAL_NAME(otNcpHdlcSendDone)(void);
extern void OT_API_REAL_NAME(otNcpPlatLogv)(otLogLevel aLogLevel,
otLogRegion aLogRegion,
const char *aFormat,
va_list aArgs);
extern void OT_API_REAL_NAME(otNcpRegisterPeekPokeDelegates)(otNcpDelegateAllowPeekPoke aAllowPeekDelegate,
otNcpDelegateAllowPeekPoke aAllowPokeDelegate);
extern void OT_API_REAL_NAME(otNcpSpiInit)(otInstance *aInstance);
otError OT_API_WRAPPER_NAME(otNcpStreamWrite)(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNcpStreamWrite)(aStreamId, aDataPtr, aDataLen);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otNcpHdlcInit)(otInstance *aInstance, otNcpHdlcSendCallback aSendCallback)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpHdlcInit)(aInstance, aSendCallback);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpHdlcInitMulti)(otInstance **aInstance,
uint8_t aCount,
otNcpHdlcSendCallback aSendCallback)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpHdlcInitMulti)(aInstance, aCount, aSendCallback);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpHdlcReceive)(const uint8_t *aBuf, uint16_t aBufLength)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpHdlcReceive)(aBuf, aBufLength);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpHdlcSendDone)(void)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpHdlcSendDone)();
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpPlatLogv)(otLogLevel aLogLevel,
otLogRegion aLogRegion,
const char *aFormat,
va_list aArgs)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpPlatLogv)(aLogLevel, aLogRegion, aFormat, aArgs);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpRegisterPeekPokeDelegates)(otNcpDelegateAllowPeekPoke aAllowPeekDelegate,
otNcpDelegateAllowPeekPoke aAllowPokeDelegate)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpRegisterPeekPokeDelegates)(aAllowPeekDelegate, aAllowPokeDelegate);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNcpSpiInit)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNcpSpiInit)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,169 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Netdata Publisher APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/netdata_publisher.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otNetDataIsDnsSrpServiceAdded)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otNetDataIsPrefixAdded)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otNetDataPublishExternalRoute)(otInstance *aInstance,
const otExternalRouteConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataPublishOnMeshPrefix)(otInstance *aInstance,
const otBorderRouterConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataReplacePublishedExternalRoute)(otInstance *aInstance,
const otIp6Prefix *aPrefix,
const otExternalRouteConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataUnpublishPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern void OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceAnycast)(otInstance *aInstance, uint8_t aSequenceNUmber);
extern void OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceUnicast)(otInstance *aInstance,
const otIp6Address *aAddress,
uint16_t aPort);
extern void OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceUnicastMeshLocalEid)(otInstance *aInstance, uint16_t aPort);
extern void OT_API_REAL_NAME(otNetDataSetDnsSrpServicePublisherCallback)(
otInstance *aInstance,
otNetDataDnsSrpServicePublisherCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otNetDataSetPrefixPublisherCallback)(otInstance *aInstance,
otNetDataPrefixPublisherCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otNetDataUnpublishDnsSrpService)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otNetDataIsDnsSrpServiceAdded)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otNetDataIsDnsSrpServiceAdded)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otNetDataIsPrefixAdded)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otNetDataIsPrefixAdded)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataPublishExternalRoute)(otInstance *aInstance, const otExternalRouteConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataPublishExternalRoute)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataPublishOnMeshPrefix)(otInstance *aInstance, const otBorderRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataPublishOnMeshPrefix)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataReplacePublishedExternalRoute)(otInstance *aInstance,
const otIp6Prefix *aPrefix,
const otExternalRouteConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataReplacePublishedExternalRoute)(aInstance, aPrefix, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataUnpublishPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataUnpublishPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otNetDataPublishDnsSrpServiceAnycast)(otInstance *aInstance, uint8_t aSequenceNUmber)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceAnycast)(aInstance, aSequenceNUmber);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataPublishDnsSrpServiceUnicast)(otInstance *aInstance,
const otIp6Address *aAddress,
uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceUnicast)(aInstance, aAddress, aPort);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataPublishDnsSrpServiceUnicastMeshLocalEid)(otInstance *aInstance, uint16_t aPort)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataPublishDnsSrpServiceUnicastMeshLocalEid)(aInstance, aPort);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataSetDnsSrpServicePublisherCallback)(otInstance *aInstance,
otNetDataDnsSrpServicePublisherCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataSetDnsSrpServicePublisherCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataSetPrefixPublisherCallback)(otInstance *aInstance,
otNetDataPrefixPublisherCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataSetPrefixPublisherCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataUnpublishDnsSrpService)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataUnpublishDnsSrpService)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,193 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Netdata APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/netdata.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otNetDataContainsOmrPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix);
extern otError OT_API_REAL_NAME(otNetDataGet)(otInstance *aInstance,
bool aStable,
uint8_t *aData,
uint8_t *aDataLength);
extern otError OT_API_REAL_NAME(otNetDataGetNextLowpanContextInfo)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otLowpanContextInfo *aContextInfo);
extern otError OT_API_REAL_NAME(otNetDataGetNextOnMeshPrefix)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otBorderRouterConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataGetNextRoute)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otExternalRouteConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataGetNextService)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otServiceConfig *aConfig);
extern otError OT_API_REAL_NAME(otNetDataSteeringDataCheckJoiner)(otInstance *aInstance, const otExtAddress *aEui64);
extern otError OT_API_REAL_NAME(
otNetDataSteeringDataCheckJoinerWithDiscerner)(otInstance *aInstance, const struct otJoinerDiscerner *aDiscerner);
extern uint8_t OT_API_REAL_NAME(otNetDataGetLength)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otNetDataGetMaxLength)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otNetDataGetStableVersion)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otNetDataGetVersion)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otNetDataGetCommissioningDataset)(otInstance *aInstance, otCommissioningDataset *aDataset);
extern void OT_API_REAL_NAME(otNetDataResetMaxLength)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otNetDataContainsOmrPrefix)(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otNetDataContainsOmrPrefix)(aInstance, aPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataGet)(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataGet)(aInstance, aStable, aData, aDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataGetNextLowpanContextInfo)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otLowpanContextInfo *aContextInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataGetNextLowpanContextInfo)(aInstance, aIterator, aContextInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataGetNextOnMeshPrefix)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otBorderRouterConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataGetNextOnMeshPrefix)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataGetNextRoute)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otExternalRouteConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataGetNextRoute)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataGetNextService)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otServiceConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataGetNextService)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataSteeringDataCheckJoiner)(otInstance *aInstance, const otExtAddress *aEui64)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataSteeringDataCheckJoiner)(aInstance, aEui64);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetDataSteeringDataCheckJoinerWithDiscerner)(otInstance *aInstance,
const struct otJoinerDiscerner *aDiscerner)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetDataSteeringDataCheckJoinerWithDiscerner)(aInstance, aDiscerner);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otNetDataGetLength)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otNetDataGetLength)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otNetDataGetMaxLength)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otNetDataGetMaxLength)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otNetDataGetStableVersion)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otNetDataGetStableVersion)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otNetDataGetVersion)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otNetDataGetVersion)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otNetDataGetCommissioningDataset)(otInstance *aInstance, otCommissioningDataset *aDataset)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataGetCommissioningDataset)(aInstance, aDataset);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otNetDataResetMaxLength)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetDataResetMaxLength)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,168 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Netdiag APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/netdiag.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const char *OT_API_REAL_NAME(otThreadGetVendorAppUrl)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otThreadGetVendorModel)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otThreadGetVendorName)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otThreadGetVendorSwVersion)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadGetNextDiagnosticTlv)(const otMessage *aMessage,
otNetworkDiagIterator *aIterator,
otNetworkDiagTlv *aNetworkDiagTlv);
extern otError OT_API_REAL_NAME(otThreadSendDiagnosticGet)(otInstance *aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount,
otReceiveDiagnosticGetCallback aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otThreadSendDiagnosticReset)(otInstance *aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount);
extern otError OT_API_REAL_NAME(otThreadSetVendorAppUrl)(otInstance *aInstance, const char *aVendorAppUrl);
extern otError OT_API_REAL_NAME(otThreadSetVendorModel)(otInstance *aInstance, const char *aVendorModel);
extern otError OT_API_REAL_NAME(otThreadSetVendorName)(otInstance *aInstance, const char *aVendorName);
extern otError OT_API_REAL_NAME(otThreadSetVendorSwVersion)(otInstance *aInstance, const char *aVendorSwVersion);
const char *OT_API_WRAPPER_NAME(otThreadGetVendorAppUrl)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetVendorAppUrl)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadGetVendorModel)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetVendorModel)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadGetVendorName)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetVendorName)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadGetVendorSwVersion)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetVendorSwVersion)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetNextDiagnosticTlv)(const otMessage *aMessage,
otNetworkDiagIterator *aIterator,
otNetworkDiagTlv *aNetworkDiagTlv)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetNextDiagnosticTlv)(aMessage, aIterator, aNetworkDiagTlv);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSendDiagnosticGet)(otInstance *aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount,
otReceiveDiagnosticGetCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otThreadSendDiagnosticGet)(aInstance, aDestination, aTlvTypes, aCount, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSendDiagnosticReset)(otInstance *aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSendDiagnosticReset)(aInstance, aDestination, aTlvTypes, aCount);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetVendorAppUrl)(otInstance *aInstance, const char *aVendorAppUrl)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetVendorAppUrl)(aInstance, aVendorAppUrl);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetVendorModel)(otInstance *aInstance, const char *aVendorModel)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetVendorModel)(aInstance, aVendorModel);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetVendorName)(otInstance *aInstance, const char *aVendorName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetVendorName)(aInstance, aVendorName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetVendorSwVersion)(otInstance *aInstance, const char *aVendorSwVersion)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetVendorSwVersion)(aInstance, aVendorSwVersion);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,105 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Network Time APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/network_time.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otNetworkTimeSetSyncPeriod)(otInstance *aInstance, uint16_t aTimeSyncPeriod);
extern otError OT_API_REAL_NAME(otNetworkTimeSetXtalThreshold)(otInstance *aInstance, uint16_t aXTALThreshold);
extern otNetworkTimeStatus OT_API_REAL_NAME(otNetworkTimeGet)(otInstance *aInstance, uint64_t *aNetworkTime);
extern uint16_t OT_API_REAL_NAME(otNetworkTimeGetSyncPeriod)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otNetworkTimeGetXtalThreshold)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otNetworkTimeSyncSetCallback)(otInstance *aInstance,
otNetworkTimeSyncCallbackFn aCallbackFn,
void *aCallbackContext);
otError OT_API_WRAPPER_NAME(otNetworkTimeSetSyncPeriod)(otInstance *aInstance, uint16_t aTimeSyncPeriod)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetworkTimeSetSyncPeriod)(aInstance, aTimeSyncPeriod);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otNetworkTimeSetXtalThreshold)(otInstance *aInstance, uint16_t aXTALThreshold)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otNetworkTimeSetXtalThreshold)(aInstance, aXTALThreshold);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otNetworkTimeStatus OT_API_WRAPPER_NAME(otNetworkTimeGet)(otInstance *aInstance, uint64_t *aNetworkTime)
{
sl_ot_rtos_acquire_stack_mutex();
otNetworkTimeStatus ret = OT_API_REAL_NAME(otNetworkTimeGet)(aInstance, aNetworkTime);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otNetworkTimeGetSyncPeriod)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otNetworkTimeGetSyncPeriod)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otNetworkTimeGetXtalThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otNetworkTimeGetXtalThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otNetworkTimeSyncSetCallback)(otInstance *aInstance,
otNetworkTimeSyncCallbackFn aCallbackFn,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otNetworkTimeSyncSetCallback)(aInstance, aCallbackFn, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Ping Sender APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/ping_sender.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otPingSenderPing)(otInstance *aInstance, const otPingSenderConfig *aConfig);
extern void OT_API_REAL_NAME(otPingSenderStop)(otInstance *aInstance);
otError OT_API_WRAPPER_NAME(otPingSenderPing)(otInstance *aInstance, const otPingSenderConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otPingSenderPing)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otPingSenderStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otPingSenderStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Radio Stats APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/radio_stats.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const otRadioTimeStats *OT_API_REAL_NAME(otRadioTimeStatsGet)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otRadioTimeStatsReset)(otInstance *aInstance);
const otRadioTimeStats *OT_API_WRAPPER_NAME(otRadioTimeStatsGet)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otRadioTimeStats *ret = OT_API_REAL_NAME(otRadioTimeStatsGet)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otRadioTimeStatsReset)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otRadioTimeStatsReset)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,57 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Random Crypto APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/random_crypto.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otRandomCryptoFillBuffer)(uint8_t *aBuffer, uint16_t aSize);
otError OT_API_WRAPPER_NAME(otRandomCryptoFillBuffer)(uint8_t *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otRandomCryptoFillBuffer)(aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,119 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Random Noncrypto APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/random_noncrypto.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern uint16_t OT_API_REAL_NAME(otRandomNonCryptoGetUint16)(void);
extern uint16_t OT_API_REAL_NAME(otRandomNonCryptoGetUint16InRange)(uint16_t aMin, uint16_t aMax);
extern uint32_t OT_API_REAL_NAME(otRandomNonCryptoAddJitter)(uint32_t aValue, uint16_t aJitter);
extern uint32_t OT_API_REAL_NAME(otRandomNonCryptoGetUint32)(void);
extern uint32_t OT_API_REAL_NAME(otRandomNonCryptoGetUint32InRange)(uint32_t aMin, uint32_t aMax);
extern uint8_t OT_API_REAL_NAME(otRandomNonCryptoGetUint8)(void);
extern uint8_t OT_API_REAL_NAME(otRandomNonCryptoGetUint8InRange)(uint8_t aMin, uint8_t aMax);
extern void OT_API_REAL_NAME(otRandomNonCryptoFillBuffer)(uint8_t *aBuffer, uint16_t aSize);
uint16_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint16)(void)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint16)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint16InRange)(uint16_t aMin, uint16_t aMax)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint16InRange)(aMin, aMax);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otRandomNonCryptoAddJitter)(uint32_t aValue, uint16_t aJitter)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otRandomNonCryptoAddJitter)(aValue, aJitter);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint32)(void)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint32)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint32InRange)(uint32_t aMin, uint32_t aMax)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint32InRange)(aMin, aMax);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint8)(void)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint8)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otRandomNonCryptoGetUint8InRange)(uint8_t aMin, uint8_t aMax)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otRandomNonCryptoGetUint8InRange)(aMin, aMax);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otRandomNonCryptoFillBuffer)(uint8_t *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otRandomNonCryptoFillBuffer)(aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,110 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Server APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/server.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otServerAddService)(otInstance *aInstance, const otServiceConfig *aConfig);
extern otError OT_API_REAL_NAME(otServerGetNetDataLocal)(otInstance *aInstance,
bool aStable,
uint8_t *aData,
uint8_t *aDataLength);
extern otError OT_API_REAL_NAME(otServerGetNextService)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otServiceConfig *aConfig);
extern otError OT_API_REAL_NAME(otServerRegister)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otServerRemoveService)(otInstance *aInstance,
uint32_t aEnterpriseNumber,
const uint8_t *aServiceData,
uint8_t aServiceDataLength);
otError OT_API_WRAPPER_NAME(otServerAddService)(otInstance *aInstance, const otServiceConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otServerAddService)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otServerGetNetDataLocal)(otInstance *aInstance,
bool aStable,
uint8_t *aData,
uint8_t *aDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otServerGetNetDataLocal)(aInstance, aStable, aData, aDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otServerGetNextService)(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otServiceConfig *aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otServerGetNextService)(aInstance, aIterator, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otServerRegister)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otServerRegister)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otServerRemoveService)(otInstance *aInstance,
uint32_t aEnterpriseNumber,
const uint8_t *aServiceData,
uint8_t aServiceDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otServerRemoveService)(aInstance, aEnterpriseNumber, aServiceData, aServiceDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,71 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Sntp APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/sntp.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otSntpClientQuery)(otInstance *aInstance,
const otSntpQuery *aQuery,
otSntpResponseHandler aHandler,
void *aContext);
extern void OT_API_REAL_NAME(otSntpClientSetUnixEra)(otInstance *aInstance, uint32_t aUnixEra);
otError OT_API_WRAPPER_NAME(otSntpClientQuery)(otInstance *aInstance,
const otSntpQuery *aQuery,
otSntpResponseHandler aHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSntpClientQuery)(aInstance, aQuery, aHandler, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otSntpClientSetUnixEra)(otInstance *aInstance, uint32_t aUnixEra)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSntpClientSetUnixEra)(aInstance, aUnixEra);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,137 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Srp Client Buffers APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/srp_client_buffers.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern char *OT_API_REAL_NAME(otSrpClientBuffersGetHostNameString)(otInstance *aInstance, uint16_t *aSize);
extern char *OT_API_REAL_NAME(
otSrpClientBuffersGetServiceEntryInstanceNameString)(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize);
extern char *OT_API_REAL_NAME(
otSrpClientBuffersGetServiceEntryServiceNameString)(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize);
extern const char **OT_API_REAL_NAME(otSrpClientBuffersGetSubTypeLabelsArray)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aArrayLength);
extern otIp6Address *OT_API_REAL_NAME(otSrpClientBuffersGetHostAddressesArray)(otInstance *aInstance,
uint8_t *aArrayLength);
extern otSrpClientBuffersServiceEntry *OT_API_REAL_NAME(otSrpClientBuffersAllocateService)(otInstance *aInstance);
extern uint8_t *OT_API_REAL_NAME(otSrpClientBuffersGetServiceEntryTxtBuffer)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aSize);
extern void OT_API_REAL_NAME(otSrpClientBuffersFreeAllServices)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otSrpClientBuffersFreeService)(otInstance *aInstance,
otSrpClientBuffersServiceEntry *aService);
char *OT_API_WRAPPER_NAME(otSrpClientBuffersGetHostNameString)(otInstance *aInstance, uint16_t *aSize)
{
sl_ot_rtos_acquire_stack_mutex();
char *ret = OT_API_REAL_NAME(otSrpClientBuffersGetHostNameString)(aInstance, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
char *OT_API_WRAPPER_NAME(otSrpClientBuffersGetServiceEntryInstanceNameString)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aSize)
{
sl_ot_rtos_acquire_stack_mutex();
char *ret = OT_API_REAL_NAME(otSrpClientBuffersGetServiceEntryInstanceNameString)(aEntry, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
char *OT_API_WRAPPER_NAME(otSrpClientBuffersGetServiceEntryServiceNameString)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aSize)
{
sl_ot_rtos_acquire_stack_mutex();
char *ret = OT_API_REAL_NAME(otSrpClientBuffersGetServiceEntryServiceNameString)(aEntry, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char **OT_API_WRAPPER_NAME(otSrpClientBuffersGetSubTypeLabelsArray)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aArrayLength)
{
sl_ot_rtos_acquire_stack_mutex();
const char **ret = OT_API_REAL_NAME(otSrpClientBuffersGetSubTypeLabelsArray)(aEntry, aArrayLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otIp6Address *OT_API_WRAPPER_NAME(otSrpClientBuffersGetHostAddressesArray)(otInstance *aInstance, uint8_t *aArrayLength)
{
sl_ot_rtos_acquire_stack_mutex();
otIp6Address *ret = OT_API_REAL_NAME(otSrpClientBuffersGetHostAddressesArray)(aInstance, aArrayLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otSrpClientBuffersServiceEntry *OT_API_WRAPPER_NAME(otSrpClientBuffersAllocateService)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otSrpClientBuffersServiceEntry *ret = OT_API_REAL_NAME(otSrpClientBuffersAllocateService)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t *OT_API_WRAPPER_NAME(otSrpClientBuffersGetServiceEntryTxtBuffer)(otSrpClientBuffersServiceEntry *aEntry,
uint16_t *aSize)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t *ret = OT_API_REAL_NAME(otSrpClientBuffersGetServiceEntryTxtBuffer)(aEntry, aSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otSrpClientBuffersFreeAllServices)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientBuffersFreeAllServices)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientBuffersFreeService)(otInstance *aInstance, otSrpClientBuffersServiceEntry *aService)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientBuffersFreeService)(aInstance, aService);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,314 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Srp Client APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/srp_client.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otSrpClientIsAutoStartModeEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otSrpClientIsRunning)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otSrpClientIsServiceKeyRecordEnabled)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otSrpClientGetDomainName)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otSrpClientItemStateToString)(otSrpClientItemState aItemState);
extern const otSockAddr *OT_API_REAL_NAME(otSrpClientGetServerAddress)(otInstance *aInstance);
extern const otSrpClientHostInfo *OT_API_REAL_NAME(otSrpClientGetHostInfo)(otInstance *aInstance);
extern const otSrpClientService *OT_API_REAL_NAME(otSrpClientGetServices)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otSrpClientAddService)(otInstance *aInstance, otSrpClientService *aService);
extern otError OT_API_REAL_NAME(otSrpClientClearService)(otInstance *aInstance, otSrpClientService *aService);
extern otError OT_API_REAL_NAME(otSrpClientEnableAutoHostAddress)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otSrpClientRemoveHostAndServices)(otInstance *aInstance,
bool aRemoveKeyLease,
bool aSendUnregToServer);
extern otError OT_API_REAL_NAME(otSrpClientRemoveService)(otInstance *aInstance, otSrpClientService *aService);
extern otError OT_API_REAL_NAME(otSrpClientSetDomainName)(otInstance *aInstance, const char *aName);
extern otError OT_API_REAL_NAME(otSrpClientSetHostAddresses)(otInstance *aInstance,
const otIp6Address *aIp6Addresses,
uint8_t aNumAddresses);
extern otError OT_API_REAL_NAME(otSrpClientSetHostName)(otInstance *aInstance, const char *aName);
extern otError OT_API_REAL_NAME(otSrpClientStart)(otInstance *aInstance, const otSockAddr *aServerSockAddr);
extern uint32_t OT_API_REAL_NAME(otSrpClientGetKeyLeaseInterval)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otSrpClientGetLeaseInterval)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otSrpClientGetTtl)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otSrpClientClearHostAndServices)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otSrpClientDisableAutoStartMode)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otSrpClientEnableAutoStartMode)(otInstance *aInstance,
otSrpClientAutoStartCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otSrpClientSetCallback)(otInstance *aInstance,
otSrpClientCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otSrpClientSetKeyLeaseInterval)(otInstance *aInstance, uint32_t aInterval);
extern void OT_API_REAL_NAME(otSrpClientSetLeaseInterval)(otInstance *aInstance, uint32_t aInterval);
extern void OT_API_REAL_NAME(otSrpClientSetServiceKeyRecordEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otSrpClientSetTtl)(otInstance *aInstance, uint32_t aTtl);
extern void OT_API_REAL_NAME(otSrpClientStop)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otSrpClientIsAutoStartModeEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpClientIsAutoStartModeEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpClientIsRunning)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpClientIsRunning)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpClientIsServiceKeyRecordEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpClientIsServiceKeyRecordEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpClientGetDomainName)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpClientGetDomainName)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpClientItemStateToString)(otSrpClientItemState aItemState)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpClientItemStateToString)(aItemState);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSockAddr *OT_API_WRAPPER_NAME(otSrpClientGetServerAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otSockAddr *ret = OT_API_REAL_NAME(otSrpClientGetServerAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpClientHostInfo *OT_API_WRAPPER_NAME(otSrpClientGetHostInfo)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpClientHostInfo *ret = OT_API_REAL_NAME(otSrpClientGetHostInfo)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpClientService *OT_API_WRAPPER_NAME(otSrpClientGetServices)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpClientService *ret = OT_API_REAL_NAME(otSrpClientGetServices)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientAddService)(otInstance *aInstance, otSrpClientService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientAddService)(aInstance, aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientClearService)(otInstance *aInstance, otSrpClientService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientClearService)(aInstance, aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientEnableAutoHostAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientEnableAutoHostAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientRemoveHostAndServices)(otInstance *aInstance,
bool aRemoveKeyLease,
bool aSendUnregToServer)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientRemoveHostAndServices)(aInstance, aRemoveKeyLease, aSendUnregToServer);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientRemoveService)(otInstance *aInstance, otSrpClientService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientRemoveService)(aInstance, aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientSetDomainName)(otInstance *aInstance, const char *aName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientSetDomainName)(aInstance, aName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientSetHostAddresses)(otInstance *aInstance,
const otIp6Address *aIp6Addresses,
uint8_t aNumAddresses)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientSetHostAddresses)(aInstance, aIp6Addresses, aNumAddresses);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientSetHostName)(otInstance *aInstance, const char *aName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientSetHostName)(aInstance, aName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpClientStart)(otInstance *aInstance, const otSockAddr *aServerSockAddr)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpClientStart)(aInstance, aServerSockAddr);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otSrpClientGetKeyLeaseInterval)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otSrpClientGetKeyLeaseInterval)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otSrpClientGetLeaseInterval)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otSrpClientGetLeaseInterval)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otSrpClientGetTtl)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otSrpClientGetTtl)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otSrpClientClearHostAndServices)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientClearHostAndServices)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientDisableAutoStartMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientDisableAutoStartMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientEnableAutoStartMode)(otInstance *aInstance,
otSrpClientAutoStartCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientEnableAutoStartMode)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientSetCallback)(otInstance *aInstance, otSrpClientCallback aCallback, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientSetCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientSetKeyLeaseInterval)(otInstance *aInstance, uint32_t aInterval)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientSetKeyLeaseInterval)(aInstance, aInterval);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientSetLeaseInterval)(otInstance *aInstance, uint32_t aInterval)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientSetLeaseInterval)(aInstance, aInterval);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientSetServiceKeyRecordEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientSetServiceKeyRecordEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientSetTtl)(otInstance *aInstance, uint32_t aTtl)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientSetTtl)(aInstance, aTtl);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpClientStop)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpClientStop)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,451 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Srp Server APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/srp_server.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otSrpServerHostIsDeleted)(const otSrpServerHost *aHost);
extern bool OT_API_REAL_NAME(otSrpServerHostMatchesFullName)(const otSrpServerHost *aHost, const char *aFullName);
extern bool OT_API_REAL_NAME(otSrpServerIsAutoEnableMode)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otSrpServerServiceHasSubTypeServiceName)(const otSrpServerService *aService,
const char *aSubTypeServiceName);
extern bool OT_API_REAL_NAME(otSrpServerServiceIsDeleted)(const otSrpServerService *aService);
extern bool OT_API_REAL_NAME(otSrpServerServiceMatchesInstanceName)(const otSrpServerService *aService,
const char *aInstanceName);
extern bool OT_API_REAL_NAME(otSrpServerServiceMatchesServiceName)(const otSrpServerService *aService,
const char *aServiceName);
extern const char *OT_API_REAL_NAME(otSrpServerGetDomain)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otSrpServerHostGetFullName)(const otSrpServerHost *aHost);
extern const char *OT_API_REAL_NAME(otSrpServerServiceGetInstanceLabel)(const otSrpServerService *aService);
extern const char *OT_API_REAL_NAME(otSrpServerServiceGetInstanceName)(const otSrpServerService *aService);
extern const char *OT_API_REAL_NAME(otSrpServerServiceGetServiceName)(const otSrpServerService *aService);
extern const char *OT_API_REAL_NAME(otSrpServerServiceGetSubTypeServiceNameAt)(const otSrpServerService *aService,
uint16_t aIndex);
extern const otIp6Address *OT_API_REAL_NAME(otSrpServerHostGetAddresses)(const otSrpServerHost *aHost,
uint8_t *aAddressesNum);
extern const otSrpServerHost *OT_API_REAL_NAME(otSrpServerGetNextHost)(otInstance *aInstance,
const otSrpServerHost *aHost);
extern const otSrpServerHost *OT_API_REAL_NAME(otSrpServerServiceGetHost)(const otSrpServerService *aService);
extern const otSrpServerResponseCounters *OT_API_REAL_NAME(otSrpServerGetResponseCounters)(otInstance *aInstance);
extern const otSrpServerService *OT_API_REAL_NAME(otSrpServerHostGetNextService)(const otSrpServerHost *aHost,
const otSrpServerService *aService);
extern const uint8_t *OT_API_REAL_NAME(otSrpServerServiceGetTxtData)(const otSrpServerService *aService,
uint16_t *aDataLength);
extern otError OT_API_REAL_NAME(otSrpServerParseSubTypeServiceName)(const char *aSubTypeServiceName,
char *aLabel,
uint8_t aLabelSize);
extern otError OT_API_REAL_NAME(otSrpServerSetAddressMode)(otInstance *aInstance, otSrpServerAddressMode aMode);
extern otError OT_API_REAL_NAME(otSrpServerSetAnycastModeSequenceNumber)(otInstance *aInstance,
uint8_t aSequenceNumber);
extern otError OT_API_REAL_NAME(otSrpServerSetDomain)(otInstance *aInstance, const char *aDomain);
extern otError OT_API_REAL_NAME(otSrpServerSetLeaseConfig)(otInstance *aInstance,
const otSrpServerLeaseConfig *aLeaseConfig);
extern otError OT_API_REAL_NAME(otSrpServerSetTtlConfig)(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig);
extern otSrpServerAddressMode OT_API_REAL_NAME(otSrpServerGetAddressMode)(otInstance *aInstance);
extern otSrpServerState OT_API_REAL_NAME(otSrpServerGetState)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otSrpServerGetPort)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otSrpServerServiceGetNumberOfSubTypes)(const otSrpServerService *aService);
extern uint16_t OT_API_REAL_NAME(otSrpServerServiceGetPort)(const otSrpServerService *aService);
extern uint16_t OT_API_REAL_NAME(otSrpServerServiceGetPriority)(const otSrpServerService *aService);
extern uint16_t OT_API_REAL_NAME(otSrpServerServiceGetWeight)(const otSrpServerService *aService);
extern uint32_t OT_API_REAL_NAME(otSrpServerServiceGetTtl)(const otSrpServerService *aService);
extern uint8_t OT_API_REAL_NAME(otSrpServerGetAnycastModeSequenceNumber)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otSrpServerGetLeaseConfig)(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig);
extern void OT_API_REAL_NAME(otSrpServerGetTtlConfig)(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig);
extern void OT_API_REAL_NAME(otSrpServerHandleServiceUpdateResult)(otInstance *aInstance,
otSrpServerServiceUpdateId aId,
otError aError);
extern void OT_API_REAL_NAME(otSrpServerHostGetLeaseInfo)(const otSrpServerHost *aHost,
otSrpServerLeaseInfo *aLeaseInfo);
extern void OT_API_REAL_NAME(otSrpServerServiceGetLeaseInfo)(const otSrpServerService *aService,
otSrpServerLeaseInfo *aLeaseInfo);
extern void OT_API_REAL_NAME(otSrpServerSetAutoEnableMode)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otSrpServerSetEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otSrpServerSetServiceUpdateHandler)(otInstance *aInstance,
otSrpServerServiceUpdateHandler aServiceHandler,
void *aContext);
bool OT_API_WRAPPER_NAME(otSrpServerHostIsDeleted)(const otSrpServerHost *aHost)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerHostIsDeleted)(aHost);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerHostMatchesFullName)(const otSrpServerHost *aHost, const char *aFullName)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerHostMatchesFullName)(aHost, aFullName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerIsAutoEnableMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerIsAutoEnableMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerServiceHasSubTypeServiceName)(const otSrpServerService *aService,
const char *aSubTypeServiceName)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerServiceHasSubTypeServiceName)(aService, aSubTypeServiceName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerServiceIsDeleted)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerServiceIsDeleted)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerServiceMatchesInstanceName)(const otSrpServerService *aService,
const char *aInstanceName)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerServiceMatchesInstanceName)(aService, aInstanceName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otSrpServerServiceMatchesServiceName)(const otSrpServerService *aService,
const char *aServiceName)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otSrpServerServiceMatchesServiceName)(aService, aServiceName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerGetDomain)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerGetDomain)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerHostGetFullName)(const otSrpServerHost *aHost)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerHostGetFullName)(aHost);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerServiceGetInstanceLabel)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerServiceGetInstanceLabel)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerServiceGetInstanceName)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerServiceGetInstanceName)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerServiceGetServiceName)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerServiceGetServiceName)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otSrpServerServiceGetSubTypeServiceNameAt)(const otSrpServerService *aService,
uint16_t aIndex)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otSrpServerServiceGetSubTypeServiceNameAt)(aService, aIndex);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otSrpServerHostGetAddresses)(const otSrpServerHost *aHost,
uint8_t *aAddressesNum)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otSrpServerHostGetAddresses)(aHost, aAddressesNum);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpServerHost *OT_API_WRAPPER_NAME(otSrpServerGetNextHost)(otInstance *aInstance, const otSrpServerHost *aHost)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpServerHost *ret = OT_API_REAL_NAME(otSrpServerGetNextHost)(aInstance, aHost);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpServerHost *OT_API_WRAPPER_NAME(otSrpServerServiceGetHost)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpServerHost *ret = OT_API_REAL_NAME(otSrpServerServiceGetHost)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpServerResponseCounters *OT_API_WRAPPER_NAME(otSrpServerGetResponseCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpServerResponseCounters *ret = OT_API_REAL_NAME(otSrpServerGetResponseCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSrpServerService *OT_API_WRAPPER_NAME(otSrpServerHostGetNextService)(const otSrpServerHost *aHost,
const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
const otSrpServerService *ret = OT_API_REAL_NAME(otSrpServerHostGetNextService)(aHost, aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint8_t *OT_API_WRAPPER_NAME(otSrpServerServiceGetTxtData)(const otSrpServerService *aService,
uint16_t *aDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
const uint8_t *ret = OT_API_REAL_NAME(otSrpServerServiceGetTxtData)(aService, aDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerParseSubTypeServiceName)(const char *aSubTypeServiceName,
char *aLabel,
uint8_t aLabelSize)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerParseSubTypeServiceName)(aSubTypeServiceName, aLabel, aLabelSize);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerSetAddressMode)(otInstance *aInstance, otSrpServerAddressMode aMode)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerSetAddressMode)(aInstance, aMode);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerSetAnycastModeSequenceNumber)(otInstance *aInstance, uint8_t aSequenceNumber)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerSetAnycastModeSequenceNumber)(aInstance, aSequenceNumber);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerSetDomain)(otInstance *aInstance, const char *aDomain)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerSetDomain)(aInstance, aDomain);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerSetLeaseConfig)(otInstance *aInstance,
const otSrpServerLeaseConfig *aLeaseConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerSetLeaseConfig)(aInstance, aLeaseConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otSrpServerSetTtlConfig)(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otSrpServerSetTtlConfig)(aInstance, aTtlConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otSrpServerAddressMode OT_API_WRAPPER_NAME(otSrpServerGetAddressMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otSrpServerAddressMode ret = OT_API_REAL_NAME(otSrpServerGetAddressMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otSrpServerState OT_API_WRAPPER_NAME(otSrpServerGetState)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otSrpServerState ret = OT_API_REAL_NAME(otSrpServerGetState)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otSrpServerGetPort)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otSrpServerGetPort)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otSrpServerServiceGetNumberOfSubTypes)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otSrpServerServiceGetNumberOfSubTypes)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otSrpServerServiceGetPort)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otSrpServerServiceGetPort)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otSrpServerServiceGetPriority)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otSrpServerServiceGetPriority)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otSrpServerServiceGetWeight)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otSrpServerServiceGetWeight)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otSrpServerServiceGetTtl)(const otSrpServerService *aService)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otSrpServerServiceGetTtl)(aService);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otSrpServerGetAnycastModeSequenceNumber)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otSrpServerGetAnycastModeSequenceNumber)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otSrpServerGetLeaseConfig)(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerGetLeaseConfig)(aInstance, aLeaseConfig);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerGetTtlConfig)(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerGetTtlConfig)(aInstance, aTtlConfig);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerHandleServiceUpdateResult)(otInstance *aInstance,
otSrpServerServiceUpdateId aId,
otError aError)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerHandleServiceUpdateResult)(aInstance, aId, aError);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerHostGetLeaseInfo)(const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerHostGetLeaseInfo)(aHost, aLeaseInfo);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerServiceGetLeaseInfo)(const otSrpServerService *aService,
otSrpServerLeaseInfo *aLeaseInfo)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerServiceGetLeaseInfo)(aService, aLeaseInfo);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerSetAutoEnableMode)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerSetAutoEnableMode)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerSetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerSetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otSrpServerSetServiceUpdateHandler)(otInstance *aInstance,
otSrpServerServiceUpdateHandler aServiceHandler,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otSrpServerSetServiceUpdateHandler)(aInstance, aServiceHandler, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Tasklet APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/tasklet.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otTaskletsArePending)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otTaskletsProcess)(otInstance *aInstance);
bool OT_API_WRAPPER_NAME(otTaskletsArePending)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otTaskletsArePending)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otTaskletsProcess)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTaskletsProcess)(aInstance);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,47 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Tcat APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/tcat.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif

View File

@@ -0,0 +1,134 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Tcp Ext APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/tcp_ext.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern int OT_API_REAL_NAME(otTcpMbedTlsSslRecvCallback)(void *aCtx, unsigned char *aBuf, size_t aLen);
extern int OT_API_REAL_NAME(otTcpMbedTlsSslSendCallback)(void *aCtx, const unsigned char *aBuf, size_t aLen);
extern otError OT_API_REAL_NAME(otTcpCircularSendBufferDeinitialize)(otTcpCircularSendBuffer *aSendBuffer);
extern otError OT_API_REAL_NAME(otTcpCircularSendBufferWrite)(otTcpEndpoint *aEndpoint,
otTcpCircularSendBuffer *aSendBuffer,
const void *aData,
size_t aLength,
size_t *aWritten,
uint32_t aFlags);
extern size_t OT_API_REAL_NAME(otTcpCircularSendBufferGetFreeSpace)(const otTcpCircularSendBuffer *aSendBuffer);
extern void OT_API_REAL_NAME(otTcpCircularSendBufferForceDiscardAll)(otTcpCircularSendBuffer *aSendBuffer);
extern void OT_API_REAL_NAME(otTcpCircularSendBufferHandleForwardProgress)(otTcpCircularSendBuffer *aSendBuffer,
size_t aInSendBuffer);
extern void OT_API_REAL_NAME(otTcpCircularSendBufferInitialize)(otTcpCircularSendBuffer *aSendBuffer,
void *aDataBuffer,
size_t aCapacity);
int OT_API_WRAPPER_NAME(otTcpMbedTlsSslRecvCallback)(void *aCtx, unsigned char *aBuf, size_t aLen)
{
sl_ot_rtos_acquire_stack_mutex();
int ret = OT_API_REAL_NAME(otTcpMbedTlsSslRecvCallback)(aCtx, aBuf, aLen);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int OT_API_WRAPPER_NAME(otTcpMbedTlsSslSendCallback)(void *aCtx, const unsigned char *aBuf, size_t aLen)
{
sl_ot_rtos_acquire_stack_mutex();
int ret = OT_API_REAL_NAME(otTcpMbedTlsSslSendCallback)(aCtx, aBuf, aLen);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpCircularSendBufferDeinitialize)(otTcpCircularSendBuffer *aSendBuffer)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpCircularSendBufferDeinitialize)(aSendBuffer);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpCircularSendBufferWrite)(otTcpEndpoint *aEndpoint,
otTcpCircularSendBuffer *aSendBuffer,
const void *aData,
size_t aLength,
size_t *aWritten,
uint32_t aFlags)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret =
OT_API_REAL_NAME(otTcpCircularSendBufferWrite)(aEndpoint, aSendBuffer, aData, aLength, aWritten, aFlags);
sl_ot_rtos_release_stack_mutex();
return ret;
}
size_t OT_API_WRAPPER_NAME(otTcpCircularSendBufferGetFreeSpace)(const otTcpCircularSendBuffer *aSendBuffer)
{
sl_ot_rtos_acquire_stack_mutex();
size_t ret = OT_API_REAL_NAME(otTcpCircularSendBufferGetFreeSpace)(aSendBuffer);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otTcpCircularSendBufferForceDiscardAll)(otTcpCircularSendBuffer *aSendBuffer)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTcpCircularSendBufferForceDiscardAll)(aSendBuffer);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otTcpCircularSendBufferHandleForwardProgress)(otTcpCircularSendBuffer *aSendBuffer,
size_t aInSendBuffer)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTcpCircularSendBufferHandleForwardProgress)(aSendBuffer, aInSendBuffer);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otTcpCircularSendBufferInitialize)(otTcpCircularSendBuffer *aSendBuffer,
void *aDataBuffer,
size_t aCapacity)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTcpCircularSendBufferInitialize)(aSendBuffer, aDataBuffer, aCapacity);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,247 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Tcp APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/tcp.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern const otSockAddr *OT_API_REAL_NAME(otTcpGetLocalAddress)(const otTcpEndpoint *aEndpoint);
extern const otSockAddr *OT_API_REAL_NAME(otTcpGetPeerAddress)(const otTcpEndpoint *aEndpoint);
extern otError OT_API_REAL_NAME(otTcpAbort)(otTcpEndpoint *aEndpoint);
extern otError OT_API_REAL_NAME(otTcpBind)(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName);
extern otError OT_API_REAL_NAME(otTcpCommitReceive)(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags);
extern otError OT_API_REAL_NAME(otTcpConnect)(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName, uint32_t aFlags);
extern otError OT_API_REAL_NAME(otTcpEndpointDeinitialize)(otTcpEndpoint *aEndpoint);
extern otError OT_API_REAL_NAME(otTcpEndpointInitialize)(otInstance *aInstance,
otTcpEndpoint *aEndpoint,
const otTcpEndpointInitializeArgs *aArgs);
extern otError OT_API_REAL_NAME(otTcpListen)(otTcpListener *aListener, const otSockAddr *aSockName);
extern otError OT_API_REAL_NAME(otTcpListenerDeinitialize)(otTcpListener *aListener);
extern otError OT_API_REAL_NAME(otTcpListenerInitialize)(otInstance *aInstance,
otTcpListener *aListener,
const otTcpListenerInitializeArgs *aArgs);
extern otError OT_API_REAL_NAME(otTcpReceiveByReference)(otTcpEndpoint *aEndpoint, const otLinkedBuffer **aBuffer);
extern otError OT_API_REAL_NAME(otTcpReceiveContiguify)(otTcpEndpoint *aEndpoint);
extern otError OT_API_REAL_NAME(otTcpSendByExtension)(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags);
extern otError OT_API_REAL_NAME(otTcpSendByReference)(otTcpEndpoint *aEndpoint,
otLinkedBuffer *aBuffer,
uint32_t aFlags);
extern otError OT_API_REAL_NAME(otTcpSendEndOfStream)(otTcpEndpoint *aEndpoint);
extern otError OT_API_REAL_NAME(otTcpStopListening)(otTcpListener *aListener);
extern otInstance *OT_API_REAL_NAME(otTcpEndpointGetInstance)(otTcpEndpoint *aEndpoint);
extern otInstance *OT_API_REAL_NAME(otTcpListenerGetInstance)(otTcpListener *aListener);
extern void *OT_API_REAL_NAME(otTcpEndpointGetContext)(otTcpEndpoint *aEndpoint);
extern void *OT_API_REAL_NAME(otTcpListenerGetContext)(otTcpListener *aListener);
const otSockAddr *OT_API_WRAPPER_NAME(otTcpGetLocalAddress)(const otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
const otSockAddr *ret = OT_API_REAL_NAME(otTcpGetLocalAddress)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otSockAddr *OT_API_WRAPPER_NAME(otTcpGetPeerAddress)(const otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
const otSockAddr *ret = OT_API_REAL_NAME(otTcpGetPeerAddress)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpAbort)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpAbort)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpBind)(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpBind)(aEndpoint, aSockName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpCommitReceive)(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpCommitReceive)(aEndpoint, aNumBytes, aFlags);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpConnect)(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName, uint32_t aFlags)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpConnect)(aEndpoint, aSockName, aFlags);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpEndpointDeinitialize)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpEndpointDeinitialize)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpEndpointInitialize)(otInstance *aInstance,
otTcpEndpoint *aEndpoint,
const otTcpEndpointInitializeArgs *aArgs)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpEndpointInitialize)(aInstance, aEndpoint, aArgs);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpListen)(otTcpListener *aListener, const otSockAddr *aSockName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpListen)(aListener, aSockName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpListenerDeinitialize)(otTcpListener *aListener)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpListenerDeinitialize)(aListener);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpListenerInitialize)(otInstance *aInstance,
otTcpListener *aListener,
const otTcpListenerInitializeArgs *aArgs)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpListenerInitialize)(aInstance, aListener, aArgs);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpReceiveByReference)(otTcpEndpoint *aEndpoint, const otLinkedBuffer **aBuffer)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpReceiveByReference)(aEndpoint, aBuffer);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpReceiveContiguify)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpReceiveContiguify)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpSendByExtension)(otTcpEndpoint *aEndpoint, size_t aNumBytes, uint32_t aFlags)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpSendByExtension)(aEndpoint, aNumBytes, aFlags);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpSendByReference)(otTcpEndpoint *aEndpoint, otLinkedBuffer *aBuffer, uint32_t aFlags)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpSendByReference)(aEndpoint, aBuffer, aFlags);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpSendEndOfStream)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpSendEndOfStream)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otTcpStopListening)(otTcpListener *aListener)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otTcpStopListening)(aListener);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otInstance *OT_API_WRAPPER_NAME(otTcpEndpointGetInstance)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
otInstance *ret = OT_API_REAL_NAME(otTcpEndpointGetInstance)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otInstance *OT_API_WRAPPER_NAME(otTcpListenerGetInstance)(otTcpListener *aListener)
{
sl_ot_rtos_acquire_stack_mutex();
otInstance *ret = OT_API_REAL_NAME(otTcpListenerGetInstance)(aListener);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void *OT_API_WRAPPER_NAME(otTcpEndpointGetContext)(otTcpEndpoint *aEndpoint)
{
sl_ot_rtos_acquire_stack_mutex();
void *ret = OT_API_REAL_NAME(otTcpEndpointGetContext)(aEndpoint);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void *OT_API_WRAPPER_NAME(otTcpListenerGetContext)(otTcpListener *aListener)
{
sl_ot_rtos_acquire_stack_mutex();
void *ret = OT_API_REAL_NAME(otTcpListenerGetContext)(aListener);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,550 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Thread Ftd APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/thread_ftd.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otThreadIsRouterEligible)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otThreadIsRouterIdAllocated)(otInstance *aInstance, uint8_t aRouterId);
extern bool OT_API_REAL_NAME(otThreadIsTmfOriginFilterEnabled)(otInstance *aInstance);
extern const otDeviceProperties *OT_API_REAL_NAME(otThreadGetDeviceProperties)(otInstance *aInstance);
extern int8_t OT_API_REAL_NAME(otThreadGetParentPriority)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadBecomeLeader)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadBecomeRouter)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadGetChildInfoById)(otInstance *aInstance,
uint16_t aChildId,
otChildInfo *aChildInfo);
extern otError OT_API_REAL_NAME(otThreadGetChildInfoByIndex)(otInstance *aInstance,
uint16_t aChildIndex,
otChildInfo *aChildInfo);
extern otError OT_API_REAL_NAME(otThreadGetChildNextIp6Address)(otInstance *aInstance,
uint16_t aChildIndex,
otChildIp6AddressIterator *aIterator,
otIp6Address *aAddress);
extern otError OT_API_REAL_NAME(otThreadGetNextCacheEntry)(otInstance *aInstance,
otCacheEntryInfo *aEntryInfo,
otCacheEntryIterator *aIterator);
extern otError OT_API_REAL_NAME(otThreadGetRouterInfo)(otInstance *aInstance,
uint16_t aRouterId,
otRouterInfo *aRouterInfo);
extern otError OT_API_REAL_NAME(otThreadReleaseRouterId)(otInstance *aInstance, uint8_t aRouterId);
extern otError OT_API_REAL_NAME(otThreadSetChildRouterLinks)(otInstance *aInstance, uint8_t aChildRouterLinks);
extern otError OT_API_REAL_NAME(otThreadSetJoinerUdpPort)(otInstance *aInstance, uint16_t aJoinerUdpPort);
extern otError OT_API_REAL_NAME(otThreadSetMaxAllowedChildren)(otInstance *aInstance, uint16_t aMaxChildren);
extern otError OT_API_REAL_NAME(otThreadSetMaxChildIpAddresses)(otInstance *aInstance, uint8_t aMaxIpAddresses);
extern otError OT_API_REAL_NAME(otThreadSetParentPriority)(otInstance *aInstance, int8_t aParentPriority);
extern otError OT_API_REAL_NAME(otThreadSetPreferredRouterId)(otInstance *aInstance, uint8_t aRouterId);
extern otError OT_API_REAL_NAME(otThreadSetPskc)(otInstance *aInstance, const otPskc *aPskc);
extern otError OT_API_REAL_NAME(otThreadSetPskcRef)(otInstance *aInstance, otPskcRef aKeyRef);
extern otError OT_API_REAL_NAME(otThreadSetRouterEligible)(otInstance *aInstance, bool aEligible);
extern otError OT_API_REAL_NAME(otThreadSetRouterIdRange)(otInstance *aInstance,
uint8_t aMinRouterId,
uint8_t aMaxRouterId);
extern otPskcRef OT_API_REAL_NAME(otThreadGetPskcRef)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otThreadGetJoinerUdpPort)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otThreadGetMaxAllowedChildren)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetAdvertisementTrickleIntervalMax)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetContextIdReuseDelay)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetPreferredLeaderPartitionId)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetChildRouterLinks)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetLocalLeaderWeight)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetMaxChildIpAddresses)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetMaxRouterId)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetNetworkIdTimeout)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetRouterDowngradeThreshold)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetRouterIdSequence)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetRouterSelectionJitter)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetRouterUpgradeThreshold)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otThreadGetNextHopAndPathCost)(otInstance *aInstance,
uint16_t aDestRloc16,
uint16_t *aNextHopRloc16,
uint8_t *aPathCost);
extern void OT_API_REAL_NAME(otThreadGetPskc)(otInstance *aInstance, otPskc *aPskc);
extern void OT_API_REAL_NAME(otThreadGetRouterIdRange)(otInstance *aInstance,
uint8_t *aMinRouterId,
uint8_t *aMaxRouterId);
extern void OT_API_REAL_NAME(otThreadRegisterNeighborTableCallback)(otInstance *aInstance,
otNeighborTableCallback aCallback);
extern void OT_API_REAL_NAME(otThreadSetCcmEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otThreadSetContextIdReuseDelay)(otInstance *aInstance, uint32_t aDelay);
extern void OT_API_REAL_NAME(otThreadSetDeviceProperties)(otInstance *aInstance,
const otDeviceProperties *aDeviceProperties);
extern void OT_API_REAL_NAME(otThreadSetLocalLeaderWeight)(otInstance *aInstance, uint8_t aWeight);
extern void OT_API_REAL_NAME(otThreadSetNetworkIdTimeout)(otInstance *aInstance, uint8_t aTimeout);
extern void OT_API_REAL_NAME(otThreadSetPreferredLeaderPartitionId)(otInstance *aInstance, uint32_t aPartitionId);
extern void OT_API_REAL_NAME(otThreadSetRouterDowngradeThreshold)(otInstance *aInstance, uint8_t aThreshold);
extern void OT_API_REAL_NAME(otThreadSetRouterSelectionJitter)(otInstance *aInstance, uint8_t aRouterJitter);
extern void OT_API_REAL_NAME(otThreadSetRouterUpgradeThreshold)(otInstance *aInstance, uint8_t aThreshold);
extern void OT_API_REAL_NAME(otThreadSetSteeringData)(otInstance *aInstance, const otExtAddress *aExtAddress);
extern void OT_API_REAL_NAME(otThreadSetThreadVersionCheckEnabled)(otInstance *aInstance, bool aEnabled);
extern void OT_API_REAL_NAME(otThreadSetTmfOriginFilterEnabled)(otInstance *aInstance, bool aEnabled);
bool OT_API_WRAPPER_NAME(otThreadIsRouterEligible)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsRouterEligible)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otThreadIsRouterIdAllocated)(otInstance *aInstance, uint8_t aRouterId)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsRouterIdAllocated)(aInstance, aRouterId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otThreadIsTmfOriginFilterEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsTmfOriginFilterEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otDeviceProperties *OT_API_WRAPPER_NAME(otThreadGetDeviceProperties)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otDeviceProperties *ret = OT_API_REAL_NAME(otThreadGetDeviceProperties)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
int8_t OT_API_WRAPPER_NAME(otThreadGetParentPriority)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
int8_t ret = OT_API_REAL_NAME(otThreadGetParentPriority)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadBecomeLeader)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadBecomeLeader)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadBecomeRouter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadBecomeRouter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetChildInfoById)(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetChildInfoById)(aInstance, aChildId, aChildInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetChildInfoByIndex)(otInstance *aInstance,
uint16_t aChildIndex,
otChildInfo *aChildInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetChildInfoByIndex)(aInstance, aChildIndex, aChildInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetChildNextIp6Address)(otInstance *aInstance,
uint16_t aChildIndex,
otChildIp6AddressIterator *aIterator,
otIp6Address *aAddress)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetChildNextIp6Address)(aInstance, aChildIndex, aIterator, aAddress);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetNextCacheEntry)(otInstance *aInstance,
otCacheEntryInfo *aEntryInfo,
otCacheEntryIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetNextCacheEntry)(aInstance, aEntryInfo, aIterator);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetRouterInfo)(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetRouterInfo)(aInstance, aRouterId, aRouterInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadReleaseRouterId)(otInstance *aInstance, uint8_t aRouterId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadReleaseRouterId)(aInstance, aRouterId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetChildRouterLinks)(otInstance *aInstance, uint8_t aChildRouterLinks)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetChildRouterLinks)(aInstance, aChildRouterLinks);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetJoinerUdpPort)(otInstance *aInstance, uint16_t aJoinerUdpPort)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetJoinerUdpPort)(aInstance, aJoinerUdpPort);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetMaxAllowedChildren)(otInstance *aInstance, uint16_t aMaxChildren)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetMaxAllowedChildren)(aInstance, aMaxChildren);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetMaxChildIpAddresses)(otInstance *aInstance, uint8_t aMaxIpAddresses)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetMaxChildIpAddresses)(aInstance, aMaxIpAddresses);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetParentPriority)(otInstance *aInstance, int8_t aParentPriority)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetParentPriority)(aInstance, aParentPriority);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetPreferredRouterId)(otInstance *aInstance, uint8_t aRouterId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetPreferredRouterId)(aInstance, aRouterId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetPskc)(otInstance *aInstance, const otPskc *aPskc)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetPskc)(aInstance, aPskc);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetPskcRef)(otInstance *aInstance, otPskcRef aKeyRef)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetPskcRef)(aInstance, aKeyRef);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetRouterEligible)(otInstance *aInstance, bool aEligible)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetRouterEligible)(aInstance, aEligible);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetRouterIdRange)(otInstance *aInstance, uint8_t aMinRouterId, uint8_t aMaxRouterId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetRouterIdRange)(aInstance, aMinRouterId, aMaxRouterId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otPskcRef OT_API_WRAPPER_NAME(otThreadGetPskcRef)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otPskcRef ret = OT_API_REAL_NAME(otThreadGetPskcRef)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otThreadGetJoinerUdpPort)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otThreadGetJoinerUdpPort)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otThreadGetMaxAllowedChildren)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otThreadGetMaxAllowedChildren)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetAdvertisementTrickleIntervalMax)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetAdvertisementTrickleIntervalMax)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetContextIdReuseDelay)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetContextIdReuseDelay)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetPreferredLeaderPartitionId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetPreferredLeaderPartitionId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetChildRouterLinks)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetChildRouterLinks)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetLocalLeaderWeight)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetLocalLeaderWeight)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetMaxChildIpAddresses)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetMaxChildIpAddresses)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetMaxRouterId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetMaxRouterId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetNetworkIdTimeout)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetNetworkIdTimeout)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetRouterDowngradeThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetRouterDowngradeThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetRouterIdSequence)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetRouterIdSequence)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetRouterSelectionJitter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetRouterSelectionJitter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetRouterUpgradeThreshold)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetRouterUpgradeThreshold)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otThreadGetNextHopAndPathCost)(otInstance *aInstance,
uint16_t aDestRloc16,
uint16_t *aNextHopRloc16,
uint8_t *aPathCost)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadGetNextHopAndPathCost)(aInstance, aDestRloc16, aNextHopRloc16, aPathCost);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadGetPskc)(otInstance *aInstance, otPskc *aPskc)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadGetPskc)(aInstance, aPskc);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadGetRouterIdRange)(otInstance *aInstance, uint8_t *aMinRouterId, uint8_t *aMaxRouterId)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadGetRouterIdRange)(aInstance, aMinRouterId, aMaxRouterId);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadRegisterNeighborTableCallback)(otInstance *aInstance,
otNeighborTableCallback aCallback)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadRegisterNeighborTableCallback)(aInstance, aCallback);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetCcmEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetCcmEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetContextIdReuseDelay)(otInstance *aInstance, uint32_t aDelay)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetContextIdReuseDelay)(aInstance, aDelay);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetDeviceProperties)(otInstance *aInstance,
const otDeviceProperties *aDeviceProperties)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetDeviceProperties)(aInstance, aDeviceProperties);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetLocalLeaderWeight)(otInstance *aInstance, uint8_t aWeight)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetLocalLeaderWeight)(aInstance, aWeight);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetNetworkIdTimeout)(otInstance *aInstance, uint8_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetNetworkIdTimeout)(aInstance, aTimeout);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetPreferredLeaderPartitionId)(otInstance *aInstance, uint32_t aPartitionId)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetPreferredLeaderPartitionId)(aInstance, aPartitionId);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetRouterDowngradeThreshold)(otInstance *aInstance, uint8_t aThreshold)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetRouterDowngradeThreshold)(aInstance, aThreshold);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetRouterSelectionJitter)(otInstance *aInstance, uint8_t aRouterJitter)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetRouterSelectionJitter)(aInstance, aRouterJitter);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetRouterUpgradeThreshold)(otInstance *aInstance, uint8_t aThreshold)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetRouterUpgradeThreshold)(aInstance, aThreshold);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetSteeringData)(otInstance *aInstance, const otExtAddress *aExtAddress)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetSteeringData)(aInstance, aExtAddress);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetThreadVersionCheckEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetThreadVersionCheckEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetTmfOriginFilterEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetTmfOriginFilterEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,722 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Thread APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/thread.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otThreadIsAnycastLocateInProgress)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otThreadIsDiscoverInProgress)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otThreadIsSingleton)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otThreadDeviceRoleToString)(otDeviceRole aRole);
extern const char *OT_API_REAL_NAME(otThreadGetDomainName)(otInstance *aInstance);
extern const char *OT_API_REAL_NAME(otThreadGetNetworkName)(otInstance *aInstance);
extern const otExtendedPanId *OT_API_REAL_NAME(otThreadGetExtendedPanId)(otInstance *aInstance);
extern const otIp6Address *OT_API_REAL_NAME(otThreadGetLinkLocalAllThreadNodesMulticastAddress)(otInstance *aInstance);
extern const otIp6Address *OT_API_REAL_NAME(otThreadGetLinkLocalIp6Address)(otInstance *aInstance);
extern const otIp6Address *OT_API_REAL_NAME(otThreadGetMeshLocalEid)(otInstance *aInstance);
extern const otIp6Address *OT_API_REAL_NAME(otThreadGetRealmLocalAllThreadNodesMulticastAddress)(otInstance *aInstance);
extern const otIp6Address *OT_API_REAL_NAME(otThreadGetRloc)(otInstance *aInstance);
extern const otIp6InterfaceIdentifier *OT_API_REAL_NAME(otThreadGetFixedDuaInterfaceIdentifier)(otInstance *aInstance);
extern const otIpCounters *OT_API_REAL_NAME(otThreadGetIp6Counters)(otInstance *aInstance);
extern const otMeshLocalPrefix *OT_API_REAL_NAME(otThreadGetMeshLocalPrefix)(otInstance *aInstance);
extern const otMleCounters *OT_API_REAL_NAME(otThreadGetMleCounters)(otInstance *aInstance);
extern const uint32_t *OT_API_REAL_NAME(otThreadGetTimeInQueueHistogram)(otInstance *aInstance,
uint16_t *aNumBins,
uint32_t *aBinInterval);
extern otDeviceRole OT_API_REAL_NAME(otThreadGetDeviceRole)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadBecomeChild)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadBecomeDetached)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadDetachGracefully)(otInstance *aInstance,
otDetachGracefullyCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otThreadDiscover)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aPanId,
bool aJoiner,
bool aEnableEui64Filtering,
otHandleActiveScanResult aCallback,
void *aCallbackContext);
extern otError OT_API_REAL_NAME(otThreadGetLeaderData)(otInstance *aInstance, otLeaderData *aLeaderData);
extern otError OT_API_REAL_NAME(otThreadGetLeaderRloc)(otInstance *aInstance, otIp6Address *aLeaderRloc);
extern otError OT_API_REAL_NAME(otThreadGetNextNeighborInfo)(otInstance *aInstance,
otNeighborInfoIterator *aIterator,
otNeighborInfo *aInfo);
extern otError OT_API_REAL_NAME(otThreadGetParentAverageRssi)(otInstance *aInstance, int8_t *aParentRssi);
extern otError OT_API_REAL_NAME(otThreadGetParentInfo)(otInstance *aInstance, otRouterInfo *aParentInfo);
extern otError OT_API_REAL_NAME(otThreadGetParentLastRssi)(otInstance *aInstance, int8_t *aLastRssi);
extern otError OT_API_REAL_NAME(otThreadGetServiceAloc)(otInstance *aInstance,
uint8_t aServiceId,
otIp6Address *aServiceAloc);
extern otError OT_API_REAL_NAME(otThreadLocateAnycastDestination)(otInstance *aInstance,
const otIp6Address *aAnycastAddress,
otThreadAnycastLocatorCallback aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otThreadSearchForBetterParent)(otInstance *aInstance);
extern otError OT_API_REAL_NAME(otThreadSendProactiveBackboneNotification)(otInstance *aInstance,
otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid,
uint32_t aTimeSinceLastTransaction);
extern otError OT_API_REAL_NAME(otThreadSetDomainName)(otInstance *aInstance, const char *aDomainName);
extern otError OT_API_REAL_NAME(otThreadSetEnabled)(otInstance *aInstance, bool aEnabled);
extern otError OT_API_REAL_NAME(otThreadSetExtendedPanId)(otInstance *aInstance, const otExtendedPanId *aExtendedPanId);
extern otError OT_API_REAL_NAME(otThreadSetFixedDuaInterfaceIdentifier)(otInstance *aInstance,
const otIp6InterfaceIdentifier *aIid);
extern otError OT_API_REAL_NAME(otThreadSetJoinerAdvertisement)(otInstance *aInstance,
uint32_t aOui,
const uint8_t *aAdvData,
uint8_t aAdvDataLength);
extern otError OT_API_REAL_NAME(otThreadSetLinkMode)(otInstance *aInstance, otLinkModeConfig aConfig);
extern otError OT_API_REAL_NAME(otThreadSetMeshLocalPrefix)(otInstance *aInstance,
const otMeshLocalPrefix *aMeshLocalPrefix);
extern otError OT_API_REAL_NAME(otThreadSetNetworkKey)(otInstance *aInstance, const otNetworkKey *aKey);
extern otError OT_API_REAL_NAME(otThreadSetNetworkKeyRef)(otInstance *aInstance, otNetworkKeyRef aKeyRef);
extern otError OT_API_REAL_NAME(otThreadSetNetworkName)(otInstance *aInstance, const char *aNetworkName);
extern otError OT_API_REAL_NAME(otThreadWakeup)(otInstance *aInstance,
const otExtAddress *aWedAddress,
uint16_t aWakeupIntervalUs,
uint16_t aWakeupDurationMs,
otWakeupCallback aCallback,
void *aCallbackContext);
extern otLinkModeConfig OT_API_REAL_NAME(otThreadGetLinkMode)(otInstance *aInstance);
extern otNetworkKeyRef OT_API_REAL_NAME(otThreadGetNetworkKeyRef)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otThreadGetKeySwitchGuardTime)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otThreadGetRloc16)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otThreadGetVersion)(void);
extern uint32_t OT_API_REAL_NAME(otThreadGetChildTimeout)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetKeySequenceCounter)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetMaxTimeInQueue)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetPartitionId)(otInstance *aInstance);
extern uint32_t OT_API_REAL_NAME(otThreadGetStoreFrameCounterAhead)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetLeaderRouterId)(otInstance *aInstance);
extern uint8_t OT_API_REAL_NAME(otThreadGetLeaderWeight)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otConvertDurationInSecondsToString)(uint32_t aDuration, char *aBuffer, uint16_t aSize);
extern void OT_API_REAL_NAME(otThreadGetNetworkKey)(otInstance *aInstance, otNetworkKey *aNetworkKey);
extern void OT_API_REAL_NAME(otThreadRegisterParentResponseCallback)(otInstance *aInstance,
otThreadParentResponseCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otThreadResetIp6Counters)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otThreadResetMleCounters)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otThreadResetTimeInQueueStat)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otThreadSendAddressNotification)(otInstance *aInstance,
otIp6Address *aDestination,
otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid);
extern void OT_API_REAL_NAME(otThreadSetChildTimeout)(otInstance *aInstance, uint32_t aTimeout);
extern void OT_API_REAL_NAME(otThreadSetDiscoveryRequestCallback)(otInstance *aInstance,
otThreadDiscoveryRequestCallback aCallback,
void *aContext);
extern void OT_API_REAL_NAME(otThreadSetKeySequenceCounter)(otInstance *aInstance, uint32_t aKeySequenceCounter);
extern void OT_API_REAL_NAME(otThreadSetKeySwitchGuardTime)(otInstance *aInstance, uint16_t aKeySwitchGuardTime);
extern void OT_API_REAL_NAME(otThreadSetStoreFrameCounterAhead)(otInstance *aInstance,
uint32_t aStoreFrameCounterAhead);
bool OT_API_WRAPPER_NAME(otThreadIsAnycastLocateInProgress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsAnycastLocateInProgress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otThreadIsDiscoverInProgress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsDiscoverInProgress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otThreadIsSingleton)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otThreadIsSingleton)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadDeviceRoleToString)(otDeviceRole aRole)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadDeviceRoleToString)(aRole);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadGetDomainName)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetDomainName)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const char *OT_API_WRAPPER_NAME(otThreadGetNetworkName)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const char *ret = OT_API_REAL_NAME(otThreadGetNetworkName)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otExtendedPanId *OT_API_WRAPPER_NAME(otThreadGetExtendedPanId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otExtendedPanId *ret = OT_API_REAL_NAME(otThreadGetExtendedPanId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otThreadGetLinkLocalAllThreadNodesMulticastAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otThreadGetLinkLocalAllThreadNodesMulticastAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otThreadGetLinkLocalIp6Address)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otThreadGetLinkLocalIp6Address)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otThreadGetMeshLocalEid)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otThreadGetMeshLocalEid)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otThreadGetRealmLocalAllThreadNodesMulticastAddress)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otThreadGetRealmLocalAllThreadNodesMulticastAddress)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6Address *OT_API_WRAPPER_NAME(otThreadGetRloc)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6Address *ret = OT_API_REAL_NAME(otThreadGetRloc)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIp6InterfaceIdentifier *OT_API_WRAPPER_NAME(otThreadGetFixedDuaInterfaceIdentifier)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIp6InterfaceIdentifier *ret = OT_API_REAL_NAME(otThreadGetFixedDuaInterfaceIdentifier)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otIpCounters *OT_API_WRAPPER_NAME(otThreadGetIp6Counters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otIpCounters *ret = OT_API_REAL_NAME(otThreadGetIp6Counters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otMeshLocalPrefix *OT_API_WRAPPER_NAME(otThreadGetMeshLocalPrefix)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otMeshLocalPrefix *ret = OT_API_REAL_NAME(otThreadGetMeshLocalPrefix)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otMleCounters *OT_API_WRAPPER_NAME(otThreadGetMleCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otMleCounters *ret = OT_API_REAL_NAME(otThreadGetMleCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const uint32_t *OT_API_WRAPPER_NAME(otThreadGetTimeInQueueHistogram)(otInstance *aInstance,
uint16_t *aNumBins,
uint32_t *aBinInterval)
{
sl_ot_rtos_acquire_stack_mutex();
const uint32_t *ret = OT_API_REAL_NAME(otThreadGetTimeInQueueHistogram)(aInstance, aNumBins, aBinInterval);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otDeviceRole OT_API_WRAPPER_NAME(otThreadGetDeviceRole)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otDeviceRole ret = OT_API_REAL_NAME(otThreadGetDeviceRole)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadBecomeChild)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadBecomeChild)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadBecomeDetached)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadBecomeDetached)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadDetachGracefully)(otInstance *aInstance,
otDetachGracefullyCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadDetachGracefully)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadDiscover)(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aPanId,
bool aJoiner,
bool aEnableEui64Filtering,
otHandleActiveScanResult aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadDiscover)(aInstance,
aScanChannels,
aPanId,
aJoiner,
aEnableEui64Filtering,
aCallback,
aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetLeaderData)(otInstance *aInstance, otLeaderData *aLeaderData)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetLeaderData)(aInstance, aLeaderData);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetLeaderRloc)(otInstance *aInstance, otIp6Address *aLeaderRloc)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetLeaderRloc)(aInstance, aLeaderRloc);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetNextNeighborInfo)(otInstance *aInstance,
otNeighborInfoIterator *aIterator,
otNeighborInfo *aInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetNextNeighborInfo)(aInstance, aIterator, aInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetParentAverageRssi)(otInstance *aInstance, int8_t *aParentRssi)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetParentAverageRssi)(aInstance, aParentRssi);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetParentInfo)(otInstance *aInstance, otRouterInfo *aParentInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetParentInfo)(aInstance, aParentInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetParentLastRssi)(otInstance *aInstance, int8_t *aLastRssi)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetParentLastRssi)(aInstance, aLastRssi);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadGetServiceAloc)(otInstance *aInstance,
uint8_t aServiceId,
otIp6Address *aServiceAloc)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadGetServiceAloc)(aInstance, aServiceId, aServiceAloc);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadLocateAnycastDestination)(otInstance *aInstance,
const otIp6Address *aAnycastAddress,
otThreadAnycastLocatorCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadLocateAnycastDestination)(aInstance, aAnycastAddress, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSearchForBetterParent)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSearchForBetterParent)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSendProactiveBackboneNotification)(otInstance *aInstance,
otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid,
uint32_t aTimeSinceLastTransaction)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otThreadSendProactiveBackboneNotification)(aInstance, aTarget, aMlIid, aTimeSinceLastTransaction);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetDomainName)(otInstance *aInstance, const char *aDomainName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetDomainName)(aInstance, aDomainName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetEnabled)(otInstance *aInstance, bool aEnabled)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetEnabled)(aInstance, aEnabled);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetExtendedPanId)(otInstance *aInstance, const otExtendedPanId *aExtendedPanId)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetExtendedPanId)(aInstance, aExtendedPanId);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetFixedDuaInterfaceIdentifier)(otInstance *aInstance,
const otIp6InterfaceIdentifier *aIid)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetFixedDuaInterfaceIdentifier)(aInstance, aIid);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetJoinerAdvertisement)(otInstance *aInstance,
uint32_t aOui,
const uint8_t *aAdvData,
uint8_t aAdvDataLength)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetJoinerAdvertisement)(aInstance, aOui, aAdvData, aAdvDataLength);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetLinkMode)(otInstance *aInstance, otLinkModeConfig aConfig)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetLinkMode)(aInstance, aConfig);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetMeshLocalPrefix)(otInstance *aInstance,
const otMeshLocalPrefix *aMeshLocalPrefix)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetMeshLocalPrefix)(aInstance, aMeshLocalPrefix);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetNetworkKey)(otInstance *aInstance, const otNetworkKey *aKey)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetNetworkKey)(aInstance, aKey);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetNetworkKeyRef)(otInstance *aInstance, otNetworkKeyRef aKeyRef)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetNetworkKeyRef)(aInstance, aKeyRef);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadSetNetworkName)(otInstance *aInstance, const char *aNetworkName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otThreadSetNetworkName)(aInstance, aNetworkName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otThreadWakeup)(otInstance *aInstance,
const otExtAddress *aWedAddress,
uint16_t aWakeupIntervalUs,
uint16_t aWakeupDurationMs,
otWakeupCallback aCallback,
void *aCallbackContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(
otThreadWakeup)(aInstance, aWedAddress, aWakeupIntervalUs, aWakeupDurationMs, aCallback, aCallbackContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otLinkModeConfig OT_API_WRAPPER_NAME(otThreadGetLinkMode)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otLinkModeConfig ret = OT_API_REAL_NAME(otThreadGetLinkMode)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otNetworkKeyRef OT_API_WRAPPER_NAME(otThreadGetNetworkKeyRef)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otNetworkKeyRef ret = OT_API_REAL_NAME(otThreadGetNetworkKeyRef)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otThreadGetKeySwitchGuardTime)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otThreadGetKeySwitchGuardTime)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otThreadGetRloc16)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otThreadGetRloc16)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otThreadGetVersion)(void)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otThreadGetVersion)();
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetChildTimeout)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetChildTimeout)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetKeySequenceCounter)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetKeySequenceCounter)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetMaxTimeInQueue)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetMaxTimeInQueue)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetPartitionId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetPartitionId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint32_t OT_API_WRAPPER_NAME(otThreadGetStoreFrameCounterAhead)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint32_t ret = OT_API_REAL_NAME(otThreadGetStoreFrameCounterAhead)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetLeaderRouterId)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetLeaderRouterId)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint8_t OT_API_WRAPPER_NAME(otThreadGetLeaderWeight)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint8_t ret = OT_API_REAL_NAME(otThreadGetLeaderWeight)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otConvertDurationInSecondsToString)(uint32_t aDuration, char *aBuffer, uint16_t aSize)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otConvertDurationInSecondsToString)(aDuration, aBuffer, aSize);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadGetNetworkKey)(otInstance *aInstance, otNetworkKey *aNetworkKey)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadGetNetworkKey)(aInstance, aNetworkKey);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadRegisterParentResponseCallback)(otInstance *aInstance,
otThreadParentResponseCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadRegisterParentResponseCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadResetIp6Counters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadResetIp6Counters)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadResetMleCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadResetMleCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadResetTimeInQueueStat)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadResetTimeInQueueStat)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSendAddressNotification)(otInstance *aInstance,
otIp6Address *aDestination,
otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSendAddressNotification)(aInstance, aDestination, aTarget, aMlIid);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetChildTimeout)(otInstance *aInstance, uint32_t aTimeout)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetChildTimeout)(aInstance, aTimeout);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetDiscoveryRequestCallback)(otInstance *aInstance,
otThreadDiscoveryRequestCallback aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetDiscoveryRequestCallback)(aInstance, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetKeySequenceCounter)(otInstance *aInstance, uint32_t aKeySequenceCounter)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetKeySequenceCounter)(aInstance, aKeySequenceCounter);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetKeySwitchGuardTime)(otInstance *aInstance, uint16_t aKeySwitchGuardTime)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetKeySwitchGuardTime)(aInstance, aKeySwitchGuardTime);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otThreadSetStoreFrameCounterAhead)(otInstance *aInstance, uint32_t aStoreFrameCounterAhead)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otThreadSetStoreFrameCounterAhead)(aInstance, aStoreFrameCounterAhead);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,134 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Trel APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/trel.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otTrelIsEnabled)(otInstance *aInstance);
extern bool OT_API_REAL_NAME(otTrelIsFilterEnabled)(otInstance *aInstance);
extern const otTrelCounters *OT_API_REAL_NAME(otTrelGetCounters)(otInstance *aInstance);
extern const otTrelPeer *OT_API_REAL_NAME(otTrelGetNextPeer)(otInstance *aInstance, otTrelPeerIterator *aIterator);
extern uint16_t OT_API_REAL_NAME(otTrelGetNumberOfPeers)(otInstance *aInstance);
extern uint16_t OT_API_REAL_NAME(otTrelGetUdpPort)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otTrelInitPeerIterator)(otInstance *aInstance, otTrelPeerIterator *aIterator);
extern void OT_API_REAL_NAME(otTrelResetCounters)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otTrelSetEnabled)(otInstance *aInstance, bool aEnable);
extern void OT_API_REAL_NAME(otTrelSetFilterEnabled)(otInstance *aInstance, bool aEnable);
bool OT_API_WRAPPER_NAME(otTrelIsEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otTrelIsEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otTrelIsFilterEnabled)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otTrelIsFilterEnabled)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otTrelCounters *OT_API_WRAPPER_NAME(otTrelGetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
const otTrelCounters *ret = OT_API_REAL_NAME(otTrelGetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
const otTrelPeer *OT_API_WRAPPER_NAME(otTrelGetNextPeer)(otInstance *aInstance, otTrelPeerIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
const otTrelPeer *ret = OT_API_REAL_NAME(otTrelGetNextPeer)(aInstance, aIterator);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otTrelGetNumberOfPeers)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otTrelGetNumberOfPeers)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
uint16_t OT_API_WRAPPER_NAME(otTrelGetUdpPort)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
uint16_t ret = OT_API_REAL_NAME(otTrelGetUdpPort)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otTrelInitPeerIterator)(otInstance *aInstance, otTrelPeerIterator *aIterator)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTrelInitPeerIterator)(aInstance, aIterator);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otTrelResetCounters)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTrelResetCounters)(aInstance);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otTrelSetEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTrelSetEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otTrelSetFilterEnabled)(otInstance *aInstance, bool aEnable)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otTrelSetFilterEnabled)(aInstance, aEnable);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,202 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Udp APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/udp.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern bool OT_API_REAL_NAME(otUdpIsOpen)(otInstance *aInstance, const otUdpSocket *aSocket);
extern bool OT_API_REAL_NAME(otUdpIsPortInUse)(otInstance *aInstance, uint16_t port);
extern otError OT_API_REAL_NAME(otUdpAddReceiver)(otInstance *aInstance, otUdpReceiver *aUdpReceiver);
extern otError OT_API_REAL_NAME(otUdpBind)(otInstance *aInstance,
otUdpSocket *aSocket,
const otSockAddr *aSockName,
otNetifIdentifier aNetif);
extern otError OT_API_REAL_NAME(otUdpClose)(otInstance *aInstance, otUdpSocket *aSocket);
extern otError OT_API_REAL_NAME(otUdpConnect)(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName);
extern otError OT_API_REAL_NAME(otUdpOpen)(otInstance *aInstance,
otUdpSocket *aSocket,
otUdpReceive aCallback,
void *aContext);
extern otError OT_API_REAL_NAME(otUdpRemoveReceiver)(otInstance *aInstance, otUdpReceiver *aUdpReceiver);
extern otError OT_API_REAL_NAME(otUdpSend)(otInstance *aInstance,
otUdpSocket *aSocket,
otMessage *aMessage,
const otMessageInfo *aMessageInfo);
extern otError OT_API_REAL_NAME(otUdpSendDatagram)(otInstance *aInstance,
otMessage *aMessage,
otMessageInfo *aMessageInfo);
extern otMessage *OT_API_REAL_NAME(otUdpNewMessage)(otInstance *aInstance, const otMessageSettings *aSettings);
extern otUdpSocket *OT_API_REAL_NAME(otUdpGetSockets)(otInstance *aInstance);
extern void OT_API_REAL_NAME(otUdpForwardReceive)(otInstance *aInstance,
otMessage *aMessage,
uint16_t aPeerPort,
const otIp6Address *aPeerAddr,
uint16_t aSockPort);
extern void OT_API_REAL_NAME(otUdpForwardSetForwarder)(otInstance *aInstance,
otUdpForwarder aForwarder,
void *aContext);
bool OT_API_WRAPPER_NAME(otUdpIsOpen)(otInstance *aInstance, const otUdpSocket *aSocket)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otUdpIsOpen)(aInstance, aSocket);
sl_ot_rtos_release_stack_mutex();
return ret;
}
bool OT_API_WRAPPER_NAME(otUdpIsPortInUse)(otInstance *aInstance, uint16_t port)
{
sl_ot_rtos_acquire_stack_mutex();
bool ret = OT_API_REAL_NAME(otUdpIsPortInUse)(aInstance, port);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpAddReceiver)(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpAddReceiver)(aInstance, aUdpReceiver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpBind)(otInstance *aInstance,
otUdpSocket *aSocket,
const otSockAddr *aSockName,
otNetifIdentifier aNetif)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpBind)(aInstance, aSocket, aSockName, aNetif);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpClose)(otInstance *aInstance, otUdpSocket *aSocket)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpClose)(aInstance, aSocket);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpConnect)(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpConnect)(aInstance, aSocket, aSockName);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpOpen)(otInstance *aInstance,
otUdpSocket *aSocket,
otUdpReceive aCallback,
void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpOpen)(aInstance, aSocket, aCallback, aContext);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpRemoveReceiver)(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpRemoveReceiver)(aInstance, aUdpReceiver);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpSend)(otInstance *aInstance,
otUdpSocket *aSocket,
otMessage *aMessage,
const otMessageInfo *aMessageInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpSend)(aInstance, aSocket, aMessage, aMessageInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otUdpSendDatagram)(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otUdpSendDatagram)(aInstance, aMessage, aMessageInfo);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otMessage *OT_API_WRAPPER_NAME(otUdpNewMessage)(otInstance *aInstance, const otMessageSettings *aSettings)
{
sl_ot_rtos_acquire_stack_mutex();
otMessage *ret = OT_API_REAL_NAME(otUdpNewMessage)(aInstance, aSettings);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otUdpSocket *OT_API_WRAPPER_NAME(otUdpGetSockets)(otInstance *aInstance)
{
sl_ot_rtos_acquire_stack_mutex();
otUdpSocket *ret = OT_API_REAL_NAME(otUdpGetSockets)(aInstance);
sl_ot_rtos_release_stack_mutex();
return ret;
}
void OT_API_WRAPPER_NAME(otUdpForwardReceive)(otInstance *aInstance,
otMessage *aMessage,
uint16_t aPeerPort,
const otIp6Address *aPeerAddr,
uint16_t aSockPort)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otUdpForwardReceive)(aInstance, aMessage, aPeerPort, aPeerAddr, aSockPort);
sl_ot_rtos_release_stack_mutex();
}
void OT_API_WRAPPER_NAME(otUdpForwardSetForwarder)(otInstance *aInstance, otUdpForwarder aForwarder, void *aContext)
{
sl_ot_rtos_acquire_stack_mutex();
OT_API_REAL_NAME(otUdpForwardSetForwarder)(aInstance, aForwarder, aContext);
sl_ot_rtos_release_stack_mutex();
}

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
* @file
* @brief OpenThread wrapper functions for OpenThread Verhoeff Checksum APIs
* allowing access to the thread stack in a multi-threaded environment.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_ot_rtos_adaptation.h"
#include <openthread/verhoeff_checksum.h>
#if defined(__GNUC__)
#define REAL_NAME(function) __real_##function
#define WRAPPER_NAME(function) __wrap_##function
#define OT_API_REAL_NAME(function) REAL_NAME(function)
#define OT_API_WRAPPER_NAME(function) WRAPPER_NAME(function)
// #elif defined(__IAR_SYSTEMS_ICC__)
// #define REAL_NAME(function) $Super$$##function
// #define WRAPPER_NAME(function) $Sub$$##function
// #define OT_API_REAL_NAME(function) $Super$$__iar_dl##function
// #define OT_API_WRAPPER_NAME(function) $Sub$$__iar_dl##function
#else
#error Unsupported compiler
#endif
extern otError OT_API_REAL_NAME(otVerhoeffChecksumCalculate)(const char *aDecimalString, char *aChecksum);
extern otError OT_API_REAL_NAME(otVerhoeffChecksumValidate)(const char *aDecimalString);
otError OT_API_WRAPPER_NAME(otVerhoeffChecksumCalculate)(const char *aDecimalString, char *aChecksum)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otVerhoeffChecksumCalculate)(aDecimalString, aChecksum);
sl_ot_rtos_release_stack_mutex();
return ret;
}
otError OT_API_WRAPPER_NAME(otVerhoeffChecksumValidate)(const char *aDecimalString)
{
sl_ot_rtos_acquire_stack_mutex();
otError ret = OT_API_REAL_NAME(otVerhoeffChecksumValidate)(aDecimalString);
sl_ot_rtos_release_stack_mutex();
return ret;
}

View File

@@ -0,0 +1,354 @@
/*******************************************************************************
* @file
* @brief CMSIS RTOS2 adaptation for running OpenThread in RTOS
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <openthread-core-config.h>
#include <openthread-system.h>
#include <openthread/tasklet.h>
#include <openthread/platform/time.h>
#include <openthread/platform/toolchain.h>
#include <mbedtls/platform.h>
#include "cmsis_os2.h"
#include "platform-efr32.h"
#include "sl_cmsis_os2_common.h"
#include "sl_component_catalog.h"
#include "sl_openthread_rtos_config.h"
#include "sl_ot_init.h"
#include "sl_ot_rtos_adaptation.h"
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sleep.h"
#endif
// Structure defining task information
typedef struct sl_ot_rtos_thread_t
{
osThreadId_t id; // Task ID
osSemaphoreId_t semaphore; // Task wake semaphore
volatile sl_ot_rtos_event_t events; // Task specific flags, to notify about the pending event
uint64_t active_duration; // Tracking the active duration of the stacks.
} sl_ot_rtos_thread_t;
/* OT main stack task specific settings */
static sl_ot_rtos_thread_t sli_ot_stack_task_info;
__ALIGNED(8) static uint8_t sli_ot_stack_task_mem[SL_OPENTHREAD_STACK_TASK_MEM_SIZE];
__ALIGNED(4) static uint8_t sli_ot_stack_task_cb[osThreadCbSize];
static void sli_ot_stack_task(void *aContext);
static const osThreadAttr_t sli_ot_stack_task_attr = {
.name = "OT Stack",
.attr_bits = 0u,
.stack_size = SL_OPENTHREAD_STACK_TASK_MEM_SIZE,
.stack_mem = sli_ot_stack_task_mem,
.cb_mem = sli_ot_stack_task_cb,
.cb_size = osThreadCbSize,
.priority = (osPriority_t)SL_OPENTHREAD_RTOS_STACK_TASK_PRIORITY,
};
static const osSemaphoreAttr_t sli_ot_stack_semaphore_attr = {.name = "OT Stack Semaphore"};
/* OT app task specific settings */
#if SL_OPENTHREAD_ENABLE_APP_TASK
static sl_ot_rtos_thread_t sli_ot_app_task_info;
__ALIGNED(8) static uint8_t sli_ot_app_task_mem[SL_OPENTHREAD_APP_TASK_MEM_SIZE];
__ALIGNED(4) static uint8_t sli_ot_app_task_cb[osThreadCbSize];
static void sli_ot_app_task(void *aContext);
static const osThreadAttr_t sli_ot_app_task_attr = {
.name = "OT App",
.attr_bits = 0u,
.stack_size = SL_OPENTHREAD_APP_TASK_MEM_SIZE,
.stack_mem = sli_ot_app_task_mem,
.cb_mem = sli_ot_app_task_cb,
.cb_size = osThreadCbSize,
.priority = (osPriority_t)SL_OPENTHREAD_RTOS_APP_TASK_PRIORITY,
};
static const osSemaphoreAttr_t sli_ot_app_semaphore_attr = {.name = "OT App Semaphore"};
#endif
/* OT Serial Task specific settings */
#if SL_OPENTHREAD_ENABLE_SERIAL_TASK
static sl_ot_rtos_thread_t sli_ot_serial_task_info;
__ALIGNED(8) static uint8_t sli_ot_serial_task_mem[SL_OPENTHREAD_SERIAL_TASK_MEM_SIZE];
__ALIGNED(4) static uint8_t sli_ot_serial_task_cb[osThreadCbSize];
static void sli_ot_serial_task(void *aContext);
static const osThreadAttr_t sli_ot_serial_task_attr = {
.name = "OT Serial",
.attr_bits = 0u,
.stack_size = SL_OPENTHREAD_SERIAL_TASK_MEM_SIZE,
.stack_mem = sli_ot_serial_task_mem,
.cb_mem = sli_ot_serial_task_cb,
.cb_size = osThreadCbSize,
.priority = (osPriority_t)SL_OPENTHREAD_RTOS_SERIAL_TASK_PRIORITY,
};
static const osSemaphoreAttr_t sli_ot_serial_semaphore_attr = {.name = "OT Serial Semaphore"};
#endif // SL_OPENTHREAD_ENABLE_SERIAL_TASK
osMutexId_t sli_ot_stack_mutex;
static const osMutexAttr_t sli_stack_mutex_attributes = {
.name = "OT Stack Mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit,
};
otInstance *otGetInstance(void);
// Create the main task mutex. This mutex will be used to grant access to stack.
static void sl_ot_rtos_create_stack_mutex(void)
{
sli_ot_stack_mutex = osMutexNew(&sli_stack_mutex_attributes);
EFM_ASSERT(sli_ot_stack_mutex != NULL);
}
// Helper function to create a task and a semaphore that can be used to wake the task
static void sl_ot_rtos_stack_create(sl_ot_rtos_thread_t *task_info,
const osThreadFunc_t task_handler,
const osThreadAttr_t *task_attributes,
const osSemaphoreAttr_t *semaphore_attributes)
{
static const uint32_t MAX_SEMAPHORE_COUNT = 1;
static const uint32_t INITIAL_SEMAPHORE_COUNT = 0;
task_info->events = 0;
task_info->semaphore = osSemaphoreNew(MAX_SEMAPHORE_COUNT, INITIAL_SEMAPHORE_COUNT, semaphore_attributes);
task_info->id = osThreadNew(*task_handler, NULL, task_attributes);
}
// Wait loop for tasks. We acquire the task semaphore and acquire the semaphore and external events can
// Wake the task by setting the event flag and releasing the task semaphore.
static sl_ot_rtos_event_t sl_ot_rtos_wait_for_event(sl_ot_rtos_thread_t *task_info, sl_ot_rtos_event_t event)
{
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
sl_ot_sleep_update();
#endif
sl_ot_rtos_event_t accessible_events = task_info->events & event;
while (accessible_events == 0)
{
(void)osSemaphoreAcquire(task_info->semaphore, osWaitForever);
accessible_events = task_info->events & event;
}
task_info->events &= ~accessible_events;
return accessible_events;
}
// Helper function to set the event flag for the task for notification
static void sl_ot_rtos_set_event_flag(sl_ot_rtos_thread_t *task_info, sl_ot_rtos_event_t event)
{
task_info->events |= event;
(void)osSemaphoreRelease(task_info->semaphore);
}
// Initialize the stack task.
void sl_ot_rtos_stack_init(void)
{
// Create main stack task for operation..
sl_ot_rtos_stack_create(&sli_ot_stack_task_info,
sli_ot_stack_task,
&sli_ot_stack_task_attr,
&sli_ot_stack_semaphore_attr);
#if SL_OPENTHREAD_ENABLE_SERIAL_TASK
// If the Serial Task is needed, create one..
sl_ot_rtos_stack_create(&sli_ot_serial_task_info,
sli_ot_serial_task,
&sli_ot_serial_task_attr,
&sli_ot_serial_semaphore_attr);
#endif
// Create the main stack mutex. This mutex will be used to request access for stack.
sl_ot_rtos_create_stack_mutex();
// Handling OpenThread initialization here
// ensures that, any functions calling mbedTLS API
// (and subsequently OSMutexPend), are called after the kernel has started.
sl_ot_init();
}
// If the default app task is needed, create one..
void sl_ot_rtos_app_init(void)
{
#if SL_OPENTHREAD_ENABLE_APP_TASK
sl_ot_rtos_stack_create(&sli_ot_app_task_info, sli_ot_app_task, &sli_ot_app_task_attr, &sli_ot_app_semaphore_attr);
#endif
}
void sl_ot_rtos_set_pending_event(sl_ot_rtos_event_t event)
{
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
sl_ot_sleep_update();
#endif
#if SL_OPENTHREAD_ENABLE_SERIAL_TASK
if (event & SL_OT_RTOS_EVENT_SERIAL)
{
// If SL_OT_RTOS_EVENT_SERIAL is raised, set the event flag for the Serial Task.
sl_ot_rtos_set_event_flag(&sli_ot_serial_task_info, event);
}
#endif
#if SL_OPENTHREAD_ENABLE_APP_TASK
if (event & SL_OT_RTOS_EVENT_APP)
{
// If SL_OT_RTOS_EVENT_APP is raised, set the event flag for app task.
sl_ot_rtos_set_event_flag(&sli_ot_app_task_info, event);
sl_ot_rtos_set_event_flag(&sli_ot_stack_task_info, event);
}
#endif
if (event & SL_OT_RTOS_EVENT_STACK)
{
// If SL_OT_RTOS_EVENT_STACK is raised, set the event flag for stack task.
sl_ot_rtos_set_event_flag(&sli_ot_stack_task_info, event);
}
}
static void sli_ot_stack_task(void *context)
{
OT_UNUSED_VARIABLE(context);
#if defined(SL_CATALOG_OT_CRASH_HANDLER_PRESENT)
efr32PrintResetInfo();
#endif
// Get the OT instance for stack operation
otInstance *instance = otGetInstance();
while (!otSysPseudoResetWasRequested())
{
uint64_t timestamp = otPlatTimeGet();
// Acquire mutex for stack access
sl_ot_rtos_acquire_stack_mutex();
// Process callbacks and tasklets
otSysProcessDrivers(instance);
otTaskletsProcess(instance);
// Release the stack mutex
sl_ot_rtos_release_stack_mutex();
if (!otTaskletsArePending(instance))
{
sli_ot_stack_task_info.active_duration += otPlatTimeGet() - timestamp;
// If tasklets are not pending, wait for stack event..
(void)sl_ot_rtos_wait_for_event(&sli_ot_stack_task_info, SL_OT_RTOS_EVENT_STACK);
}
}
// If Reset was requested, finalize OT and terminate the thread..
otInstanceFinalize(instance);
osThreadTerminate(sli_ot_stack_task_info.id);
}
#if SL_OPENTHREAD_ENABLE_APP_TASK
static void sli_ot_app_task(void *context)
{
OT_UNUSED_VARIABLE(context);
while (!otSysPseudoResetWasRequested())
{
uint64_t timestamp = otPlatTimeGet();
// Give a tick to application..
sl_ot_rtos_application_tick();
sli_ot_app_task_info.active_duration += otPlatTimeGet() - timestamp;
// Wait for the app event..
(void)sl_ot_rtos_wait_for_event(&sli_ot_app_task_info, SL_OT_RTOS_EVENT_APP);
}
// If reset is requested terminate the app task..
osThreadTerminate(sli_ot_app_task_info.id);
}
#endif // SL_OPENTHREAD_ENABLE_APP_TASK
#if SL_OPENTHREAD_ENABLE_SERIAL_TASK
static void sli_ot_serial_task(void *aContext)
{
(void)aContext;
while (1)
{
uint64_t timestamp = otPlatTimeGet();
// Process serial events. We acquire stack mutex here because, we will be accessing
// the stack to provide serial callbacks. As these are platform level callbacks, it
// must be in stack context.
sl_ot_rtos_acquire_stack_mutex();
efr32SerialProcess();
sl_ot_rtos_release_stack_mutex();
sli_ot_serial_task_info.active_duration += otPlatTimeGet() - timestamp;
// Wait for the serial event..
(void)sl_ot_rtos_wait_for_event(&sli_ot_serial_task_info, SL_OT_RTOS_EVENT_SERIAL);
}
}
#endif
void otTaskletsSignalPending(otInstance *aInstance)
{
(void)aInstance;
sl_ot_rtos_set_pending_event(SL_OT_RTOS_EVENT_STACK);
}
void otSysEventSignalPending(void)
{
sl_ot_rtos_set_pending_event(SL_OT_RTOS_EVENT_STACK);
}
bool sl_ot_rtos_task_can_access_pal(void)
{
// ToDo: Address the PAL lock by changing the order of stack initialization
return true;
}
OT_TOOL_WEAK void sl_ot_rtos_application_tick(void)
{
}
OT_TOOL_WEAK void sl_ot_rtos_acquire_stack_mutex(void)
{
osStatus_t error = osMutexAcquire(sli_ot_stack_mutex, osWaitForever);
OT_UNUSED_VARIABLE(error);
}
OT_TOOL_WEAK void sl_ot_rtos_release_stack_mutex(void)
{
osStatus_t error = osMutexRelease(sli_ot_stack_mutex);
OT_UNUSED_VARIABLE(error);
}
OT_TOOL_WEAK bool sl_ot_rtos_try_acquire_stack_mutex(void)
{
osStatus_t error = osMutexAcquire(sli_ot_stack_mutex, 0);
return (error == osOK);
}

View File

@@ -0,0 +1,114 @@
/*******************************************************************************
* @file
* @brief CMSIS RTOS2 adaptation for running OpenThread in RTOS
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef OPENTHREAD_RTOS
#define OPENTHREAD_RTOS
#include <stdbool.h>
typedef enum sl_ot_rtos_event_t
{
SL_OT_RTOS_EVENT_STACK = 1 << 0,
SL_OT_RTOS_EVENT_SERIAL = 1 << 1,
SL_OT_RTOS_EVENT_APP = 1 << 2
} sl_ot_rtos_event_t;
/**
* API to initialize RTOS 'OT Stack' and 'OT Serial' Tasks.
*
* Calling this API results in the 'OT Stack' and 'OT Serial' tasks being
* created. 'OT Serial' task creation is controlled by the config item
* @p SL_OPENTHREAD_ENABLE_SERIAL_TASK. This is enabled by default.
*
*/
void sl_ot_rtos_stack_init(void);
/**
* API to initialize RTOS App task.
*
* Calling this API results in app task being created. based on the config item
* @p SL_OPENTHREAD_ENABLE_APP_TASK.
*
* This is enabled by default.
*
*/
void sl_ot_rtos_app_init(void);
/**
* Pend an event to a task based on the event received.
*
* Based on the event received as input pend one of the tasks for operation
*
* @param[in] event Type of event received, can take the values indicated in @p sl_ot_rtos_event_t
*
*/
void sl_ot_rtos_set_pending_event(sl_ot_rtos_event_t event);
/**
* RTOS tick for application. Will be called anytime app task is running.
*/
void sl_ot_rtos_application_tick(void);
/**
* Mutex handler, API to obtain access to the stack.
*
* A weak implementation is provided, user can implement their own mutex handlers.
*
*/
void sl_ot_rtos_acquire_stack_mutex(void);
/**
* Mutex handler, API to relinquish access to the stack.
*
* A weak implementation is provided, user can implement their own mutex handlers.
*
*/
void sl_ot_rtos_release_stack_mutex(void);
/**
* Mutex handler, API to try to obtain access to the stack.
*
* Return true if access granted, false otherwise.
*
* A weak implementation is provided, user can implement their own mutex handlers.
*
*/
bool sl_ot_rtos_try_acquire_stack_mutex(void);
/**
* Return if the current thread can access the PAL APIs.
*
* @retval True Current thread can access the PAL APIs.
* @retval False Current thread cannot access the PAL APIs.
*
*/
bool sl_ot_rtos_task_can_access_pal(void);
#endif