[instance-locator] use instance reference instead of pointer (#2007)

This commit changes the `InstanceLocator` class to keep track of a
reference to `otInstance` (instead of a pointer) to make it behave
similar to other `ObjectLocator` classes. The method `GetInstance()`
in all locator objects is updated to provide a reference (instead
of a pointer) to `otInstance`.

The logging macros are updated such that a reference to `otInstance`
is passed as the first argument (with the exception of
`otLog<Level>Plat()` macros which are used by platform code in C
domain). The documentation for log macros are also updated.
This commit is contained in:
Abtin Keshavarzian
2017-07-25 15:06:14 -07:00
committed by Jonathan Hui
parent ea73c92151
commit fc72e4e719
36 changed files with 657 additions and 563 deletions
+56 -56
View File
@@ -157,236 +157,236 @@
// ==API==
// begin_wpp config
// USEPREFIX (otLogCritApi, "[%p]API%!SPACE!", CTX);
// USEPREFIX (otLogCritApi, "[%p]API%!SPACE!", &CTX);
// otLogCritApi{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_API}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnApi, "[%p]API%!SPACE!", CTX);
// USEPREFIX (otLogWarnApi, "[%p]API%!SPACE!", &CTX);
// otLogWarnApi{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_API}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoApi, "[%p]API%!SPACE!", CTX);
// USEPREFIX (otLogInfoApi, "[%p]API%!SPACE!", &CTX);
// otLogInfoApi{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_API}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgApi, "[%p]API%!SPACE!", CTX);
// USEPREFIX (otLogDebgApi, "[%p]API%!SPACE!", &CTX);
// otLogDebgApi{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_API}(CTX, MSG, ...);
// end_wpp
// ==NCP==
// begin_wpp config
// USEPREFIX (otLogCritNcp, "[%p]NCP%!SPACE!", CTX);
// USEPREFIX (otLogCritNcp, "[%p]NCP%!SPACE!", &CTX);
// otLogCritNcp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NCP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnNcp, "[%p]NCP%!SPACE!", CTX);
// USEPREFIX (otLogWarnNcp, "[%p]NCP%!SPACE!", &CTX);
// otLogWarnNcp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NCP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoNcp, "[%p]NCP%!SPACE!", CTX);
// USEPREFIX (otLogInfoNcp, "[%p]NCP%!SPACE!", &CTX);
// otLogInfoNcp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NCP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgNcp, "[%p]NCP%!SPACE!", CTX);
// USEPREFIX (otLogDebgNcp, "[%p]NCP%!SPACE!", &CTX);
// otLogDebgNcp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NCP}(CTX, MSG, ...);
// end_wpp
// ==MESHCOP==
// begin_wpp config
// USEPREFIX (otLogCritMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// USEPREFIX (otLogCritMeshCoP, "[%p]MESHCOP%!SPACE!", &CTX);
// otLogCritMeshCoP{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// USEPREFIX (otLogWarnMeshCoP, "[%p]MESHCOP%!SPACE!", &CTX);
// otLogWarnMeshCoP{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// USEPREFIX (otLogInfoMeshCoP, "[%p]MESHCOP%!SPACE!", &CTX);
// otLogInfoMeshCoP{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// USEPREFIX (otLogDebgMeshCoP, "[%p]MESHCOP%!SPACE!", &CTX);
// otLogDebgMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogCertMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// USEPREFIX (otLogCertMeshCoP, "[%p]MESHCOP%!SPACE!", &CTX);
// otLogCertMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// ==MBEDTLS==
// begin_wpp config
// USEPREFIX (otLogCritMbedTls, "[%p]MBED%!SPACE!", CTX);
// USEPREFIX (otLogCritMbedTls, "[%p]MBED%!SPACE!", &CTX);
// otLogCritMbedTls{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MBEDTLS}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMbedTls, "[%p]MBED%!SPACE!", CTX);
// USEPREFIX (otLogWarnMbedTls, "[%p]MBED%!SPACE!", &CTX);
// otLogWarnMbedTls{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MBEDTLS}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMbedTls, "[%p]MBED%!SPACE!", CTX);
// USEPREFIX (otLogInfoMbedTls, "[%p]MBED%!SPACE!", &CTX);
// otLogInfoMbedTls{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MBEDTLS}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMbedTls, "[%p]MBED%!SPACE!", CTX);
// USEPREFIX (otLogDebgMbedTls, "[%p]MBED%!SPACE!", &CTX);
// otLogDebgMbedTls{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MBEDTLS}(CTX, MSG, ...);
// end_wpp
// ==MLE==
// begin_wpp config
// USEPREFIX (otLogCritMle, "[%p]MLE%!SPACE!", CTX);
// USEPREFIX (otLogCritMle, "[%p]MLE%!SPACE!", &CTX);
// otLogCritMle{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MLE}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMle, "[%p]MLE%!SPACE!", CTX);
// USEPREFIX (otLogWarnMle, "[%p]MLE%!SPACE!", &CTX);
// otLogWarnMle{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MLE}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMleErr, "[%p]MLE%!SPACE!", CTX);
// USEPREFIX (otLogWarnMleErr, "[%p]MLE%!SPACE!", &CTX);
// otLogWarnMleErr{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MLE}(CTX, EXP, MSG, ...);
// USESUFFIX(otLogWarnMleErr, ", %!otError!", EXP);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMle, "[%p]MLE%!SPACE!", CTX);
// USEPREFIX (otLogInfoMle, "[%p]MLE%!SPACE!", &CTX);
// otLogInfoMle{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MLE}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMle, "[%p]MLE%!SPACE!", CTX);
// USEPREFIX (otLogDebgMle, "[%p]MLE%!SPACE!", &CTX);
// otLogDebgMle{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MLE}(CTX, MSG, ...);
// end_wpp
// ==ARP==
// begin_wpp config
// USEPREFIX (otLogCritArp, "[%p]ARP%!SPACE!", CTX);
// USEPREFIX (otLogCritArp, "[%p]ARP%!SPACE!", &CTX);
// otLogCritArp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ARP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnArp, "[%p]ARP%!SPACE!", CTX);
// USEPREFIX (otLogWarnArp, "[%p]ARP%!SPACE!", &CTX);
// otLogWarnArp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ARP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoArp, "[%p]ARP%!SPACE!", CTX);
// USEPREFIX (otLogInfoArp, "[%p]ARP%!SPACE!", &CTX);
// otLogInfoArp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ARP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgArp, "[%p]ARP%!SPACE!", CTX);
// USEPREFIX (otLogDebgArp, "[%p]ARP%!SPACE!", &CTX);
// otLogDebgArp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ARP}(CTX, MSG, ...);
// end_wpp
// ==NETD==
// begin_wpp config
// USEPREFIX (otLogCritNetData, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogCritNetData, "[%p]NETD%!SPACE!", &CTX);
// otLogCritNetData{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NETD}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnNetData, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogWarnNetData, "[%p]NETD%!SPACE!", &CTX);
// otLogWarnNetData{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NETD}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoNetData, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogInfoNetData, "[%p]NETD%!SPACE!", &CTX);
// otLogInfoNetData{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NETD}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgNetData, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogDebgNetData, "[%p]NETD%!SPACE!", &CTX);
// otLogDebgNetData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NETD}(CTX, MSG, ...);
// end_wpp
// ==ICMP==
// begin_wpp config
// USEPREFIX (otLogCritIcmp, "[%p]ICMP%!SPACE!", CTX);
// USEPREFIX (otLogCritIcmp, "[%p]ICMP%!SPACE!", &CTX);
// otLogCritIcmp{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_ICMP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnIcmp, "[%p]ICMP%!SPACE!", CTX);
// USEPREFIX (otLogWarnIcmp, "[%p]ICMP%!SPACE!", &CTX);
// otLogWarnIcmp{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_ICMP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoIcmp, "[%p]ICMP%!SPACE!", CTX);
// USEPREFIX (otLogInfoIcmp, "[%p]ICMP%!SPACE!", &CTX);
// otLogInfoIcmp{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_ICMP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgIcmp, "[%p]ICMP%!SPACE!", CTX);
// USEPREFIX (otLogDebgIcmp, "[%p]ICMP%!SPACE!", &CTX);
// otLogDebgIcmp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_ICMP}(CTX, MSG, ...);
// end_wpp
// ==IPV6==
// begin_wpp config
// USEPREFIX (otLogCritIp6, "[%p]IP6%!SPACE!", CTX);
// USEPREFIX (otLogCritIp6, "[%p]IP6%!SPACE!", &CTX);
// otLogCritIp6{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_IPV6}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnIp6, "[%p]IP6%!SPACE!", CTX);
// USEPREFIX (otLogWarnIp6, "[%p]IP6%!SPACE!", &CTX);
// otLogWarnIp6{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_IPV6}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoIp6, "[%p]IP6%!SPACE!", CTX);
// USEPREFIX (otLogInfoIp6, "[%p]IP6%!SPACE!", &CTX);
// otLogInfoIp6{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_IPV6}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgIp6, "[%p]IP6%!SPACE!", CTX);
// USEPREFIX (otLogDebgIp6, "[%p]IP6%!SPACE!", &CTX);
// otLogDebgIp6{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_IPV6}(CTX, MSG, ...);
// end_wpp
// ==MAC==
// begin_wpp config
// USEPREFIX (otLogCritMac, "[%p]MAC%!SPACE!", CTX);
// USEPREFIX (otLogCritMac, "[%p]MAC%!SPACE!", &CTX);
// otLogCritMac{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MAC}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMac, "[%p]MAC%!SPACE!", CTX);
// USEPREFIX (otLogWarnMac, "[%p]MAC%!SPACE!", &CTX);
// otLogWarnMac{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MAC}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMac, "[%p]MAC%!SPACE!", CTX);
// USEPREFIX (otLogInfoMac, "[%p]MAC%!SPACE!", &CTX);
// otLogInfoMac{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MAC}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMac, "[%p]MAC%!SPACE!", CTX);
// USEPREFIX (otLogDebgMac, "[%p]MAC%!SPACE!", &CTX);
// otLogDebgMac{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MAC}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMacErr, "[%p]MAC%!SPACE!", CTX);
// USEPREFIX (otLogDebgMacErr, "[%p]MAC%!SPACE!", &CTX);
// otLogDebgMacErr{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MAC}(CTX, EXP, MSG, ...);
// USESUFFIX(otLogDebgMacErr, ", %!otError!", EXP);
// end_wpp
@@ -394,22 +394,22 @@
// ==MEM==
// begin_wpp config
// USEPREFIX (otLogCritMem, "[%p]MEM%!SPACE!", CTX);
// USEPREFIX (otLogCritMem, "[%p]MEM%!SPACE!", &CTX);
// otLogCritMem{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MEM}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMem, "[%p]MEM%!SPACE!", CTX);
// USEPREFIX (otLogWarnMem, "[%p]MEM%!SPACE!", &CTX);
// otLogWarnMem{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MEM}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMem, "[%p]MEM%!SPACE!", CTX);
// USEPREFIX (otLogInfoMem, "[%p]MEM%!SPACE!", &CTX);
// otLogInfoMem{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MEM}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMem, "[%p]MEM%!SPACE!", CTX);
// USEPREFIX (otLogDebgMem, "[%p]MEM%!SPACE!", &CTX);
// otLogDebgMem{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MEM}(CTX, MSG, ...);
// end_wpp
@@ -422,50 +422,50 @@
// ==MEM==
// begin_wpp config
// USEPREFIX (otLogCritNetDiag, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogCritNetDiag, "[%p]NETD%!SPACE!", &CTX);
// otLogCritNetDiag{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_NDIAG}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnNetDiag, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogWarnNetDiag, "[%p]NETD%!SPACE!", &CTX);
// otLogWarnNetDiag{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_NDIAG}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoNetDiag, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogInfoNetDiag, "[%p]NETD%!SPACE!", &CTX);
// otLogInfoNetDiag{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_NDIAG}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgNetDiag, "[%p]NETD%!SPACE!", CTX);
// USEPREFIX (otLogDebgNetDiag, "[%p]NETD%!SPACE!", &CTX);
// otLogDebgNetDiag{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NDIAG}(CTX, MSG, ...);
// end_wpp
// ==COAP==
// begin_wpp config
// USEPREFIX (otLogCritCoap, "[%p]COAP%!SPACE!", CTX);
// USEPREFIX (otLogCritCoap, "[%p]COAP%!SPACE!", &CTX);
// otLogCritCoap{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnCoap, "[%p]COAP%!SPACE!", CTX);
// USEPREFIX (otLogWarnCoap, "[%p]COAP%!SPACE!", &CTX);
// otLogWarnCoap{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoCoap, "[%p]COAP%!SPACE!", CTX);
// USEPREFIX (otLogInfoCoap, "[%p]COAP%!SPACE!", &CTX);
// otLogInfoCoap{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoCoapErr, "[%p]COAP%!SPACE!", CTX);
// USEPREFIX (otLogInfoCoapErr, "[%p]COAP%!SPACE!", &CTX);
// otLogInfoCoapErr{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(CTX, EXP, MSG, ...);
// USESUFFIX(otLogInfoCoapErr, ", %!otError!", EXP);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgCoap, "[%p]COAP%!SPACE!", CTX);
// USEPREFIX (otLogDebgCoap, "[%p]COAP%!SPACE!", &CTX);
// otLogDebgCoap{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
+1 -1
View File
@@ -244,7 +244,7 @@ Interpreter::Interpreter(otInstance *aInstance):
mLength(8),
mCount(1),
mInterval(1000),
mPingTimer(aInstance, &Interpreter::s_HandlePingTimer, this),
mPingTimer(*aInstance, &Interpreter::s_HandlePingTimer, this),
#if OPENTHREAD_ENABLE_DNS_CLIENT
mResolvingInProgress(0),
#endif
+6 -5
View File
@@ -82,10 +82,11 @@ otInstance::otInstance(void) :
mActiveScanCallbackContext(NULL),
mEnergyScanCallback(NULL),
mEnergyScanCallbackContext(NULL),
mTimerMilliScheduler(this),
mTimerMilliScheduler(*this),
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
mTimerMicroScheduler(this),
mTimerMicroScheduler(*this),
#endif
mIp6(*this),
mThreadNetif(mIp6),
#if OPENTHREAD_ENABLE_RAW_LINK_API
mLinkRaw(*this),
@@ -96,7 +97,7 @@ otInstance::otInstance(void) :
#if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
mLogLevel(static_cast<otLogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL)),
#endif // OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
mMessagePool(this)
mMessagePool(*this)
{
}
@@ -148,7 +149,7 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize)
// Execute post constructor operations
otInstancePostConstructor(instance);
otLogInfoApi(instance, "otInstance Initialized");
otLogInfoApi(*instance, "otInstance Initialized");
exit:
@@ -179,7 +180,7 @@ otInstance *otInstanceInitSingle(void)
// Execute post constructor operations
otInstancePostConstructor(sInstance);
otLogInfoApi(sInstance, "otInstance Initialized");
otLogInfoApi(*sInstance, "otInstance Initialized");
exit:
+7 -7
View File
@@ -269,14 +269,14 @@ LinkRaw::LinkRaw(otInstance &aInstance):
mTransmitDoneCallback(NULL),
mEnergyScanDoneCallback(NULL)
#if OPENTHREAD_LINKRAW_TIMER_REQUIRED
, mTimer(&aInstance, &LinkRaw::HandleTimer, this)
, mTimer(aInstance, &LinkRaw::HandleTimer, this)
, mTimerReason(kTimerReasonNone)
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
, mTimerMicro(&aInstance, &LinkRaw::HandleTimer, this)
, mTimerMicro(aInstance, &LinkRaw::HandleTimer, this)
#endif
#endif // OPENTHREAD_LINKRAW_TIMER_REQUIRED
#if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN
, mEnergyScanTask(&aInstance, &LinkRaw::HandleEnergyScanTask, this)
, mEnergyScanTask(aInstance, &LinkRaw::HandleEnergyScanTask, this)
#endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN
{
// Query the capabilities to check asserts
@@ -386,7 +386,7 @@ otError LinkRaw::DoTransmit(otRadioFrame *aFrame)
void LinkRaw::InvokeTransmitDone(otRadioFrame *aFrame, bool aFramePending, otError aError)
{
otLogDebgPlat(aInstance, "LinkRaw Transmit Done (err=0x%x)", aError);
otLogDebgPlat(&mInstance, "LinkRaw Transmit Done (err=0x%x)", aError);
#if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
mTimer.Stop();
@@ -427,11 +427,11 @@ void LinkRaw::InvokeTransmitDone(otRadioFrame *aFrame, bool aFramePending, otErr
{
if (aError == OT_ERROR_NONE)
{
otLogInfoPlat(aInstance, "LinkRaw Invoke Transmit Done");
otLogInfoPlat(&mInstance, "LinkRaw Invoke Transmit Done");
}
else
{
otLogWarnPlat(aInstance, "LinkRaw Invoke Transmit Failed (err=0x%x)", aError);
otLogWarnPlat(&mInstance, "LinkRaw Invoke Transmit Failed (err=0x%x)", aError);
}
mTransmitDoneCallback(&mInstance, aFrame, aFramePending, aError);
@@ -559,7 +559,7 @@ void LinkRaw::StartCsmaBackoff(void)
backoff = (otPlatRandomGet() % (1UL << backoffExponent));
backoff *= (static_cast<uint32_t>(Mac::kUnitBackoffPeriod) * OT_RADIO_SYMBOL_TIME);
otLogDebgPlat(aInstance, "LinkRaw Starting RetransmitTimeout Timer (%d ms)", backoff);
otLogDebgPlat(&mInstance, "LinkRaw Starting RetransmitTimeout Timer (%d ms)", backoff);
mTimerReason = kTimerReasonRetransmitTimeout;
#if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
+1 -1
View File
@@ -219,7 +219,7 @@ void CoapSecure::HandleDtlsReceive(uint8_t *aBuf, uint16_t aLength)
otLogFuncEntry();
VerifyOrExit((message = GetInstance()->mMessagePool.New(Message::kTypeIp6, 0)) != NULL);
VerifyOrExit((message = GetInstance().mMessagePool.New(Message::kTypeIp6, 0)) != NULL);
SuccessOrExit(message->Append(aBuf, aLength));
Coap::Receive(*message, mPeerAddress);
+6 -6
View File
@@ -44,19 +44,19 @@ namespace ot {
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *ThreadNetifLocator::GetInstance(void) const
otInstance &ThreadNetifLocator::GetInstance(void) const
{
return otInstanceFromThreadNetif(&GetNetif());
return *otInstanceFromThreadNetif(&GetNetif());
}
otInstance *MeshForwarderLocator::GetInstance(void) const
otInstance &MeshForwarderLocator::GetInstance(void) const
{
return otInstanceFromThreadNetif(&GetMeshForwarder().GetNetif());
return *otInstanceFromThreadNetif(&GetMeshForwarder().GetNetif());
}
otInstance *Ip6Locator::GetInstance(void) const
otInstance &Ip6Locator::GetInstance(void) const
{
return otInstanceFromIp6(&GetIp6());
return *otInstanceFromIp6(&GetIp6());
}
#endif // #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
+18 -29
View File
@@ -105,15 +105,15 @@ public:
#endif
/**
* This method returns the pointer to the parent otInstance structure.
* This method returns the reference to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure, or NULL if the instance has been finalized.
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *GetInstance(void) const;
otInstance &GetInstance(void) const;
#else
otInstance *GetInstance(void) const { return otGetInstance(); }
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
@@ -146,15 +146,15 @@ public:
#endif
/**
* This method returns the pointer to the parent otInstance structure.
* This method returns the reference to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure, or NULL if the instance has been finalized.
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *GetInstance(void) const;
otInstance &GetInstance(void) const;
#else
otInstance *GetInstance(void) const { return otGetInstance(); }
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
@@ -187,15 +187,15 @@ public:
#endif
/**
* This method returns the pointer to the parent otInstance structure.
* This method returns the reference to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure, or NULL if the instance has been finalized.
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *GetInstance(void) const;
otInstance &GetInstance(void) const;
#else
otInstance *GetInstance(void) const { return otGetInstance(); }
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
@@ -212,19 +212,19 @@ protected:
* This class implements locator for otInstance object
*
*/
class InstanceLocator
class InstanceLocator: private Locator<otInstance>
{
public:
/**
* This method returns the pointer to the parent otInstance structure.
* This method returns a reference to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure, or NULL if the instance has been finalized.
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *GetInstance(void) const { return mInstance; }
otInstance &GetInstance(void) const { return mLocatorObject; }
#else
otInstance *GetInstance(void) const { return otGetInstance(); }
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
@@ -234,18 +234,7 @@ protected:
* @param[in] aInstance A pointer to the otInstance.
*
*/
InstanceLocator(otInstance *aInstance)
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
: mInstance(aInstance)
#endif
{
OT_UNUSED_VARIABLE(aInstance);
}
private:
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance *mInstance;
#endif
InstanceLocator(otInstance &aInstance): Locator(aInstance) { }
};
/**
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -44,13 +44,13 @@
namespace ot {
MessagePool::MessagePool(otInstance *aInstance) :
MessagePool::MessagePool(otInstance &aInstance) :
InstanceLocator(aInstance),
mAllQueue()
{
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
// Initialize Platform buffer pool management.
otPlatMessagePoolInit(GetInstance(), kNumBuffers, sizeof(Buffer));
otPlatMessagePoolInit(&GetInstance(), kNumBuffers, sizeof(Buffer));
#else
memset(mBuffers, 0, sizeof(mBuffers));
@@ -106,7 +106,7 @@ Buffer *MessagePool::NewBuffer(void)
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
buffer = static_cast<Buffer *>(otPlatMessagePoolNew(GetInstance()));
buffer = static_cast<Buffer *>(otPlatMessagePoolNew(&GetInstance()));
#else
@@ -136,7 +136,7 @@ otError MessagePool::FreeBuffers(Buffer *aBuffer)
{
tmpBuffer = aBuffer->GetNextBuffer();
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
otPlatMessagePoolFree(GetInstance(), aBuffer);
otPlatMessagePoolFree(&GetInstance(), aBuffer);
#else // OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
aBuffer->SetNextBuffer(mFreeBuffers);
mFreeBuffers = aBuffer;
@@ -153,7 +153,7 @@ otError MessagePool::ReclaimBuffers(int aNumBuffers)
uint16_t numFreeBuffers;
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
numFreeBuffers = otPlatMessagePoolNumFreeBuffers(GetInstance());
numFreeBuffers = otPlatMessagePoolNumFreeBuffers(&GetInstance());
#else
numFreeBuffers = mNumFreeBuffers;
#endif
+2 -2
View File
@@ -1107,7 +1107,7 @@ public:
* This constructor initializes the object.
*
*/
MessagePool(otInstance *aInstance);
MessagePool(otInstance &aInstance);
/**
* This method is used to obtain a new message. The default priority `kDefaultMessagePriority`
@@ -1157,7 +1157,7 @@ public:
*
*/
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
uint16_t GetFreeBufferCount(void) const { return otPlatMessagePoolNumFreeBuffers(GetInstance()); }
uint16_t GetFreeBufferCount(void) const { return otPlatMessagePoolNumFreeBuffers(&GetInstance()); }
#else
uint16_t GetFreeBufferCount(void) const { return mNumFreeBuffers; }
#endif
+4 -4
View File
@@ -44,7 +44,7 @@
namespace ot {
Tasklet::Tasklet(otInstance *aInstance, Handler aHandler, void *aContext):
Tasklet::Tasklet(otInstance &aInstance, Handler aHandler, void *aContext):
InstanceLocator(aInstance),
Context(aContext),
mHandler(aHandler),
@@ -54,7 +54,7 @@ Tasklet::Tasklet(otInstance *aInstance, Handler aHandler, void *aContext):
otError Tasklet::Post(void)
{
return GetInstance()->mTaskletScheduler.Post(*this);
return GetInstance().mTaskletScheduler.Post(*this);
}
TaskletScheduler::TaskletScheduler(void):
@@ -73,7 +73,7 @@ otError TaskletScheduler::Post(Tasklet &aTasklet)
{
mHead = &aTasklet;
mTail = &aTasklet;
otTaskletsSignalPending(aTasklet.GetInstance());
otTaskletsSignalPending(&aTasklet.GetInstance());
}
else
{
@@ -118,7 +118,7 @@ void TaskletScheduler::ProcessQueuedTasklets(void)
{
if (mHead != NULL)
{
otTaskletsSignalPending(mHead->GetInstance());
otTaskletsSignalPending(&mHead->GetInstance());
}
break;
+2 -2
View File
@@ -75,12 +75,12 @@ public:
/**
* This constructor creates a tasklet instance.
*
* @param[in] aInstance A pointer to the instance object.
* @param[in] aInstance A reference to the instance object.
* @param[in] aHandler A pointer to a function that is called when the tasklet is run.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
Tasklet(otInstance *aInstance, Handler aHandler, void *aContext);
Tasklet(otInstance &aInstance, Handler aHandler, void *aContext);
/**
* This method puts the tasklet on the run queue.
+4 -4
View File
@@ -89,7 +89,7 @@ void TimerMilli::Stop(void)
TimerMilliScheduler &TimerMilli::GetTimerMilliScheduler(void) const
{
return GetInstance()->mTimerMilliScheduler;
return GetInstance().mTimerMilliScheduler;
}
void TimerScheduler::Add(Timer &aTimer, const AlarmApi &aAlarmApi)
@@ -168,14 +168,14 @@ void TimerScheduler::SetAlarm(const AlarmApi &aAlarmApi)
{
if (mHead == NULL)
{
aAlarmApi.AlarmStop(GetInstance());
aAlarmApi.AlarmStop(&GetInstance());
}
else
{
uint32_t now = aAlarmApi.AlarmGetNow();
uint32_t remaining = IsStrictlyBefore(now, mHead->mFireTime) ? (mHead->mFireTime - now) : 0;
aAlarmApi.AlarmStartAt(GetInstance(), now, remaining);
aAlarmApi.AlarmStartAt(&GetInstance(), now, remaining);
}
}
@@ -246,7 +246,7 @@ void TimerMicro::Stop(void)
TimerMicroScheduler &TimerMicro::GetTimerMicroScheduler(void) const
{
return GetInstance()->mTimerMicroScheduler;
return GetInstance().mTimerMicroScheduler;
}
extern "C" void otPlatAlarmMicroFired(otInstance *aInstance)
+12 -12
View File
@@ -86,12 +86,12 @@ public:
/**
* This constructor creates a timer instance.
*
* @param[in] aInstance A pointer to the instance.
* @param[in] aInstance A reference to the instance.
* @param[in] aHandler A pointer to a function that is called when the timer expires.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
Timer(otInstance *aInstance, Handler aHandler, void *aContext):
Timer(otInstance &aInstance, Handler aHandler, void *aContext):
InstanceLocator(aInstance),
Context(aContext),
mHandler(aHandler),
@@ -146,12 +146,12 @@ public:
/**
* This constructor creates a millisecond timer instance.
*
* @param[in] aInstance A pointer to the instance.
* @param[in] aInstance A reference to the instance.
* @param[in] aHandler A pointer to a function that is called when the timer expires.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
TimerMilli(otInstance *aInstance, Handler aHandler, void *aContext):
TimerMilli(otInstance &aInstance, Handler aHandler, void *aContext):
Timer(aInstance, aHandler, aContext) {
}
@@ -238,10 +238,10 @@ protected:
/**
* This constructor initializes the object.
*
* @param[in] aInstance A pointer to the instance object.
* @param[in] aInstance A reference to the instance object.
*
*/
TimerScheduler(otInstance *aInstance):
TimerScheduler(otInstance &aInstance):
InstanceLocator(aInstance),
mHead(NULL) {
}
@@ -308,10 +308,10 @@ public:
/**
* This constructor initializes the object.
*
* @param[in] aInstance A pointer to the instance object.
* @param[in] aInstance A reference to the instance object.
*
*/
TimerMilliScheduler(otInstance *aInstance):
TimerMilliScheduler(otInstance &aInstance):
TimerScheduler(aInstance) {
}
@@ -354,12 +354,12 @@ public:
/**
* This constructor creates a timer instance.
*
* @param[in] aInstance A pointer to the instance object.
* @param[in] aInstance A reference to the instance object.
* @param[in] aHandler A pointer to a function that is called when the timer expires.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
TimerMicro(otInstance *aInstance, Handler aHandler, void *aContext):
TimerMicro(otInstance &aInstance, Handler aHandler, void *aContext):
Timer(aInstance, aHandler, aContext) {
}
@@ -416,10 +416,10 @@ public:
/**
* This constructor initializes the object.
*
* @param[in] aInstance A pointer to the instance object.
* @param[in] aInstance A reference to the instance object.
*
*/
TimerMicroScheduler(otInstance *aInstance):
TimerMicroScheduler(otInstance &aInstance):
TimerScheduler(aInstance) {
}
+1 -1
View File
@@ -43,7 +43,7 @@
namespace ot {
TrickleTimer::TrickleTimer(
otInstance *aInstance,
otInstance &aInstance,
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
uint32_t aRedundancyConstant,
#endif
+2 -2
View File
@@ -80,14 +80,14 @@ public:
/**
* This constructor creates a trickle timer instance.
*
* @param[in] aInstance A pointer to the instance.
* @param[in] aInstance A reference to the instance.
* @param[in] aRedundancyConstant The redundancy constant for the timer, k.
* @param[in] aTransmitHandler A pointer to a function that is called when transmission should occur.
* @param[in] aIntervalExpiredHandler An optional pointer to a function that is called when the interval expires.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
TrickleTimer(otInstance *aInstance,
TrickleTimer(otInstance &aInstance,
#ifdef ENABLE_TRICKLE_TIMER_SUPPRESSION_SUPPORT
uint32_t aRedundancyConstant,
#endif
+20 -20
View File
@@ -139,7 +139,7 @@ Mac::Mac(ThreadNetif &aThreadNetif):
#if OPENTHREAD_ENABLE_MAC_FILTER
mFilter(),
#endif // OPENTHREAD_ENABLE_MAC_FILTER
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(aThreadNetif.GetInstance()))),
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aThreadNetif.GetInstance()))),
mKeyIdMode2FrameCounter(0),
#if OPENTHREAD_CONFIG_STAY_AWAKE_BETWEEN_FRAGMENTS
mDelaySleep(false),
@@ -156,7 +156,7 @@ Mac::Mac(ThreadNetif &aThreadNetif):
SetExtAddress(mExtAddress);
SetShortAddress(mShortAddress);
otPlatRadioEnable(GetInstance());
otPlatRadioEnable(&GetInstance());
}
otError Mac::ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler, void *aContext)
@@ -286,7 +286,7 @@ void Mac::StartEnergyScan(void)
{
mState = kStateEnergyScan;
if (!(otPlatRadioGetCaps(GetInstance()) & OT_RADIO_CAPS_ENERGY_SCAN))
if (!(otPlatRadioGetCaps(&GetInstance()) & OT_RADIO_CAPS_ENERGY_SCAN))
{
mEnergyScanCurrentMaxRssi = kInvalidRssiValue;
mMacTimer.Start(mScanDuration);
@@ -295,7 +295,7 @@ void Mac::StartEnergyScan(void)
}
else
{
otError error = otPlatRadioEnergyScan(GetInstance(), mScanChannel, mScanDuration);
otError error = otPlatRadioEnergyScan(&GetInstance(), mScanChannel, mScanDuration);
if (error != OT_ERROR_NONE)
{
@@ -374,7 +374,7 @@ void Mac::HandleEnergyScanSampleRssi(void)
VerifyOrExit(mState == kStateEnergyScan);
rssi = otPlatRadioGetRssi(GetInstance());
rssi = otPlatRadioGetRssi(&GetInstance());
if (rssi != kInvalidRssiValue)
{
@@ -440,7 +440,7 @@ void Mac::SetExtAddress(const ExtAddress &aExtAddress)
buf[i] = aExtAddress.m8[7 - i];
}
otPlatRadioSetExtendedAddress(GetInstance(), buf);
otPlatRadioSetExtendedAddress(&GetInstance(), buf);
mExtAddress = aExtAddress;
otLogFuncExit();
@@ -453,7 +453,7 @@ void Mac::GetHashMacAddress(ExtAddress *aHashMacAddress)
otLogFuncEntry();
otPlatRadioGetIeeeEui64(GetInstance(), buf);
otPlatRadioGetIeeeEui64(&GetInstance(), buf);
sha256.Start();
sha256.Update(buf, OT_EXT_ADDRESS_SIZE);
sha256.Finish(buf);
@@ -468,7 +468,7 @@ otError Mac::SetShortAddress(ShortAddress aShortAddress)
{
otLogFuncEntryMsg("%d", aShortAddress);
mShortAddress = aShortAddress;
otPlatRadioSetShortAddress(GetInstance(), aShortAddress);
otPlatRadioSetShortAddress(&GetInstance(), aShortAddress);
otLogFuncExit();
return OT_ERROR_NONE;
}
@@ -506,7 +506,7 @@ otError Mac::SetPanId(PanId aPanId)
{
otLogFuncEntryMsg("%d", aPanId);
mPanId = aPanId;
otPlatRadioSetPanId(GetInstance(), mPanId);
otPlatRadioSetPanId(&GetInstance(), mPanId);
otLogFuncExit();
return OT_ERROR_NONE;
}
@@ -554,7 +554,7 @@ void Mac::NextOperation(void)
break;
default:
if (mRxOnWhenIdle || mReceiveTimer.IsRunning() || otPlatRadioGetPromiscuous(GetInstance()))
if (mRxOnWhenIdle || mReceiveTimer.IsRunning() || otPlatRadioGetPromiscuous(&GetInstance()))
{
RadioReceive(mChannel);
}
@@ -793,7 +793,7 @@ void Mac::HandleBeginTransmit(void)
switch (mState)
{
case kStateActiveScan:
otPlatRadioSetPanId(GetInstance(), kPanIdBroadcast);
otPlatRadioSetPanId(&GetInstance(), kPanIdBroadcast);
sendFrame.SetChannel(mScanChannel);
SendBeaconRequest(sendFrame);
sendFrame.SetSequence(0);
@@ -870,7 +870,7 @@ void Mac::TransmitStartedTask(otRadioFrame *aFrame)
{
Frame *frame = static_cast<Frame *>(aFrame);
if (frame->GetAckRequest() && !(otPlatRadioGetCaps(GetInstance()) & OT_RADIO_CAPS_ACK_TIMEOUT))
if (frame->GetAckRequest() && !(otPlatRadioGetCaps(&GetInstance()) & OT_RADIO_CAPS_ACK_TIMEOUT))
{
mMacTimer.Start(kAckTimeout);
otLogDebgMac(GetInstance(), "Ack timer start");
@@ -1102,7 +1102,7 @@ otError Mac::RadioTransmit(Frame *aSendFrame)
#endif
// Transmit packet
return otPlatRadioTransmit(GetInstance(), static_cast<otRadioFrame *>(aSendFrame));
return otPlatRadioTransmit(&GetInstance(), static_cast<otRadioFrame *>(aSendFrame));
}
otError Mac::RadioReceive(uint8_t aChannel)
@@ -1117,7 +1117,7 @@ otError Mac::RadioReceive(uint8_t aChannel)
#endif
// Receive
return otPlatRadioReceive(GetInstance(), aChannel);
return otPlatRadioReceive(&GetInstance(), aChannel);
}
void Mac::RadioSleep(void)
@@ -1133,7 +1133,7 @@ void Mac::RadioSleep(void)
else
#endif
{
otPlatRadioSleep(GetInstance());
otPlatRadioSleep(&GetInstance());
}
}
@@ -1157,7 +1157,7 @@ void Mac::HandleMacTimer(void)
if (mScanChannels == 0 || mScanChannel > OT_RADIO_CHANNEL_MAX)
{
RadioReceive(mChannel);
otPlatRadioSetPanId(GetInstance(), mPanId);
otPlatRadioSetPanId(&GetInstance(), mPanId);
mActiveScanHandler(mScanContext, NULL);
ScheduleNextTransmission();
ExitNow();
@@ -1835,12 +1835,12 @@ void Mac::SetPcapCallback(otLinkPcapCallback aPcapCallback, void *aCallbackConte
bool Mac::IsPromiscuous(void)
{
return otPlatRadioGetPromiscuous(GetInstance());
return otPlatRadioGetPromiscuous(&GetInstance());
}
void Mac::SetPromiscuous(bool aPromiscuous)
{
otPlatRadioSetPromiscuous(GetInstance(), aPromiscuous);
otPlatRadioSetPromiscuous(&GetInstance(), aPromiscuous);
if (mState == kStateIdle)
{
@@ -1854,12 +1854,12 @@ bool Mac::RadioSupportsCsmaBackoff(void)
* 1) Radio provides the CSMA backoff capability (i.e., `OT_RADIO_CAPS_CSMA_BACKOFF` bit is set) or;
* 2) It provides `OT_RADIO_CAPS_TRANSMIT_RETRIES` which indicates support for MAC retries along with CSMA backoff.
*/
return (otPlatRadioGetCaps(GetInstance()) & (OT_RADIO_CAPS_TRANSMIT_RETRIES | OT_RADIO_CAPS_CSMA_BACKOFF)) != 0;
return (otPlatRadioGetCaps(&GetInstance()) & (OT_RADIO_CAPS_TRANSMIT_RETRIES | OT_RADIO_CAPS_CSMA_BACKOFF)) != 0;
}
bool Mac::RadioSupportsRetries(void)
{
return (otPlatRadioGetCaps(GetInstance()) & OT_RADIO_CAPS_TRANSMIT_RETRIES) != 0;
return (otPlatRadioGetCaps(&GetInstance()) & OT_RADIO_CAPS_TRANSMIT_RETRIES) != 0;
}
void Mac::FillMacCountersTlv(NetworkDiagnostic::MacCountersTlv &aMacCounters) const
+1 -1
View File
@@ -627,7 +627,7 @@ public:
* @returns The noise floor value in dBm.
*
*/
int8_t GetNoiseFloor(void) { return otPlatRadioGetReceiveSensitivity(GetInstance()); }
int8_t GetNoiseFloor(void) { return otPlatRadioGetReceiveSensitivity(&GetInstance()); }
/**
* This method indicates whether or not CSMA backoff is supported by the radio layer.
+9 -9
View File
@@ -52,7 +52,7 @@
namespace ot {
namespace MeshCoP {
DatasetLocal::DatasetLocal(otInstance *aInstance, const Tlv::Type aType) :
DatasetLocal::DatasetLocal(otInstance &aInstance, const Tlv::Type aType) :
InstanceLocator(aInstance),
mUpdateTime(0),
mType(aType)
@@ -61,12 +61,12 @@ DatasetLocal::DatasetLocal(otInstance *aInstance, const Tlv::Type aType) :
void DatasetLocal::Clear(void)
{
otPlatSettingsDelete(GetInstance(), GetSettingsKey(), -1);
otPlatSettingsDelete(&GetInstance(), GetSettingsKey(), -1);
}
bool DatasetLocal::IsPresent(void) const
{
return otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, NULL, NULL) == OT_ERROR_NONE;
return otPlatSettingsGet(&GetInstance(), GetSettingsKey(), 0, NULL, NULL) == OT_ERROR_NONE;
}
otError DatasetLocal::Get(Dataset &aDataset)
@@ -76,7 +76,7 @@ otError DatasetLocal::Get(Dataset &aDataset)
otError error;
aDataset.mLength = sizeof(aDataset.mTlvs);
error = otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, aDataset.mTlvs, &aDataset.mLength);
error = otPlatSettingsGet(&GetInstance(), GetSettingsKey(), 0, aDataset.mTlvs, &aDataset.mLength);
VerifyOrExit(error == OT_ERROR_NONE, aDataset.mLength = 0);
delayTimer = static_cast<DelayTimerTlv *>(aDataset.Get(Tlv::kDelayTimer));
@@ -109,7 +109,7 @@ otError DatasetLocal::Get(otOperationalDataset &aDataset) const
memset(&aDataset, 0, sizeof(aDataset));
dataset.mLength = sizeof(dataset.mTlvs);
error = otPlatSettingsGet(GetInstance(), GetSettingsKey(), 0, dataset.mTlvs, &dataset.mLength);
error = otPlatSettingsGet(&GetInstance(), GetSettingsKey(), 0, dataset.mTlvs, &dataset.mLength);
SuccessOrExit(error);
cur = reinterpret_cast<const Tlv *>(dataset.mTlvs);
@@ -357,12 +357,12 @@ otError DatasetLocal::Set(const otOperationalDataset &aDataset)
if (dataset.GetSize() == 0)
{
error = otPlatSettingsDelete(GetInstance(), GetSettingsKey(), 0);
error = otPlatSettingsDelete(&GetInstance(), GetSettingsKey(), 0);
otLogInfoMeshCoP(GetInstance(), "%s dataset deleted", mType == Tlv::kActiveTimestamp ? "Active" : "Pending");
}
else
{
error = otPlatSettingsSet(GetInstance(), GetSettingsKey(), dataset.GetBytes(), dataset.GetSize());
error = otPlatSettingsSet(&GetInstance(), GetSettingsKey(), dataset.GetBytes(), dataset.GetSize());
otLogInfoMeshCoP(GetInstance(), "%s dataset set", mType == Tlv::kActiveTimestamp ? "Active" : "Pending");
}
@@ -385,12 +385,12 @@ otError DatasetLocal::Set(const Dataset &aDataset)
if (dataset.GetSize() == 0)
{
error = otPlatSettingsDelete(GetInstance(), GetSettingsKey(), 0);
error = otPlatSettingsDelete(&GetInstance(), GetSettingsKey(), 0);
otLogInfoMeshCoP(GetInstance(), "%s dataset deleted", mType == Tlv::kActiveTimestamp ? "Active" : "Pending");
}
else
{
error = otPlatSettingsSet(GetInstance(), GetSettingsKey(), dataset.GetBytes(), dataset.GetSize());
error = otPlatSettingsSet(&GetInstance(), GetSettingsKey(), dataset.GetBytes(), dataset.GetSize());
otLogInfoMeshCoP(GetInstance(), "%s dataset set", mType == Tlv::kActiveTimestamp ? "Active" : "Pending");
}
+2 -2
View File
@@ -48,11 +48,11 @@ public:
/**
* This constructor initializes the object.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aInstance A reference to an OpenThread instance.
* @param[in] aType The type of the dataset, active or pending.
*
*/
DatasetLocal(otInstance *aInstance, const Tlv::Type aType);
DatasetLocal(otInstance &aInstance, const Tlv::Type aType);
/**
* This method indicates whether this is an Active or Pending Dataset.
+1 -1
View File
@@ -101,7 +101,7 @@ otError Dtls::Start(bool aClient, ConnectedHandler aConnectedHandler, ReceiveHan
// mbedTLS's debug level is almost the same as OpenThread's
mbedtls_debug_set_threshold(OPENTHREAD_CONFIG_LOG_LEVEL);
otPlatRadioGetIeeeEui64(GetInstance(), eui64.m8);
otPlatRadioGetIeeeEui64(&GetInstance(), eui64.m8);
rval = mbedtls_ctr_drbg_seed(&mCtrDrbg, mbedtls_entropy_func, &mEntropy, eui64.m8, sizeof(eui64));
VerifyOrExit(rval == 0);
+1 -1
View File
@@ -695,7 +695,7 @@ otError Dhcp6Client::ProcessIaAddress(Message &aMessage, uint16_t aOffset)
address->mValidLifetime = option.GetValidLifetime();
address->mAddress.mPreferred = address->mPreferredLifetime != 0;
address->mAddress.mValid = address->mValidLifetime != 0;
otIp6AddUnicastAddress(GetNetif().GetInstance(), &address->mAddress);
otIp6AddUnicastAddress(&GetNetif().GetInstance(), &address->mAddress);
break;
}
}
+5 -9
View File
@@ -52,13 +52,14 @@
namespace ot {
namespace Ip6 {
Ip6::Ip6(void):
Ip6::Ip6(otInstance &aInstance):
InstanceLocator(aInstance),
mRoutes(*this),
mIcmp(*this),
mUdp(*this),
mMpl(*this),
mForwardingEnabled(false),
mSendQueueTask(GetInstance(), HandleSendQueue, this),
mSendQueueTask(aInstance, HandleSendQueue, this),
mReceiveIp6DatagramCallback(NULL),
mReceiveIp6DatagramCallbackContext(NULL),
mIsReceiveIp6FilterEnabled(false),
@@ -68,8 +69,8 @@ Ip6::Ip6(void):
Message *Ip6::NewMessage(uint16_t aReserved)
{
return GetInstance()->mMessagePool.New(Message::kTypeIp6,
sizeof(Header) + sizeof(HopByHopHeader) + sizeof(OptionMpl) + aReserved);
return GetInstance().mMessagePool.New(Message::kTypeIp6,
sizeof(Header) + sizeof(HopByHopHeader) + sizeof(OptionMpl) + aReserved);
}
uint16_t Ip6::UpdateChecksum(uint16_t aChecksum, const Address &aAddress)
@@ -1096,11 +1097,6 @@ exit:
return rval;
}
otInstance *Ip6::GetInstance(void)
{
return otInstanceFromIp6(this);
}
Ip6 &Ip6::GetOwner(const Context &aContext)
{
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
+6 -10
View File
@@ -40,6 +40,7 @@
#include <openthread/udp.h>
#include "common/encoding.hpp"
#include "common/locator.hpp"
#include "common/message.hpp"
#include "net/icmp6.hpp"
#include "net/ip6_address.hpp"
@@ -95,7 +96,7 @@ namespace Ip6 {
* This class implements the core IPv6 message processing.
*
*/
class Ip6
class Ip6 : public InstanceLocator
{
public:
enum
@@ -116,8 +117,11 @@ public:
/**
* This constructor initializes the object.
*
* @param[in] aInstance A reference to the otInstance object.
*
*/
Ip6(void);
Ip6(otInstance &aInstance);
/**
* This method sends an IPv6 datagram.
@@ -320,14 +324,6 @@ public:
*/
int8_t GetOnLinkNetif(const Address &aAddress);
/**
* This method returns the pointer to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure.
*
*/
otInstance *GetInstance(void);
/**
* This method returns a reference to the send queue.
*
+1 -1
View File
@@ -108,7 +108,7 @@ otError DataPollManager::SendDataPoll(void)
VerifyOrExit(message->GetType() != Message::kTypeMacDataPoll, error = OT_ERROR_ALREADY);
}
message = meshForwarder.GetInstance()->mMessagePool.New(Message::kTypeMacDataPoll, 0);
message = GetInstance().mMessagePool.New(Message::kTypeMacDataPoll, 0);
VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS);
error = meshForwarder.SendMessage(*message);
+3 -3
View File
@@ -1921,7 +1921,7 @@ void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Mac:
meshHeader.SetHopsLeft(meshHeader.GetHopsLeft() - 1);
meshHeader.AppendTo(aFrame);
VerifyOrExit((message = netif.GetInstance()->mMessagePool.New(Message::kType6lowpan, 0)) != NULL,
VerifyOrExit((message = GetInstance().mMessagePool.New(Message::kType6lowpan, 0)) != NULL,
error = OT_ERROR_NO_BUFS);
SuccessOrExit(error = message->SetLength(aFrameLength));
message->Write(0, aFrameLength, aFrame);
@@ -2009,7 +2009,7 @@ void MeshForwarder::HandleFragment(uint8_t *aFrame, uint8_t aFrameLength,
aFrame += fragmentHeader->GetHeaderLength();
aFrameLength -= fragmentHeader->GetHeaderLength();
VerifyOrExit((message = netif.GetInstance()->mMessagePool.New(Message::kTypeIp6, 0)) != NULL,
VerifyOrExit((message = GetInstance().mMessagePool.New(Message::kTypeIp6, 0)) != NULL,
error = OT_ERROR_NO_BUFS);
message->SetLinkSecurityEnabled(aMessageInfo.mLinkSecurity);
message->SetPanId(aMessageInfo.mPanId);
@@ -2190,7 +2190,7 @@ void MeshForwarder::HandleLowpanHC(uint8_t *aFrame, uint8_t aFrameLength,
Message *message;
int headerLength;
VerifyOrExit((message = netif.GetInstance()->mMessagePool.New(Message::kTypeIp6, 0)) != NULL,
VerifyOrExit((message = GetInstance().mMessagePool.New(Message::kTypeIp6, 0)) != NULL,
error = OT_ERROR_NO_BUFS);
message->SetLinkSecurityEnabled(aMessageInfo.mLinkSecurity);
message->SetPanId(aMessageInfo.mPanId);
+7 -7
View File
@@ -204,7 +204,7 @@ otError Mle::Start(bool aEnableReattach, bool aAnnounceAttach)
otLogFuncEntry();
// cannot bring up the interface if IEEE 802.15.4 promiscuous mode is enabled
VerifyOrExit(otPlatRadioGetPromiscuous(netif.GetInstance()) == false, error = OT_ERROR_INVALID_STATE);
VerifyOrExit(otPlatRadioGetPromiscuous(&netif.GetInstance()) == false, error = OT_ERROR_INVALID_STATE);
VerifyOrExit(netif.IsUp(), error = OT_ERROR_INVALID_STATE);
mRole = OT_DEVICE_ROLE_DETACHED;
@@ -278,7 +278,7 @@ otError Mle::Restore(void)
netif.GetPendingDataset().Restore();
length = sizeof(networkInfo);
SuccessOrExit(error = otPlatSettingsGet(netif.GetInstance(), Settings::kKeyNetworkInfo, 0,
SuccessOrExit(error = otPlatSettingsGet(&netif.GetInstance(), Settings::kKeyNetworkInfo, 0,
reinterpret_cast<uint8_t *>(&networkInfo), &length));
VerifyOrExit(length >= sizeof(networkInfo), error = OT_ERROR_NOT_FOUND);
@@ -305,7 +305,7 @@ otError Mle::Restore(void)
if (!IsActiveRouter(networkInfo.mRloc16))
{
length = sizeof(parentInfo);
SuccessOrExit(error = otPlatSettingsGet(netif.GetInstance(), Settings::kKeyParentInfo, 0,
SuccessOrExit(error = otPlatSettingsGet(&netif.GetInstance(), Settings::kKeyParentInfo, 0,
reinterpret_cast<uint8_t *>(&parentInfo), &length));
VerifyOrExit(length >= sizeof(parentInfo), error = OT_ERROR_PARSE);
@@ -374,7 +374,7 @@ otError Mle::Store(void)
memset(&parentInfo, 0, sizeof(parentInfo));
memcpy(&parentInfo.mExtAddress, &mParent.GetExtAddress(), sizeof(parentInfo.mExtAddress));
SuccessOrExit(error = otPlatSettingsSet(netif.GetInstance(), Settings::kKeyParentInfo,
SuccessOrExit(error = otPlatSettingsSet(&netif.GetInstance(), Settings::kKeyParentInfo,
reinterpret_cast<uint8_t *>(&parentInfo), sizeof(parentInfo)));
}
}
@@ -382,7 +382,7 @@ otError Mle::Store(void)
{
// when not attached, read out any existing values so that we do not change them
uint16_t length = sizeof(networkInfo);
IgnoreReturnValue(otPlatSettingsGet(netif.GetInstance(), Settings::kKeyNetworkInfo, 0,
IgnoreReturnValue(otPlatSettingsGet(&netif.GetInstance(), Settings::kKeyNetworkInfo, 0,
reinterpret_cast<uint8_t *>(&networkInfo), &length));
}
@@ -393,7 +393,7 @@ otError Mle::Store(void)
networkInfo.mMacFrameCounter = netif.GetKeyManager().GetMacFrameCounter() +
OPENTHREAD_CONFIG_STORE_FRAME_COUNTER_AHEAD;
SuccessOrExit(error = otPlatSettingsSet(netif.GetInstance(), Settings::kKeyNetworkInfo,
SuccessOrExit(error = otPlatSettingsSet(&netif.GetInstance(), Settings::kKeyNetworkInfo,
reinterpret_cast<uint8_t *>(&networkInfo), sizeof(networkInfo)));
netif.GetKeyManager().SetStoredMleFrameCounter(networkInfo.mMleFrameCounter);
@@ -3109,7 +3109,7 @@ otError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Message
Crc16 ansi(Crc16::kAnsi);
// Get Factory set EUI64
otPlatRadioGetIeeeEui64(GetInstance(), mfgEUI64.m8);
otPlatRadioGetIeeeEui64(&GetInstance(), mfgEUI64.m8);
// Compute bloom filter
for (size_t i = 0; i < sizeof(mfgEUI64.m8); i++)
+5 -5
View File
@@ -3502,7 +3502,7 @@ otError MleRouter::RestoreChildren(void)
uint16_t length;
length = sizeof(childInfo);
SuccessOrExit(error = otPlatSettingsGet(GetInstance(), Settings::kKeyChildInfo, i,
SuccessOrExit(error = otPlatSettingsGet(&GetInstance(), Settings::kKeyChildInfo, i,
reinterpret_cast<uint8_t *>(&childInfo), &length));
VerifyOrExit(length >= sizeof(childInfo), error = OT_ERROR_PARSE);
@@ -3531,13 +3531,13 @@ otError MleRouter::RemoveStoredChild(uint16_t aChildRloc16)
Settings::ChildInfo childInfo;
uint16_t length = sizeof(childInfo);
SuccessOrExit(error = otPlatSettingsGet(GetInstance(), Settings::kKeyChildInfo, i,
SuccessOrExit(error = otPlatSettingsGet(&GetInstance(), Settings::kKeyChildInfo, i,
reinterpret_cast<uint8_t *>(&childInfo), &length));
VerifyOrExit(length == sizeof(childInfo), error = OT_ERROR_PARSE);
if (childInfo.mRloc16 == aChildRloc16)
{
error = otPlatSettingsDelete(GetNetif().GetInstance(), Settings::kKeyChildInfo, i);
error = otPlatSettingsDelete(&GetInstance(), Settings::kKeyChildInfo, i);
ExitNow();
}
}
@@ -3563,7 +3563,7 @@ otError MleRouter::StoreChild(uint16_t aChildRloc16)
childInfo.mRloc16 = child->GetRloc16();
childInfo.mMode = child->GetDeviceMode();
error = otPlatSettingsAdd(GetInstance(), Settings::kKeyChildInfo, reinterpret_cast<uint8_t *>(&childInfo),
error = otPlatSettingsAdd(&GetInstance(), Settings::kKeyChildInfo, reinterpret_cast<uint8_t *>(&childInfo),
sizeof(childInfo));
exit:
@@ -3574,7 +3574,7 @@ otError MleRouter::RefreshStoredChildren(void)
{
otError error = OT_ERROR_NONE;
SuccessOrExit(error = otPlatSettingsDelete(GetInstance(), Settings::kKeyChildInfo, -1));
SuccessOrExit(error = otPlatSettingsDelete(&GetInstance(), Settings::kKeyChildInfo, -1));
for (uint8_t i = 0; i < kMaxChildren; i++)
{
+7 -7
View File
@@ -109,15 +109,15 @@ exit:
void SourceMatchController::ClearTable(void)
{
otPlatRadioClearSrcMatchShortEntries(GetInstance());
otPlatRadioClearSrcMatchExtEntries(GetInstance());
otPlatRadioClearSrcMatchShortEntries(&GetInstance());
otPlatRadioClearSrcMatchExtEntries(&GetInstance());
otLogDebgMac(GetInstance(), "SrcAddrMatch - Cleared all entries");
}
void SourceMatchController::Enable(bool aEnable)
{
mEnabled = aEnable;
otPlatRadioEnableSrcMatch(GetInstance(), mEnabled);
otPlatRadioEnableSrcMatch(&GetInstance(), mEnabled);
otLogDebgMac(GetInstance(), "SrcAddrMatch - %sabling", mEnabled ? "En" : "Dis");
}
@@ -146,7 +146,7 @@ otError SourceMatchController::AddAddress(const Child &aChild)
if (aChild.IsIndirectSourceMatchShort())
{
error = otPlatRadioAddSrcMatchShortEntry(GetInstance(), aChild.GetRloc16());
error = otPlatRadioAddSrcMatchShortEntry(&GetInstance(), aChild.GetRloc16());
otLogDebgMac(GetInstance(), "SrcAddrMatch - Adding short addr: 0x%04x -- %s (%d)",
aChild.GetRloc16(), otThreadErrorToString(error), error);
@@ -160,7 +160,7 @@ otError SourceMatchController::AddAddress(const Child &aChild)
addr[i] = aChild.GetExtAddress().m8[sizeof(addr) - 1 - i];
}
error = otPlatRadioAddSrcMatchExtEntry(GetInstance(), addr);
error = otPlatRadioAddSrcMatchExtEntry(&GetInstance(), addr);
otLogDebgMac(GetInstance(), "SrcAddrMatch - Adding addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)",
addr[7], addr[6], addr[5], addr[4], addr[3], addr[2], addr[1], addr[0],
@@ -183,7 +183,7 @@ void SourceMatchController::ClearEntry(Child &aChild)
if (aChild.IsIndirectSourceMatchShort())
{
error = otPlatRadioClearSrcMatchShortEntry(GetInstance(), aChild.GetRloc16());
error = otPlatRadioClearSrcMatchShortEntry(&GetInstance(), aChild.GetRloc16());
otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing short address: 0x%04x -- %s (%d)",
aChild.GetRloc16(), otThreadErrorToString(error), error);
@@ -197,7 +197,7 @@ void SourceMatchController::ClearEntry(Child &aChild)
addr[i] = aChild.GetExtAddress().m8[sizeof(aChild.GetExtAddress()) - 1 - i];
}
error = otPlatRadioClearSrcMatchExtEntry(GetInstance(), addr);
error = otPlatRadioClearSrcMatchExtEntry(&GetInstance(), addr);
otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)",
addr[7], addr[6], addr[5], addr[4], addr[3], addr[2], addr[1], addr[0],
+1 -1
View File
@@ -104,7 +104,7 @@ void ChildSupervisor::SendMessage(Child &aChild)
VerifyOrExit(aChild.GetIndirectMessageCount() == 0);
message = netif.GetInstance()->mMessagePool.New(Message::kTypeSupervision, sizeof(uint8_t));
message = netif.GetInstance().mMessagePool.New(Message::kTypeSupervision, sizeof(uint8_t));
VerifyOrExit(message != NULL);
// Supervision message is an empty payload 15.4 data frame.
+1 -1
View File
@@ -148,7 +148,7 @@ void JamDetector::HandleTimer(void)
VerifyOrExit(mEnabled);
rssi = otPlatRadioGetRssi(GetNetif().GetInstance());
rssi = otPlatRadioGetRssi(&GetInstance());
// If the RSSI is valid, check if it exceeds the threshold
// and try to update the history bit map
+1 -1
View File
@@ -669,7 +669,7 @@ NcpBase::NcpBase(otInstance *aInstance):
mDiscoveryScanJoinerFlag(false),
mDiscoveryScanEnableFiltering(false),
mDiscoveryScanPanId(0xffff),
mUpdateChangedPropsTask(aInstance, &NcpBase::UpdateChangedProps, this),
mUpdateChangedPropsTask(*aInstance, &NcpBase::UpdateChangedProps, this),
mThreadChangedFlags(0),
mChangedPropsSet(),
mHostPowerState(SPINEL_HOST_POWER_STATE_ONLINE),
+1 -1
View File
@@ -105,7 +105,7 @@ NcpSpi::NcpSpi(otInstance *aInstance) :
mTxState(kTxStateIdle),
mHandlingRxFrame(false),
mResetFlag(true),
mPrepareTxFrameTask(aInstance, &NcpSpi::PrepareTxFrame, this),
mPrepareTxFrameTask(*aInstance, &NcpSpi::PrepareTxFrame, this),
mSendFrameLen(0)
{
memset(mSendFrame, 0, kSpiHeaderLength);
+1 -1
View File
@@ -98,7 +98,7 @@ NcpUart::NcpUart(otInstance *aInstance):
mUartBuffer(),
mState(kStartingFrame),
mByte(0),
mUartSendTask(aInstance, EncodeAndSendToUart, this)
mUartSendTask(*aInstance, EncodeAndSendToUart, this)
{
mTxFrameBuffer.SetFrameAddedCallback(HandleFrameAddedToNcpBuffer, this);
+5 -5
View File
@@ -82,19 +82,19 @@ otInstance *testInitInstance(void)
otInstance *instance = NULL;
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
size_t instaneBufferLength = 0;
size_t instanceBufferLength = 0;
uint8_t *instanceBuffer = NULL;
// Call to query the buffer size
(void)otInstanceInit(NULL, &instaneBufferLength);
(void)otInstanceInit(NULL, &instanceBufferLength);
// Call to allocate the buffer
instanceBuffer = (uint8_t *)malloc(instaneBufferLength);
instanceBuffer = (uint8_t *)malloc(instanceBufferLength);
VerifyOrQuit(instanceBuffer != NULL, "Failed to allocate otInstance");
memset(instanceBuffer, 0, instaneBufferLength);
memset(instanceBuffer, 0, instanceBufferLength);
// Initialize OpenThread with the buffer
instance = otInstanceInit(instanceBuffer, &instaneBufferLength);
instance = otInstanceInit(instanceBuffer, &instanceBufferLength);
#else
instance = otInstanceInitSingle();
#endif
+14 -14
View File
@@ -85,7 +85,7 @@ void InitCounters(void)
class TestTimer: public ot::TimerMilli
{
public:
TestTimer(otInstance *aInstance):
TestTimer(otInstance &aInstance):
ot::TimerMilli(aInstance, TestTimer::HandleTimerFired, NULL),
mFiredCounter(0)
{ }
@@ -115,7 +115,7 @@ int TestOneTimer(void)
const uint32_t kTimeT0 = 1000;
const uint32_t kTimerInterval = 10;
otInstance *instance = testInitInstance();
TestTimer timer(instance);
TestTimer timer(*instance);
// Test one Timer basic operation.
@@ -241,8 +241,8 @@ int TestTwoTimers(void)
const uint32_t kTimeT0 = 1000;
const uint32_t kTimerInterval = 10;
otInstance *instance = testInitInstance();
TestTimer timer1(instance);
TestTimer timer2(instance);
TestTimer timer1(*instance);
TestTimer timer2(*instance);
InitTestTimer();
printf("TestTwoTimers() ");
@@ -526,16 +526,16 @@ static void TenTimers(uint32_t aTimeShift)
otInstance *instance = testInitInstance();
TestTimer timer0(instance);
TestTimer timer1(instance);
TestTimer timer2(instance);
TestTimer timer3(instance);
TestTimer timer4(instance);
TestTimer timer5(instance);
TestTimer timer6(instance);
TestTimer timer7(instance);
TestTimer timer8(instance);
TestTimer timer9(instance);
TestTimer timer0(*instance);
TestTimer timer1(*instance);
TestTimer timer2(*instance);
TestTimer timer3(*instance);
TestTimer timer4(*instance);
TestTimer timer5(*instance);
TestTimer timer6(*instance);
TestTimer timer7(*instance);
TestTimer timer8(*instance);
TestTimer timer9(*instance);
TestTimer *timers[kNumTimers] =
{
&timer0,