mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 17:39:51 +00:00
[api] remove otLinkGetPhyChannel*() Link APIs (#3736)
This commit is contained in:
@@ -801,26 +801,6 @@ otError otLinkSetEnabled(otInstance *aInstance, bool aEnable);
|
||||
*/
|
||||
bool otLinkIsEnabled(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function gets the minimum channel number of IEEE 802.15.4 physical layer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The minimum channel number.
|
||||
*
|
||||
*/
|
||||
OTAPI uint8_t OTCALL otLinkGetPhyChannelMin(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function gets the maximum channel number of IEEE 802.15.4 physical layer.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The maximum channel number.
|
||||
*
|
||||
*/
|
||||
OTAPI uint8_t OTCALL otLinkGetPhyChannelMax(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
+12
-3
@@ -554,16 +554,25 @@ void Interpreter::ProcessChannel(int argc, char *argv[])
|
||||
mServer->OutputFormat("enabled: %d\r\n", otChannelMonitorIsEnabled(mInstance));
|
||||
if (otChannelMonitorIsEnabled(mInstance))
|
||||
{
|
||||
uint32_t channelMask = otLinkGetSupportedChannelMask(mInstance);
|
||||
uint8_t channelNum = sizeof(channelMask) * CHAR_BIT;
|
||||
|
||||
mServer->OutputFormat("interval: %lu\r\n", otChannelMonitorGetSampleInterval(mInstance));
|
||||
mServer->OutputFormat("threshold: %d\r\n", otChannelMonitorGetRssiThreshold(mInstance));
|
||||
mServer->OutputFormat("window: %lu\r\n", otChannelMonitorGetSampleWindow(mInstance));
|
||||
mServer->OutputFormat("count: %lu\r\n", otChannelMonitorGetSampleCount(mInstance));
|
||||
|
||||
mServer->OutputFormat("occupancies:\r\n");
|
||||
for (uint8_t channel = otLinkGetPhyChannelMin(mInstance); channel <= otLinkGetPhyChannelMax(mInstance);
|
||||
channel++)
|
||||
for (uint8_t channel = 0; channel < channelNum; channel++)
|
||||
{
|
||||
uint32_t occupancy = otChannelMonitorGetChannelOccupancy(mInstance, channel);
|
||||
uint32_t occupancy = 0;
|
||||
|
||||
if (!((1UL << channel) & channelMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
occupancy = otChannelMonitorGetChannelOccupancy(mInstance, channel);
|
||||
|
||||
mServer->OutputFormat("ch %d (0x%04x) ", channel, occupancy);
|
||||
occupancy = (occupancy * 10000) / 0xffff;
|
||||
|
||||
@@ -431,15 +431,3 @@ uint16_t otLinkGetCcaFailureRate(otInstance *aInstance)
|
||||
|
||||
return instance.Get<Mac::Mac>().GetCcaFailureRate();
|
||||
}
|
||||
|
||||
uint8_t otLinkGetPhyChannelMin(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
return Phy::kChannelMin;
|
||||
}
|
||||
|
||||
uint8_t otLinkGetPhyChannelMax(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
return Phy::kChannelMax;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <openthread/link.h>
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
namespace ot {
|
||||
@@ -191,8 +192,7 @@ void Diag::ProcessChannel(int aArgCount, char *aArgVector[], char *aOutput, size
|
||||
long value;
|
||||
|
||||
SuccessOrExit(error = ParseLong(aArgVector[0], value));
|
||||
VerifyOrExit(value >= otLinkGetPhyChannelMin(sInstance) && value <= otLinkGetPhyChannelMax(sInstance),
|
||||
error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(value >= Phy::kChannelMin && value <= Phy::kChannelMax, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
sChannel = static_cast<uint8_t>(value);
|
||||
otPlatRadioReceive(sInstance, sChannel);
|
||||
|
||||
@@ -2060,10 +2060,17 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHANNEL_MONITOR_SAMPL
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHANNEL_MONITOR_CHANNEL_OCCUPANCY>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t channelMask = otLinkGetSupportedChannelMask(mInstance);
|
||||
uint8_t channelNum = sizeof(channelMask) * CHAR_BIT;
|
||||
|
||||
for (uint8_t channel = otLinkGetPhyChannelMin(mInstance); channel <= otLinkGetPhyChannelMax(mInstance); channel++)
|
||||
for (uint8_t channel = 0; channel < channelNum; channel++)
|
||||
{
|
||||
if (!((1UL << channel) & channelMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SuccessOrExit(error = mEncoder.OpenStruct());
|
||||
|
||||
SuccessOrExit(error = mEncoder.WriteUint8(channel));
|
||||
|
||||
Reference in New Issue
Block a user