*
* @pre thread API must be initialized with thread_initialize().
*/
-int thread_network_set_panid(thread_network_h network, uint64_t panid);
+int thread_network_set_panid(thread_network_h network, uint16_t panid);
/**
* @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
return THREAD_ERROR_NONE;
}
+int thread_network_set_panid(thread_network_h network, uint16_t panid)
+{
+ FUNC_ENTRY;
+ THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+ THREAD_CHECK_INIT_STATUS();
+ THREAD_VALIDATE_INPUT_PARAMETER(network);
+
+ THREAD_DBG("Network panid: %u", panid);
+
+ thread_network_s *current_network = network;
+ current_network->panid = panid;
+
+ FUNC_EXIT;
+ return THREAD_ERROR_NONE;
+}
+
/* Network leader/Creator */
int thread_network_create_operational_network(thread_instance_h instance,
const char *name, const char *key, const char *pskc, uint32_t channel,
const char *NETWORK_DUMMY_PSKC = "19d3bd4ee76baad7ff2da29c87c67452";
const uint32_t NETWORK_DUMMY_CHANNEL = 15;
const uint64_t NETWORK_DUMMY_EXTENDED_PANID = 0xeea0d4484e93db7a;
+ const uint16_t NETWORK_DUMMY_PANID = 0x68a0;
thread_instance_h instance;
thread_network_h network;
EXPECT_EQ(THREAD_ERROR_NONE, thread_network_create(&network));
EXPECT_EQ(THREAD_ERROR_NONE,
thread_network_set_extended_panid(network, NETWORK_DUMMY_EXTENDED_PANID));
+}
+
+TEST_F(ThreadNetworkTest, SetPanidNotInitialized)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());
+ EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED,
+ thread_network_set_panid(network, NETWORK_DUMMY_PANID));
+}
+
+TEST_F(ThreadNetworkTest, SetPanidInvalidParameter)
+{
+ EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER,
+ thread_network_set_panid(nullptr, NETWORK_DUMMY_PANID));
+}
+
+TEST_F(ThreadNetworkTest, SetPanidErrorNone)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_network_create(&network));
+ EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_network_set_panid(network, NETWORK_DUMMY_PANID));
}
\ No newline at end of file