From 515519f7b6fe5eaad4042dce617904470b56e638 Mon Sep 17 00:00:00 2001 From: Buke Po Date: Wed, 2 Aug 2017 00:50:52 +0800 Subject: [PATCH] [mac] enable radio layer before setting parameters (#2048) This commit adjusts the order for calling radio layer API to make sure otPlatRadioEnable() is the first called to radio layer. This mainly addresses the issue of otInstance which is not provided when initializing radio layer. --- src/core/common/logging.hpp | 2 +- src/core/mac/mac.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp index 4e47f15d5..4ab4c4d96 100644 --- a/src/core/common/logging.hpp +++ b/src/core/common/logging.hpp @@ -310,7 +310,7 @@ extern "C" { #define otLogCritMle(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__) #define otLogWarnMle(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__) #define otLogWarnMleErr(aInstance, aError, aFormat, ...) \ - otLogWarn(&aInstance, OT_LOG_REGION_MAC, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__) + otLogWarn(&aInstance, OT_LOG_REGION_MLE, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__) #define otLogInfoMle(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__) #define otLogDebgMle(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__) #else diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 0719d5403..ba15b8456 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -185,13 +185,13 @@ Mac::Mac(ThreadNetif &aThreadNetif): memset(&mCounters, 0, sizeof(otMacCounters)); + otPlatRadioEnable(&GetInstance()); + SetExtendedPanId(sExtendedPanidInit); SetNetworkName(sNetworkNameInit); SetPanId(mPanId); SetExtAddress(mExtAddress); SetShortAddress(mShortAddress); - - otPlatRadioEnable(&GetInstance()); } otError Mac::ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler, void *aContext)