mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 06:37:46 +00:00
[coap] change AddResource() to return void (#4942)
This commit is contained in:
@@ -850,11 +850,8 @@ otError otCoapStop(otInstance *aInstance);
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added @p aResource.
|
||||
* @retval OT_ERROR_ALREADY The @p aResource was already added.
|
||||
*
|
||||
*/
|
||||
otError otCoapAddResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
void otCoapAddResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
|
||||
/**
|
||||
* This function removes a resource from the CoAP server.
|
||||
|
||||
@@ -257,11 +257,8 @@ otError otCoapSecureSendRequest(otInstance * aInstance,
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aResource A pointer to the resource.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added @p aResource.
|
||||
* @retval OT_ERROR_ALREADY The @p aResource was already added.
|
||||
*
|
||||
*/
|
||||
otError otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
void otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource);
|
||||
|
||||
/**
|
||||
* This function removes a resource from the CoAP Secure server.
|
||||
|
||||
@@ -193,7 +193,7 @@ otError Coap::ProcessResource(uint8_t aArgsLength, char *aArgs[])
|
||||
mResource.mHandler = &Coap::HandleRequest;
|
||||
|
||||
strncpy(mUriPath, aArgs[1], sizeof(mUriPath) - 1);
|
||||
SuccessOrExit(error = otCoapAddResource(mInterpreter.mInstance, &mResource));
|
||||
otCoapAddResource(mInterpreter.mInstance, &mResource);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ otError CoapSecure::ProcessResource(uint8_t aArgsLength, char *aArgs[])
|
||||
mResource.mHandler = &CoapSecure::HandleRequest;
|
||||
|
||||
strncpy(mUriPath, aArgs[1], sizeof(mUriPath) - 1);
|
||||
SuccessOrExit(error = otCoapSecureAddResource(mInterpreter.mInstance, &mResource));
|
||||
otCoapSecureAddResource(mInterpreter.mInstance, &mResource);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -132,7 +132,7 @@ otError CoapSecure::ProcessResource(uint8_t aArgsLength, char *aArgs[])
|
||||
}
|
||||
|
||||
exit:
|
||||
return OT_ERROR_NONE;
|
||||
return error;
|
||||
}
|
||||
|
||||
otError CoapSecure::ProcessStart(uint8_t aArgsLength, char *aArgs[])
|
||||
|
||||
@@ -249,11 +249,11 @@ otError otCoapStop(otInstance *aInstance)
|
||||
return instance.GetApplicationCoap().Stop();
|
||||
}
|
||||
|
||||
otError otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
void otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetApplicationCoap().AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
instance.GetApplicationCoap().AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
void otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
|
||||
@@ -161,11 +161,11 @@ otError otCoapSecureSendRequest(otInstance * aInstance,
|
||||
return instance.GetApplicationCoapSecure().SendMessage(*static_cast<Coap::Message *>(aMessage), aHandler, aContext);
|
||||
}
|
||||
|
||||
otError otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
void otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetApplicationCoapSecure().AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
instance.GetApplicationCoapSecure().AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
void otCoapSecureRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
|
||||
@@ -90,9 +90,9 @@ void CoapBase::ClearRequests(const Ip6::Address *aAddress)
|
||||
}
|
||||
}
|
||||
|
||||
otError CoapBase::AddResource(Resource &aResource)
|
||||
void CoapBase::AddResource(Resource &aResource)
|
||||
{
|
||||
return mResources.Add(aResource);
|
||||
IgnoreError(mResources.Add(aResource));
|
||||
}
|
||||
|
||||
void CoapBase::RemoveResource(Resource &aResource)
|
||||
|
||||
@@ -307,11 +307,8 @@ public:
|
||||
*
|
||||
* @param[in] aResource A reference to the resource.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added @p aResource.
|
||||
* @retval OT_ERROR_ALREADY The @p aResource was already added.
|
||||
*
|
||||
*/
|
||||
otError AddResource(Resource &aResource);
|
||||
void AddResource(Resource &aResource);
|
||||
|
||||
/**
|
||||
* This method removes a resource from the CoAP server.
|
||||
|
||||
@@ -676,18 +676,18 @@ otError BorderAgent::Start(void)
|
||||
SuccessOrExit(error = coaps.SetPsk(Get<KeyManager>().GetPskc().m8, OT_PSKC_MAX_SIZE));
|
||||
coaps.SetConnectedCallback(HandleConnected, this);
|
||||
|
||||
IgnoreError(coaps.AddResource(mActiveGet));
|
||||
IgnoreError(coaps.AddResource(mActiveSet));
|
||||
IgnoreError(coaps.AddResource(mPendingGet));
|
||||
IgnoreError(coaps.AddResource(mPendingSet));
|
||||
IgnoreError(coaps.AddResource(mCommissionerPetition));
|
||||
IgnoreError(coaps.AddResource(mCommissionerKeepAlive));
|
||||
IgnoreError(coaps.AddResource(mCommissionerSet));
|
||||
IgnoreError(coaps.AddResource(mCommissionerGet));
|
||||
IgnoreError(coaps.AddResource(mProxyTransmit));
|
||||
IgnoreError(coaps.AddResource(mRelayTransmit));
|
||||
coaps.AddResource(mActiveGet);
|
||||
coaps.AddResource(mActiveSet);
|
||||
coaps.AddResource(mPendingGet);
|
||||
coaps.AddResource(mPendingSet);
|
||||
coaps.AddResource(mCommissionerPetition);
|
||||
coaps.AddResource(mCommissionerKeepAlive);
|
||||
coaps.AddResource(mCommissionerSet);
|
||||
coaps.AddResource(mCommissionerGet);
|
||||
coaps.AddResource(mProxyTransmit);
|
||||
coaps.AddResource(mRelayTransmit);
|
||||
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mRelayReceive));
|
||||
Get<Coap::Coap>().AddResource(mRelayReceive);
|
||||
|
||||
SetState(OT_BORDER_AGENT_STATE_STARTED);
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ void Commissioner::SignalJoinerEvent(otCommissionerJoinerEvent aEvent, const Mac
|
||||
|
||||
void Commissioner::AddCoapResources(void)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mRelayReceive));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mDatasetChanged));
|
||||
IgnoreError(Get<Coap::CoapSecure>().AddResource(mJoinerFinalize));
|
||||
Get<Coap::Coap>().AddResource(mRelayReceive);
|
||||
Get<Coap::Coap>().AddResource(mDatasetChanged);
|
||||
Get<Coap::CoapSecure>().AddResource(mJoinerFinalize);
|
||||
}
|
||||
|
||||
void Commissioner::RemoveCoapResources(void)
|
||||
|
||||
@@ -683,7 +683,7 @@ ActiveDataset::ActiveDataset(Instance &aInstance)
|
||||
, mResourceSet(OT_URI_PATH_ACTIVE_SET, &ActiveDataset::HandleSet, this)
|
||||
#endif
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mResourceGet));
|
||||
Get<Coap::Coap>().AddResource(mResourceGet);
|
||||
}
|
||||
|
||||
bool ActiveDataset::IsPartiallyComplete(void) const
|
||||
@@ -732,7 +732,7 @@ PendingDataset::PendingDataset(Instance &aInstance)
|
||||
, mResourceSet(OT_URI_PATH_PENDING_SET, &PendingDataset::HandleSet, this)
|
||||
#endif
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mResourceGet));
|
||||
Get<Coap::Coap>().AddResource(mResourceGet);
|
||||
}
|
||||
|
||||
void PendingDataset::Clear(void)
|
||||
|
||||
@@ -461,7 +461,7 @@ exit:
|
||||
void ActiveDataset::StartLeader(void)
|
||||
{
|
||||
IgnoreError(GenerateLocal());
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mResourceSet));
|
||||
Get<Coap::Coap>().AddResource(mResourceSet);
|
||||
}
|
||||
|
||||
void ActiveDataset::StopLeader(void)
|
||||
@@ -487,7 +487,7 @@ exit:
|
||||
void PendingDataset::StartLeader(void)
|
||||
{
|
||||
StartDelayTimer();
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mResourceSet));
|
||||
Get<Coap::Coap>().AddResource(mResourceSet);
|
||||
}
|
||||
|
||||
void PendingDataset::StopLeader(void)
|
||||
|
||||
@@ -51,11 +51,11 @@ namespace ot {
|
||||
|
||||
EnergyScanClient::EnergyScanClient(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mCallback(NULL)
|
||||
, mContext(NULL)
|
||||
, mEnergyScan(OT_URI_PATH_ENERGY_REPORT, &EnergyScanClient::HandleReport, this)
|
||||
{
|
||||
mContext = NULL;
|
||||
mCallback = NULL;
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mEnergyScan));
|
||||
Get<Coap::Coap>().AddResource(mEnergyScan);
|
||||
}
|
||||
|
||||
otError EnergyScanClient::SendQuery(uint32_t aChannelMask,
|
||||
|
||||
@@ -65,7 +65,7 @@ Joiner::Joiner(Instance &aInstance)
|
||||
, mJoinerEntrust(OT_URI_PATH_JOINER_ENTRUST, &Joiner::HandleJoinerEntrust, this)
|
||||
{
|
||||
memset(mJoinerRouters, 0, sizeof(mJoinerRouters));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mJoinerEntrust));
|
||||
Get<Coap::Coap>().AddResource(mJoinerEntrust);
|
||||
}
|
||||
|
||||
void Joiner::GetJoinerId(Mac::ExtAddress &aJoinerId) const
|
||||
|
||||
@@ -63,7 +63,7 @@ JoinerRouter::JoinerRouter(Instance &aInstance)
|
||||
, mIsJoinerPortConfigured(false)
|
||||
, mExpectJoinEntRsp(false)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mRelayTransmit));
|
||||
Get<Coap::Coap>().AddResource(mRelayTransmit);
|
||||
}
|
||||
|
||||
void JoinerRouter::HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aFlags)
|
||||
|
||||
@@ -60,8 +60,8 @@ Leader::Leader(Instance &aInstance)
|
||||
, mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal)
|
||||
, mSessionId(Random::NonCrypto::GetUint16())
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mPetition));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mKeepAlive));
|
||||
Get<Coap::Coap>().AddResource(mPetition);
|
||||
Get<Coap::Coap>().AddResource(mKeepAlive);
|
||||
}
|
||||
|
||||
void Leader::HandlePetition(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
||||
|
||||
@@ -54,7 +54,7 @@ PanIdQueryClient::PanIdQueryClient(Instance &aInstance)
|
||||
, mContext(NULL)
|
||||
, mPanIdQuery(OT_URI_PATH_PANID_CONFLICT, &PanIdQueryClient::HandleConflict, this)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mPanIdQuery));
|
||||
Get<Coap::Coap>().AddResource(mPanIdQuery);
|
||||
}
|
||||
|
||||
otError PanIdQueryClient::SendQuery(uint16_t aPanId,
|
||||
|
||||
@@ -71,9 +71,9 @@ AddressResolver::AddressResolver(Instance &aInstance)
|
||||
mUnusedList.Push(*entry);
|
||||
}
|
||||
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAddressError));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAddressQuery));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAddressNotification));
|
||||
Get<Coap::Coap>().AddResource(mAddressError);
|
||||
Get<Coap::Coap>().AddResource(mAddressQuery);
|
||||
Get<Coap::Coap>().AddResource(mAddressNotification);
|
||||
|
||||
IgnoreError(Get<Ip6::Icmp>().RegisterHandler(mIcmpHandler));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ AnnounceBeginServer::AnnounceBeginServer(Instance &aInstance)
|
||||
: AnnounceSenderBase(aInstance, &AnnounceBeginServer::HandleTimer)
|
||||
, mAnnounceBegin(OT_URI_PATH_ANNOUNCE_BEGIN, &AnnounceBeginServer::HandleRequest, this)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAnnounceBegin));
|
||||
Get<Coap::Coap>().AddResource(mAnnounceBegin);
|
||||
}
|
||||
|
||||
void AnnounceBeginServer::SendAnnounce(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod)
|
||||
|
||||
@@ -59,7 +59,7 @@ EnergyScanServer::EnergyScanServer(Instance &aInstance)
|
||||
, mNotifierCallback(aInstance, &EnergyScanServer::HandleStateChanged, this)
|
||||
, mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, this)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mEnergyScan));
|
||||
Get<Coap::Coap>().AddResource(mEnergyScan);
|
||||
}
|
||||
|
||||
void EnergyScanServer::HandleRequest(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
||||
|
||||
@@ -356,8 +356,8 @@ void MleRouter::SetStateLeader(uint16_t aRloc16)
|
||||
Get<NetworkData::Leader>().Start();
|
||||
Get<MeshCoP::ActiveDataset>().StartLeader();
|
||||
Get<MeshCoP::PendingDataset>().StartLeader();
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAddressSolicit));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mAddressRelease));
|
||||
Get<Coap::Coap>().AddResource(mAddressSolicit);
|
||||
Get<Coap::Coap>().AddResource(mAddressRelease);
|
||||
Get<Ip6::Ip6>().SetForwardingEnabled(true);
|
||||
Get<Ip6::Mpl>().SetTimerExpirations(kMplRouterDataMessageTimerExpirations);
|
||||
Get<Mac::Mac>().SetBeaconEnabled(true);
|
||||
|
||||
@@ -76,9 +76,9 @@ void Leader::Reset(void)
|
||||
|
||||
void Leader::Start(void)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mServerData));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mCommissioningDataGet));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mCommissioningDataSet));
|
||||
Get<Coap::Coap>().AddResource(mServerData);
|
||||
Get<Coap::Coap>().AddResource(mCommissioningDataGet);
|
||||
Get<Coap::Coap>().AddResource(mCommissioningDataSet);
|
||||
}
|
||||
|
||||
void Leader::Stop(void)
|
||||
|
||||
@@ -63,10 +63,10 @@ NetworkDiagnostic::NetworkDiagnostic(Instance &aInstance)
|
||||
, mReceiveDiagnosticGetCallback(NULL)
|
||||
, mReceiveDiagnosticGetCallbackContext(NULL)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mDiagnosticGetRequest));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mDiagnosticGetQuery));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mDiagnosticGetAnswer));
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mDiagnosticReset));
|
||||
Get<Coap::Coap>().AddResource(mDiagnosticGetRequest);
|
||||
Get<Coap::Coap>().AddResource(mDiagnosticGetQuery);
|
||||
Get<Coap::Coap>().AddResource(mDiagnosticGetAnswer);
|
||||
Get<Coap::Coap>().AddResource(mDiagnosticReset);
|
||||
}
|
||||
|
||||
void NetworkDiagnostic::SetReceiveDiagnosticGetCallback(otReceiveDiagnosticGetCallback aCallback,
|
||||
|
||||
@@ -53,7 +53,7 @@ PanIdQueryServer::PanIdQueryServer(Instance &aInstance)
|
||||
, mTimer(aInstance, &PanIdQueryServer::HandleTimer, this)
|
||||
, mPanIdQuery(OT_URI_PATH_PANID_QUERY, &PanIdQueryServer::HandleQuery, this)
|
||||
{
|
||||
IgnoreError(Get<Coap::Coap>().AddResource(mPanIdQuery));
|
||||
Get<Coap::Coap>().AddResource(mPanIdQuery);
|
||||
}
|
||||
|
||||
void PanIdQueryServer::HandleQuery(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
||||
|
||||
Reference in New Issue
Block a user