ma_check_null_ret("g_client", g_client);
- g_mutex_init(&motdev_mutex);
- g_mutex_lock(&motdev_mutex);
if (g_client->g_motdev_list) {
OCDeleteDiscoveredDevices(g_client->g_motdev_list);
g_client->g_motdev_list = NULL;
}
- g_mutex_unlock(&motdev_mutex);
}
static void _remove_owned_client()
{
- GMutex owned_dev_mutex;
-
ma_check_null_ret("g_client", g_client);
- /* delete un/owned device lists before updating them */
- g_mutex_init(&owned_dev_mutex);
- g_mutex_lock(&owned_dev_mutex);
if (g_client->g_mowned_list) {
OCDeleteDiscoveredDevices(g_client->g_mowned_list);
g_client->g_mowned_list = NULL;
}
- g_mutex_unlock(&owned_dev_mutex);
}
static int _set_device_id_seed(void)
ma_req_cb_s *con = (ma_req_cb_s *)data;
ma_check_null_ret_error("con", con, NULL);
- /* delete un/owned device lists before updating them */
- _remove_mot_client();
-
MA_LOGI("Discovering Multiple Ownership Transfer enabled Devices on Network..");
if (OC_STACK_OK != OCDiscoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT,
&g_client->g_motdev_list)) {
}
g_thread_unref(con->thread);
+ /* delete un/owned device lists before updating them */
+ _remove_mot_client();
+
con->userdata = service;
con->cid = MA_DISC_MOT_ENB_DEVS;
#ifdef TIMEOUT_USED
ma_req_cb_s *con = (ma_req_cb_s *)data;
OCProvisionDev_t *src_dev = NULL;
- OCProvisionDev_t *clone_dev = NULL;
OicUuid_t *uuid_target = NULL;
if (!con->uuid_target_str) {
MA_LOGE("We can't find in MOT dev list");
goto MOT_ENDED;
}
- /* Copy subject device and related information */
- clone_dev = PMCloneOCProvisionDev(src_dev);
- /* To do ACL provisioning only one */
- clone_dev->next = NULL;
g_client->g_doneCB = false;
+#ifdef MULTIPLE_OWN_AT_ONCE
OCProvisionDev_t* dev = NULL;
- LL_FOREACH(clone_dev, dev) {
+ LL_FOREACH(src_dev, dev) {
if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel) {
/* Pre-Configured PIN initialization */
const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
- ret = OCAddPreconfigPin(dev, testPreconfigPin, strlen(testPreconfigPin));
+ ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin));
if(OC_STACK_OK != ret) {
MA_LOGE("Failed to save the pre-configured PIN");
MA_LOGE("You can't use the pre-configured PIN OxM for MOT");
}
}
}
+#else
+ if(OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) {
+ /* Pre-Configured PIN initialization */
+ const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
+ ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin));
+ if(OC_STACK_OK != ret) {
+ MA_LOGE("Failed to save the pre-configured PIN");
+ MA_LOGE("You can't use the pre-configured PIN OxM for MOT");
+ goto MOT_ENDED;
+ }
+ }
+#endif
- ret = OCDoMultipleOwnershipTransfer(g_client, clone_dev, _mot_cb);
+ ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb);
if (OC_STACK_OK != ret ) {
MA_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, _error_to_string(ret));
goto MOT_ENDED;
MOT_ENDED:
- net_ma_emit_mot_done(ma_dbus_get_object(), (int)ret);
if (uuid_target)
g_free(uuid_target);
- if (clone_dev)
- PMDeleteDeviceList(clone_dev);
+
_request_cleanup(data);
g_thread_exit(GINT_TO_POINTER (1));
+ net_ma_emit_mot_done(ma_dbus_get_object(), (int)ret);
+
return NULL;
}