From 67c2c04f0e615956d39208df0a6acee08a48a154 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Wed, 25 May 2022 01:47:30 +0800 Subject: [PATCH] [log] add region code log (#7740) This commit adds log to record the region code to help developers know which region code is currently in use from log. --- src/lib/spinel/radio_spinel_impl.hpp | 17 ++++++++++++++++- src/posix/platform/radio_url.cpp | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/spinel/radio_spinel_impl.hpp b/src/lib/spinel/radio_spinel_impl.hpp index c6c02e288..176e79419 100644 --- a/src/lib/spinel/radio_spinel_impl.hpp +++ b/src/lib/spinel/radio_spinel_impl.hpp @@ -2409,7 +2409,22 @@ exit: template otError RadioSpinel::SetRadioRegion(uint16_t aRegionCode) { - return Set(SPINEL_PROP_PHY_REGION_CODE, SPINEL_DATATYPE_UINT16_S, aRegionCode); + otError error; + + error = Set(SPINEL_PROP_PHY_REGION_CODE, SPINEL_DATATYPE_UINT16_S, aRegionCode); + + if (error == OT_ERROR_NONE) + { + otLogNotePlat("Set region code \"%c%c\" successfully", static_cast(aRegionCode >> 8), + static_cast(aRegionCode)); + } + else + { + otLogWarnPlat("Failed to set region code \"%c%c\": %s", static_cast(aRegionCode >> 8), + static_cast(aRegionCode), otThreadErrorToString(error)); + } + + return error; } template diff --git a/src/posix/platform/radio_url.cpp b/src/posix/platform/radio_url.cpp index 54e9be0a2..c126663b9 100644 --- a/src/posix/platform/radio_url.cpp +++ b/src/posix/platform/radio_url.cpp @@ -89,7 +89,8 @@ const char *otSysGetRadioUrlHelpString(void) #endif return "RadioURL:\n" OT_RADIO_URL_HELP_BUS OT_RADIO_URL_HELP_MAX_POWER_TABLE - " region[=region-code] Set the radio's region code.\n" + " region[=region-code] Set the radio's region code. The region code must be an\n" + " ISO 3166 alpha-2 code.\n" " cca-threshold[=dbm] Set the radio's CCA ED threshold in dBm measured at antenna connector.\n" " enable-coex[=1|0] If not specified, RCP coex operates with its default configuration.\n" " Disable coex with 0, and enable it with other values.\n"