From: Wootak Jung Date: Fri, 25 Mar 2022 02:18:46 +0000 (+0900) Subject: Add new API to get the panid from operational network X-Git-Tag: accepted/tizen/unified/20220914.164046~78 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F04%2F272904%2F1;p=platform%2Fcore%2Fapi%2Fthread.git Add new API to get the panid from operational network Change-Id: I658dfd3d29753b0c24024b74b172398b8ac4e54a Signed-off-by: hyunuk.tak --- diff --git a/include/thread.h b/include/thread.h index f430ea6..36fbb4e 100644 --- a/include/thread.h +++ b/include/thread.h @@ -363,6 +363,27 @@ int thread_network_get_active_dataset_tlvs(thread_instance_h instance, /** * @ingroup CAPI_NETWORK_THREAD_MODULE + * @brief Get the PanId from Operational Network + * @since_tizen 7.0 + * + * @param[out] panid The PanId + * + * @return 0 on success, otherwise a negative error value. + * @retval #THREAD_ERROR_NONE Successful + * @retval #THREAD_ERROR_NOT_INITIALIZED Not initialized + * @retval #THREAD_ERROR_OPERATION_FAILED Operation failed + * @retval #THREAD_ERROR_NOT_SUPPORTED Not supported + * + * @pre thread API must be initialized with thread_initialize(). + * @pre Active Operational Dataset must be set using thread_set_active_dataset_tlvs(). + * + * @see thread_network_create_operational_network() + * @see thread_set_active_dataset_tlvs() + */ +int thread_network_get_panid(thread_instance_h instance, uint16_t *panid); + +/** + * @ingroup CAPI_NETWORK_THREAD_MODULE * @brief Attach the OT hardware to the active Operational Network, which is pre-set * @since_tizen 7.0 * diff --git a/src/thread-network.c b/src/thread-network.c index 9ec8254..83bf963 100644 --- a/src/thread-network.c +++ b/src/thread-network.c @@ -236,6 +236,30 @@ int thread_network_get_active_dataset_tlvs(thread_instance_h instance, return ret; } +int thread_network_get_panid(thread_instance_h instance, uint16_t *panid) +{ + FUNC_ENTRY; + THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON); + THREAD_CHECK_INIT_STATUS(); + THREAD_VALIDATE_INPUT_PARAMETER(instance); + THREAD_VALIDATE_INPUT_PARAMETER(panid); + + int ret = THREAD_ERROR_NONE; + GVariant *out = NULL; + + /* get "PanId" dbus property */ + ret = _thread_dbus_get_property( + THREAD_DBUS_PROPERTY_PANID, &out); + retv_if(ret != THREAD_ERROR_NONE, ret); + + g_variant_get(out, "q", panid); + THREAD_DBG("Thread PanId: %u", (size_t)*panid); + g_variant_unref(out); + + FUNC_EXIT; + return THREAD_ERROR_NONE; +} + static int __thread_attach_active_network() { FUNC_ENTRY;