Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[options] add an option to control power calibration #2590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,10 @@ if (OTBR_LINK_METRICS_TELEMETRY)
else()
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_LINK_METRICS_TELEMETRY=0)
endif()

option(OTBR_POWER_CALIBRATION "Enable Power Calibration" ON)
if (OTBR_POWER_CALIBRATION)
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_POWER_CALIBRATION=1)
else()
target_compile_definitions(otbr-config INTERFACE OTBR_ENABLE_POWER_CALIBRATION=0)
endif()
2 changes: 2 additions & 0 deletions src/ncp/ncp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void NcpHost::GetChannelMasks(const ChannelMasksReceiver &aReceiver, const Async
mTaskRunner.Post([aErrReceiver](void) { aErrReceiver(OT_ERROR_NOT_IMPLEMENTED, "Not implemented!"); });
}

#if OTBR_ENABLE_POWER_CALIBRATION
void NcpHost::SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMaxPowers,
const AsyncResultReceiver &aReceiver)
{
Expand All @@ -202,6 +203,7 @@ void NcpHost::SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMa
// TODO: Implement SetChannelMaxPowers under NCP mode.
mTaskRunner.Post([aReceiver](void) { aReceiver(OT_ERROR_NOT_IMPLEMENTED, "Not implemented!"); });
}
#endif

void NcpHost::AddThreadStateChangedCallback(ThreadStateChangedCallback aCallback)
{
Expand Down
20 changes: 14 additions & 6 deletions src/ncp/ncp_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,22 @@ class NcpHost : public MainloopProcessor, public ThreadHost, public NcpNetworkPr
void SetThreadEnabled(bool aEnabled, const AsyncResultReceiver aReceiver) override;
void SetCountryCode(const std::string &aCountryCode, const AsyncResultReceiver &aReceiver) override;
void GetChannelMasks(const ChannelMasksReceiver &aReceiver, const AsyncResultReceiver &aErrReceiver) override;
#if OTBR_ENABLE_POWER_CALIBRATION
void SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMaxPowers,
const AsyncResultReceiver &aReceiver) override;
void AddThreadStateChangedCallback(ThreadStateChangedCallback aCallback) override;
CoprocessorType GetCoprocessorType(void) override { return OT_COPROCESSOR_NCP; }
const char *GetCoprocessorVersion(void) override;
const char *GetInterfaceName(void) const override { return mConfig.mInterfaceName; }
void Init(void) override;
void Deinit(void) override;
#endif
void AddThreadStateChangedCallback(ThreadStateChangedCallback aCallback) override;
CoprocessorType GetCoprocessorType(void) override
{
return OT_COPROCESSOR_NCP;
}
const char *GetCoprocessorVersion(void) override;
const char *GetInterfaceName(void) const override
{
return mConfig.mInterfaceName;
}
void Init(void) override;
void Deinit(void) override;

// MainloopProcessor methods
void Update(MainloopContext &aMainloop) override;
Expand Down
2 changes: 2 additions & 0 deletions src/ncp/rcp_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ void RcpHost::GetChannelMasks(const ChannelMasksReceiver &aReceiver, const Async
}
}

#if OTBR_ENABLE_POWER_CALIBRATION
void RcpHost::SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMaxPowers,
const AsyncResultReceiver &aReceiver)
{
Expand Down Expand Up @@ -549,6 +550,7 @@ void RcpHost::SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMa
exit:
mTaskRunner.Post([aReceiver, error, errorMsg](void) { aReceiver(error, errorMsg); });
}
#endif // OTBR_ENABLE_POWER_CALIBRATION

void RcpHost::DisableThreadAfterDetach(void *aContext)
{
Expand Down
2 changes: 2 additions & 0 deletions src/ncp/rcp_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ class RcpHost : public MainloopProcessor, public ThreadHost, public OtNetworkPro
void SetThreadEnabled(bool aEnabled, const AsyncResultReceiver aReceiver) override;
void SetCountryCode(const std::string &aCountryCode, const AsyncResultReceiver &aReceiver) override;
void GetChannelMasks(const ChannelMasksReceiver &aReceiver, const AsyncResultReceiver &aErrReceiver) override;
#if OTBR_ENABLE_POWER_CALIBRATION
void SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMaxPowers,
const AsyncResultReceiver &aReceiver) override;
#endif
void AddThreadStateChangedCallback(ThreadStateChangedCallback aCallback) override;

CoprocessorType GetCoprocessorType(void) override
Expand Down
2 changes: 2 additions & 0 deletions src/ncp/thread_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class ThreadHost : virtual public NetworkProperties
*/
virtual void GetChannelMasks(const ChannelMasksReceiver &aReceiver, const AsyncResultReceiver &aErrReceiver) = 0;

#if OTBR_ENABLE_POWER_CALIBRATION
/**
* Sets the max power of each channel.
*
Expand All @@ -201,6 +202,7 @@ class ThreadHost : virtual public NetworkProperties
*/
virtual void SetChannelMaxPowers(const std::vector<ChannelMaxPower> &aChannelMaxPowers,
const AsyncResultReceiver &aReceiver) = 0;
#endif

/**
* This method adds a event listener for Thread state changes.
Expand Down
Loading