mirror of
https://github.com/espressif/openthread.git
synced 2026-09-04 00:00:06 +00:00
[radio] add radio folder to core (#4045)
This commit renames existing `phy` folder into `radio`. It also renames some of the related files in this folder. It also moves all default/weak `otPlatRadio` implementations to a common `radio_platform_defaults.cpp` file.
This commit is contained in:
committed by
Jonathan Hui
parent
6ebc517408
commit
b1d92846c0
+1
-1
@@ -188,7 +188,7 @@ LOCAL_SRC_FILES := \
|
||||
src/core/net/ip6_mpl.cpp \
|
||||
src/core/net/netif.cpp \
|
||||
src/core/net/udp6.cpp \
|
||||
src/core/phy/radio_weak.cpp \
|
||||
src/core/radio/radio_platform_defaults.cpp \
|
||||
src/core/thread/address_resolver.cpp \
|
||||
src/core/thread/announce_begin_server.cpp \
|
||||
src/core/thread/announce_sender.cpp \
|
||||
|
||||
@@ -194,7 +194,7 @@ SOURCES_COMMON = \
|
||||
net/netif.cpp \
|
||||
net/sntp_client.cpp \
|
||||
net/udp6.cpp \
|
||||
phy/radio_weak.cpp \
|
||||
radio/radio_platform_defaults.cpp \
|
||||
thread/address_resolver.cpp \
|
||||
thread/announce_begin_server.cpp \
|
||||
thread/announce_sender.cpp \
|
||||
@@ -255,7 +255,7 @@ libopenthread_radio_a_SOURCES = \
|
||||
mac/mac_frame.cpp \
|
||||
mac/sub_mac.cpp \
|
||||
mac/sub_mac_callbacks.cpp \
|
||||
phy/radio_weak.cpp \
|
||||
radio/radio_platform_defaults.cpp \
|
||||
thread/link_quality.cpp \
|
||||
utils/missing_strlcat.c \
|
||||
utils/missing_strlcpy.c \
|
||||
@@ -390,7 +390,7 @@ HEADERS_COMMON = \
|
||||
net/socket.hpp \
|
||||
net/tcp.hpp \
|
||||
net/udp6.hpp \
|
||||
phy/phy.hpp \
|
||||
radio/radio.hpp \
|
||||
thread/address_resolver.hpp \
|
||||
thread/announce_begin_server.hpp \
|
||||
thread/announce_sender.hpp \
|
||||
|
||||
@@ -155,9 +155,3 @@ const char *otGetRadioVersionString(otInstance *aInstance)
|
||||
{
|
||||
return otPlatRadioGetVersionString(aInstance);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK const char *otPlatRadioGetVersionString(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
return otGetVersionString();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/locator-getters.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
using namespace ot;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "utils/parse_cmdline.hpp"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
@@ -71,7 +71,7 @@ void Diags::ProcessChannel(int aArgCount, char *aArgVector[], char *aOutput, siz
|
||||
VerifyOrExit(aArgCount == 1, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
SuccessOrExit(error = ParseLong(aArgVector[0], value));
|
||||
VerifyOrExit(value >= Phy::kChannelMin && value <= Phy::kChannelMax, error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(value >= Radio::kChannelMin && value <= Radio::kChannelMax, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
mChannel = static_cast<uint8_t>(value);
|
||||
otPlatDiagChannelSet(mChannel);
|
||||
@@ -172,7 +172,7 @@ void Diags::ProcessChannel(int aArgCount, char *aArgVector[], char *aOutput, siz
|
||||
long value;
|
||||
|
||||
SuccessOrExit(error = ParseLong(aArgVector[0], value));
|
||||
VerifyOrExit(value >= Phy::kChannelMin && value <= Phy::kChannelMax, error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(value >= Radio::kChannelMin && value <= Radio::kChannelMax, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
mChannel = static_cast<uint8_t>(value);
|
||||
otPlatRadioReceive(&GetInstance(), mChannel);
|
||||
|
||||
@@ -58,10 +58,10 @@ otError ChannelMask::GetNextChannel(uint8_t &aChannel) const
|
||||
|
||||
if (aChannel == kChannelIteratorFirst)
|
||||
{
|
||||
aChannel = (Phy::kChannelMin - 1);
|
||||
aChannel = (Radio::kChannelMin - 1);
|
||||
}
|
||||
|
||||
for (aChannel++; aChannel <= Phy::kChannelMax; aChannel++)
|
||||
for (aChannel++; aChannel <= Radio::kChannelMax; aChannel++)
|
||||
{
|
||||
if (ContainsChannel(aChannel))
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/string.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
InfoString ToString(void) const;
|
||||
|
||||
private:
|
||||
OT_STATIC_ASSERT((Phy::kChannelMin < 32) && (Phy::kChannelMax < 32),
|
||||
OT_STATIC_ASSERT((Radio::kChannelMin < 32) && (Radio::kChannelMax < 32),
|
||||
"The channel number is larger than 32. `ChannelMask` uses 32 bit mask.");
|
||||
uint32_t mMask;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "crypto/aes_ccm.hpp"
|
||||
#include "crypto/sha256.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "thread/link_quality.hpp"
|
||||
#include "thread/mle_router.hpp"
|
||||
#include "thread/thread_netif.hpp"
|
||||
@@ -96,7 +96,7 @@ Mac::Mac(Instance &aInstance)
|
||||
, mRadioChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL)
|
||||
, mRadioChannelAcquisitionId(0)
|
||||
, mSupportedChannelMask(otPlatRadioGetSupportedChannelMask(&aInstance))
|
||||
, mScanChannel(Phy::kChannelMin)
|
||||
, mScanChannel(Radio::kChannelMin)
|
||||
, mScanDuration(0)
|
||||
, mScanChannelMask()
|
||||
, mActiveScanHandler(NULL) /* Initialize `mActiveScanHandler` and `mEnergyScanHandler` union */
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "common/logging.hpp"
|
||||
#include "meshcop/meshcop.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "thread/thread_netif.hpp"
|
||||
#include "thread/thread_tlvs.hpp"
|
||||
#include "thread/thread_uri_paths.hpp"
|
||||
|
||||
@@ -121,8 +121,8 @@ bool ChannelTlv::IsValid(void) const
|
||||
|
||||
VerifyOrExit(GetLength() == sizeof(*this) - sizeof(Tlv));
|
||||
VerifyOrExit(mChannelPage <= OT_RADIO_CHANNEL_PAGE_MAX);
|
||||
VerifyOrExit((1U << mChannelPage) & Phy::kSupportedChannelPages);
|
||||
VerifyOrExit(Phy::kChannelMin <= GetChannel() && GetChannel() <= Phy::kChannelMax);
|
||||
VerifyOrExit((1U << mChannelPage) & Radio::kSupportedChannelPages);
|
||||
VerifyOrExit(Radio::kChannelMin <= GetChannel() && GetChannel() <= Radio::kChannelMax);
|
||||
ret = true;
|
||||
|
||||
exit:
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "common/tlvs.hpp"
|
||||
#include "meshcop/timestamp.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
@@ -1661,7 +1661,7 @@ public:
|
||||
private:
|
||||
enum
|
||||
{
|
||||
kNumMaskEntries = Phy::kNumChannelPages,
|
||||
kNumMaskEntries = Radio::kNumChannelPages,
|
||||
};
|
||||
|
||||
ChannelMaskEntry mEntries[kNumMaskEntries];
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes definitions for the IEEE 802.15.4 PHY.
|
||||
* This file includes definitions for OpenThread definition of radio abstraction.
|
||||
*/
|
||||
|
||||
#ifndef PHY_HPP_
|
||||
#define PHY_HPP_
|
||||
#ifndef RADIO_HPP_
|
||||
#define RADIO_HPP_
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
@@ -43,16 +43,16 @@
|
||||
namespace ot {
|
||||
|
||||
/**
|
||||
* @addtogroup core-phy
|
||||
* @addtogroup core-radio
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions for the IEEE 802.15.4 PHY
|
||||
* This module includes definitions for OpenThread radio abstraction.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Phy {
|
||||
namespace Radio {
|
||||
|
||||
/**
|
||||
* This enumeration defines the IEEE 802.15.4 channel related parameters.
|
||||
@@ -84,7 +84,7 @@ enum
|
||||
OT_STATIC_ASSERT((OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT || OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT),
|
||||
"OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT or OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT "
|
||||
"must be set to 1 to specify the radio mode");
|
||||
} // namespace Phy
|
||||
} // namespace Radio
|
||||
} // namespace ot
|
||||
|
||||
#endif // PHY_HPP_
|
||||
#endif // RADIO_HPP_
|
||||
@@ -27,12 +27,12 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the default radio platform APIs.
|
||||
* This file implements the default/weak radio platform APIs.
|
||||
*/
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
using namespace ot;
|
||||
|
||||
@@ -40,10 +40,16 @@ OT_TOOL_WEAK uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return Phy::kSupportedChannels;
|
||||
return Radio::kSupportedChannels;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK uint32_t otPlatRadioGetPreferredChannelMask(otInstance *aInstance)
|
||||
{
|
||||
return otPlatRadioGetSupportedChannelMask(aInstance);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK const char *otPlatRadioGetVersionString(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
return otGetVersionString();
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "common/random.hpp"
|
||||
#include "meshcop/meshcop.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "net/netif.hpp"
|
||||
#include "net/tcp.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/mle_router.hpp"
|
||||
#include "thread/thread_netif.hpp"
|
||||
|
||||
@@ -422,7 +422,7 @@ otError NetworkDiagnostic::FillRequestedTlvs(Message & aRequest,
|
||||
case NetworkDiagnosticTlv::kChannelPages:
|
||||
{
|
||||
uint8_t length = 0;
|
||||
uint8_t pageMask = Phy::kSupportedChannelPages;
|
||||
uint8_t pageMask = Radio::kSupportedChannelPages;
|
||||
ChannelPagesTlv tlv;
|
||||
|
||||
tlv.Init();
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "common/tlvs.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "thread/device_mode.hpp"
|
||||
#include "thread/mle_constants.hpp"
|
||||
|
||||
@@ -1377,7 +1377,7 @@ public:
|
||||
uint8_t *GetChannelPages(void) { return mChannelPages; }
|
||||
|
||||
private:
|
||||
uint8_t mChannelPages[Phy::kNumChannelPages];
|
||||
uint8_t mChannelPages[Radio::kNumChannelPages];
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "common/locator-getters.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "common/random.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ uint16_t ChannelMonitor::GetChannelOccupancy(uint8_t aChannel) const
|
||||
{
|
||||
uint16_t occupancy = 0;
|
||||
|
||||
VerifyOrExit((Phy::kChannelMin <= aChannel) && (aChannel <= Phy::kChannelMax));
|
||||
occupancy = mChannelOccupancy[aChannel - Phy::kChannelMin];
|
||||
VerifyOrExit((Radio::kChannelMin <= aChannel) && (aChannel <= Radio::kChannelMax));
|
||||
occupancy = mChannelOccupancy[aChannel - Radio::kChannelMin];
|
||||
|
||||
exit:
|
||||
return occupancy;
|
||||
@@ -146,7 +146,7 @@ void ChannelMonitor::HandleEnergyScanResult(otEnergyScanResult *aResult)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t channelIndex = (aResult->mChannel - Phy::kChannelMin);
|
||||
uint8_t channelIndex = (aResult->mChannel - Radio::kChannelMin);
|
||||
uint32_t newAverage = mChannelOccupancy[channelIndex];
|
||||
uint32_t newValue = 0;
|
||||
uint32_t weight;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "common/locator.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Utils {
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
#else
|
||||
kNumChannelMasks = 4,
|
||||
#endif
|
||||
kNumChannels = (Phy::kChannelMax - Phy::kChannelMin + 1),
|
||||
kNumChannels = (Radio::kChannelMax - Radio::kChannelMin + 1),
|
||||
kTimerInterval = (kSampleInterval / kNumChannelMasks),
|
||||
kMaxJitterInterval = 4096,
|
||||
kMaxOccupancy = 0xffff,
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
@@ -204,7 +204,7 @@ NcpBase::NcpBase(Instance *aInstance)
|
||||
, mDecoder()
|
||||
, mHostPowerStateInProgress(false)
|
||||
, mLastStatus(SPINEL_STATUS_OK)
|
||||
, mScanChannelMask(Phy::kSupportedChannels)
|
||||
, mScanChannelMask(Radio::kSupportedChannels)
|
||||
, mScanPeriod(200)
|
||||
, mDiscoveryScanJoinerFlag(false)
|
||||
, mDiscoveryScanEnableFiltering(false)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "common/debug.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#include "test_util.h"
|
||||
@@ -94,7 +94,7 @@ void VerifyChannelMaskContent(const Mac::ChannelMask &aMask, uint8_t *aChannels,
|
||||
uint8_t index = 0;
|
||||
uint8_t channel;
|
||||
|
||||
for (channel = Phy::kChannelMin; channel <= Phy::kChannelMax; channel++)
|
||||
for (channel = Radio::kChannelMin; channel <= Radio::kChannelMax; channel++)
|
||||
{
|
||||
if (index < aLength)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ void TestMacChannelMask(void)
|
||||
uint8_t channles4[] = {20};
|
||||
|
||||
Mac::ChannelMask mask1;
|
||||
Mac::ChannelMask mask2(Phy::kSupportedChannels);
|
||||
Mac::ChannelMask mask2(Radio::kSupportedChannels);
|
||||
|
||||
printf("Testing Mac::ChannelMask\n");
|
||||
|
||||
@@ -149,12 +149,12 @@ void TestMacChannelMask(void)
|
||||
printf("empty = %s\n", mask1.ToString().AsCString());
|
||||
|
||||
VerifyOrQuit(!mask2.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask2.GetMask() == Phy::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
VerifyOrQuit(mask2.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
printf("all_channels = %s\n", mask2.ToString().AsCString());
|
||||
|
||||
mask1.SetMask(Phy::kSupportedChannels);
|
||||
mask1.SetMask(Radio::kSupportedChannels);
|
||||
VerifyOrQuit(!mask1.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask1.GetMask() == Phy::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
VerifyOrQuit(mask1.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
|
||||
VerifyChannelMaskContent(mask1, all_channels, sizeof(all_channels));
|
||||
|
||||
@@ -204,8 +204,8 @@ void TestMacChannelMask(void)
|
||||
mask2.Clear();
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed\n");
|
||||
|
||||
mask1.SetMask(Phy::kSupportedChannels);
|
||||
mask2.SetMask(Phy::kSupportedChannels);
|
||||
mask1.SetMask(Radio::kSupportedChannels);
|
||||
mask2.SetMask(Radio::kSupportedChannels);
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed\n");
|
||||
|
||||
mask1.Clear();
|
||||
|
||||
Reference in New Issue
Block a user