mirror of
https://github.com/espressif/openthread.git
synced 2026-08-29 13:29:54 +00:00
[commissioner] clean up member variable and type formatting (#12667)
This commit reorganizes the member variables in the `Commissioner` class, ordering them to optimize memory packing. Additionally, it shortens the local typedef names for callback function pointers, such as renaming `otCommissionerEnergyReportCallback` to the more concise `EnergyReportCallback`, improving overall readability. Finally, it aligns parameter formatting in method signatures like `SendEnergyScanQuery()` and `SendPanIdQuery()`.
This commit is contained in:
@@ -49,10 +49,10 @@ Commissioner::Commissioner(Instance &aInstance)
|
||||
, mJoinerRloc(0)
|
||||
, mSessionId(0)
|
||||
, mTransmitAttempts(0)
|
||||
, mState(kStateDisabled)
|
||||
, mJoinerExpirationTimer(aInstance)
|
||||
, mTimer(aInstance)
|
||||
, mJoinerSessionTimer(aInstance)
|
||||
, mState(kStateDisabled)
|
||||
{
|
||||
ClearAllBytes(mJoiners);
|
||||
|
||||
@@ -1033,13 +1033,13 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Commissioner::SendEnergyScanQuery(uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
uint16_t aScanDuration,
|
||||
const Ip6::Address &aAddress,
|
||||
otCommissionerEnergyReportCallback aCallback,
|
||||
void *aContext)
|
||||
Error Commissioner::SendEnergyScanQuery(uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
uint16_t aScanDuration,
|
||||
const Ip6::Address &aAddress,
|
||||
EnergyReportCallback aCallback,
|
||||
void *aContext)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Coap::Message *message = nullptr;
|
||||
@@ -1091,11 +1091,11 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
Error Commissioner::SendPanIdQuery(uint16_t aPanId,
|
||||
uint32_t aChannelMask,
|
||||
const Ip6::Address &aAddress,
|
||||
otCommissionerPanIdConflictCallback aCallback,
|
||||
void *aContext)
|
||||
Error Commissioner::SendPanIdQuery(uint16_t aPanId,
|
||||
uint32_t aChannelMask,
|
||||
const Ip6::Address &aAddress,
|
||||
PanIdConflictCallback aCallback,
|
||||
void *aContext)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Coap::Message *message = nullptr;
|
||||
|
||||
@@ -92,8 +92,10 @@ public:
|
||||
kJoinerEventRemoved = OT_COMMISSIONER_JOINER_REMOVED,
|
||||
};
|
||||
|
||||
typedef otCommissionerStateCallback StateCallback; ///< State change callback function pointer type.
|
||||
typedef otCommissionerJoinerCallback JoinerCallback; ///< Joiner state change callback function pointer type.
|
||||
typedef otCommissionerStateCallback StateCallback; ///< State change callback type.
|
||||
typedef otCommissionerJoinerCallback JoinerCallback; ///< Joiner state change callback type.
|
||||
typedef otCommissionerEnergyReportCallback EnergyReportCallback; ///< Energy report callback type.
|
||||
typedef otCommissionerPanIdConflictCallback PanIdConflictCallback; ///< PAN ID conflict callback type.
|
||||
|
||||
/**
|
||||
* Initializes the Commissioner object.
|
||||
@@ -335,38 +337,38 @@ public:
|
||||
* @param[in] aCount The number of energy measurements per channel.
|
||||
* @param[in] aPeriod The time between energy measurements (milliseconds).
|
||||
* @param[in] aScanDuration The scan duration for each energy measurement (milliseconds).
|
||||
* @param[in] aAddress A pointer to the IPv6 destination.
|
||||
* @param[in] aCallback A pointer to a function called on receiving an Energy Report message.
|
||||
* @param[in] aAddress The IPv6 destination.
|
||||
* @param[in] aCallback Callback function called to report Energy Scan results.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval kErrorNone Successfully enqueued the Energy Scan Query message.
|
||||
* @retval kErrorNoBufs Insufficient buffers to generate an Energy Scan Query message.
|
||||
*/
|
||||
Error SendEnergyScanQuery(uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
uint16_t aScanDuration,
|
||||
const Ip6::Address &aAddress,
|
||||
otCommissionerEnergyReportCallback aCallback,
|
||||
void *aContext);
|
||||
Error SendEnergyScanQuery(uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
uint16_t aPeriod,
|
||||
uint16_t aScanDuration,
|
||||
const Ip6::Address &aAddress,
|
||||
EnergyReportCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
/**
|
||||
* Sends a PAN ID Query message.
|
||||
*
|
||||
* @param[in] aPanId The PAN ID to query.
|
||||
* @param[in] aChannelMask The channel mask value.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination.
|
||||
* @param[in] aCallback A pointer to a function called on receiving an Energy Report message.
|
||||
* @param[in] aAddress The IPv6 destination.
|
||||
* @param[in] aCallback Callback function to report PAN ID conflicts.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval kErrorNone Successfully enqueued the PAN ID Query message.
|
||||
* @retval kErrorNoBufs Insufficient buffers to generate a PAN ID Query message.
|
||||
*/
|
||||
Error SendPanIdQuery(uint16_t aPanId,
|
||||
uint32_t aChannelMask,
|
||||
const Ip6::Address &aAddress,
|
||||
otCommissionerPanIdConflictCallback aCallback,
|
||||
void *aContext);
|
||||
Error SendPanIdQuery(uint16_t aPanId,
|
||||
uint32_t aChannelMask,
|
||||
const Ip6::Address &aAddress,
|
||||
PanIdConflictCallback aCallback,
|
||||
void *aContext);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t kPetitionAttemptDelay = 5; // COMM_PET_ATTEMPT_DELAY (seconds)
|
||||
@@ -375,6 +377,8 @@ private:
|
||||
static constexpr uint32_t kKeepAliveTimeout = 50; // TIMEOUT_COMM_PET (seconds)
|
||||
static constexpr uint32_t kRemoveJoinerDelay = 20; // Delay to remove successfully joined joiner
|
||||
|
||||
static constexpr uint16_t kMaxJoinerEntries = OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES;
|
||||
|
||||
static constexpr uint32_t kJoinerSessionTimeoutMillis =
|
||||
1000 * OPENTHREAD_CONFIG_COMMISSIONER_JOINER_SESSION_TIMEOUT; // Expiration time for active Joiner session
|
||||
|
||||
@@ -460,29 +464,24 @@ private:
|
||||
using CommissionerTimer = TimerMilliIn<Commissioner, &Commissioner::HandleTimer>;
|
||||
using JoinerSessionTimer = TimerMilliIn<Commissioner, &Commissioner::HandleJoinerSessionTimer>;
|
||||
|
||||
Joiner mJoiners[OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES];
|
||||
|
||||
Joiner *mActiveJoiner;
|
||||
Ip6::InterfaceIdentifier mJoinerIid;
|
||||
uint16_t mJoinerPort;
|
||||
uint16_t mJoinerRloc;
|
||||
uint16_t mSessionId;
|
||||
uint8_t mTransmitAttempts;
|
||||
JoinerExpirationTimer mJoinerExpirationTimer;
|
||||
CommissionerTimer mTimer;
|
||||
JoinerSessionTimer mJoinerSessionTimer;
|
||||
|
||||
Ip6::Netif::UnicastAddress mCommissionerAloc;
|
||||
|
||||
ProvisioningUrlTlv::StringType mProvisioningUrl;
|
||||
CommissionerIdTlv::StringType mCommissionerId;
|
||||
|
||||
State mState;
|
||||
|
||||
Callback<StateCallback> mStateCallback;
|
||||
Callback<JoinerCallback> mJoinerCallback;
|
||||
Callback<otCommissionerEnergyReportCallback> mEnergyReportCallback;
|
||||
Callback<otCommissionerPanIdConflictCallback> mPanIdConflictCallback;
|
||||
Joiner mJoiners[kMaxJoinerEntries];
|
||||
Joiner *mActiveJoiner;
|
||||
Ip6::InterfaceIdentifier mJoinerIid;
|
||||
uint16_t mJoinerPort;
|
||||
uint16_t mJoinerRloc;
|
||||
uint16_t mSessionId;
|
||||
uint8_t mTransmitAttempts;
|
||||
State mState;
|
||||
JoinerExpirationTimer mJoinerExpirationTimer;
|
||||
CommissionerTimer mTimer;
|
||||
JoinerSessionTimer mJoinerSessionTimer;
|
||||
Ip6::Netif::UnicastAddress mCommissionerAloc;
|
||||
ProvisioningUrlTlv::StringType mProvisioningUrl;
|
||||
CommissionerIdTlv::StringType mCommissionerId;
|
||||
Callback<StateCallback> mStateCallback;
|
||||
Callback<JoinerCallback> mJoinerCallback;
|
||||
Callback<EnergyReportCallback> mEnergyReportCallback;
|
||||
Callback<PanIdConflictCallback> mPanIdConflictCallback;
|
||||
};
|
||||
|
||||
DeclareTmfHandler(Commissioner, kUriDatasetChanged);
|
||||
|
||||
Reference in New Issue
Block a user