mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 18:57:47 +00:00
[commissioner] add new API to get Provisioning URL (#2884)
This commit is contained in:
committed by
Jonathan Hui
parent
14a1f49011
commit
3796b33e6a
@@ -121,6 +121,19 @@ OTAPI otError OTCALL otCommissionerAddJoiner(otInstance * aInstance,
|
||||
*/
|
||||
OTAPI otError OTCALL otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aEui64);
|
||||
|
||||
/**
|
||||
* This function gets the Provisioning URL.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aLength A pointer to `uint16_t` to return the length (number of chars) in the URL string.
|
||||
*
|
||||
* Note that the returned URL string buffer is not necessarily null-terminated.
|
||||
*
|
||||
* @returns A pointer to char buffer containing the URL string, or NULL if @p aLength is NULL.
|
||||
*
|
||||
*/
|
||||
const char *otCommissionerGetProvisioningUrl(otInstance *aInstance, uint16_t *aLength);
|
||||
|
||||
/**
|
||||
* This function sets the Provisioning URL.
|
||||
*
|
||||
|
||||
@@ -124,6 +124,25 @@ otError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aPro
|
||||
return error;
|
||||
}
|
||||
|
||||
const char *otCommissionerGetProvisioningUrl(otInstance *aInstance, uint16_t *aLength)
|
||||
{
|
||||
const char *url = NULL;
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
if (aLength != NULL)
|
||||
{
|
||||
url = instance.GetThreadNetif().GetCommissioner().GetProvisioningUrl(*aLength);
|
||||
}
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aLength);
|
||||
#endif
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
otError otCommissionerAnnounceBegin(otInstance * aInstance,
|
||||
uint32_t aChannelMask,
|
||||
uint8_t aCount,
|
||||
|
||||
@@ -310,6 +310,15 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
const char *Commissioner::GetProvisioningUrl(uint16_t &aLength) const
|
||||
{
|
||||
ProvisioningUrlTlv &provisioningUrl = GetNetif().GetDtls().mProvisioningUrl;
|
||||
|
||||
aLength = provisioningUrl.GetLength();
|
||||
|
||||
return provisioningUrl.GetProvisioningUrl();
|
||||
}
|
||||
|
||||
otError Commissioner::SetProvisioningUrl(const char *aProvisioningUrl)
|
||||
{
|
||||
return GetNetif().GetDtls().mProvisioningUrl.SetProvisioningUrl(aProvisioningUrl);
|
||||
|
||||
@@ -116,6 +116,18 @@ public:
|
||||
*/
|
||||
otError RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay);
|
||||
|
||||
/**
|
||||
* This method gets the Provisioning URL.
|
||||
*
|
||||
* @param[out] aLength A reference to `uint16_t` to return the length (number of chars) in the URL string.
|
||||
*
|
||||
* Note that the returned URL string buffer is not necessarily null-terminated.
|
||||
*
|
||||
* @returns A pointer to char buffer containing the URL string.
|
||||
*
|
||||
*/
|
||||
const char *GetProvisioningUrl(uint16_t &aLength) const;
|
||||
|
||||
/**
|
||||
* This method sets the Provisioning URL.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user