/* delete un/owned device lists before updating them */
_remove_owned_client();
- D2DS_LOGD("Discovering Multiple Owned Devices on Network.");
+ D2DS_LOGD("Discovering Multiple Owned Devices");
ret = OCDiscoverMultipleOwnedDevices(DISCOVERY_TIMEOUT, &g_client->g_mowned_list);
if (OC_STACK_OK != ret) {
D2DS_LOGE( "OCDiscoverMultipleOwnerEnabledDevices API error");
return D2DS_ERROR_NONE;
}
-static void _mot_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool has_error)
+static void _mot_cb(void* ctx, int num, OCProvisionResult_t* arr, bool has_error)
{
+ int i = 0;
+ int ret = OC_STACK_OK;
d2ds_subowner_s *client = (d2ds_subowner_s *)ctx;
if (!has_error) {
D2DS_LOGD("Multiple Ownership Transfer SUCCEEDED");
} else {
D2DS_LOGD( "Multiple Ownership Transfer FAILED ");
- _print_result_list((const OCProvisionResult_t*) arr, nOfRes);
+
+ _print_result_list((const OCProvisionResult_t*) arr, num);
+
+ ret = openDB();
+ if (OC_STACK_OK != ret)
+ D2DS_LOGE( "openDB: ret = %d (%s)", ret, _error_to_string(ret));
+
+ for ( ; num > i; ++i) {
+ if (OC_STACK_OK !=arr[i].res) {
+ ret = delete_mowned_device_db((const OicUuid_t*) &arr[i].deviceId);
+ }
+ }
+ ret = closeDB();
+ if (OC_STACK_OK != ret)
+ D2DS_LOGE( "closeDB: ret = %d (%s)", ret, _error_to_string(ret));
}
client->g_doneCB = true;
}
}
ret = openDB();
- if (OC_STACK_OK == ret) {
- delete_mowned_device_db((const OicUuid_t*) uuid_target);
- closeDB();
- }
+ if (OC_STACK_OK != ret)
+ D2DS_LOGE( "openDB: ret = %d (%s)", ret, _error_to_string(ret));
+ ret = delete_mowned_device_db((const OicUuid_t*) uuid_target);
+ if (OC_STACK_OK != ret)
+ D2DS_LOGE( "delete_mowned_device_db: ret = %d (%s)", ret, _error_to_string(ret));
+ ret = closeDB();
+ if (OC_STACK_OK != ret)
+ D2DS_LOGE( "closeDB: ret = %d (%s)", ret, _error_to_string(ret));
ret = OCRemoveSubOwner(g_client, src_dev, &uuid_mowner, _remove_mo_cb);
if (OC_STACK_OK != ret ) {
d2ds_check_null_ret_error("service", service, FALSE);
- D2DS_LOGD("[IPC] Discovery Owned devices using MOT");
+ D2DS_LOGD("[IPC] Discovery Owned devices");
/* If we are working now? */
if (g_atomic_int_get(&service->pending))
d2ds_check_null_ret_error("service", service, FALSE);
- D2DS_LOGD("[IPC] Remove Mullti Ownership");
+ D2DS_LOGD("[IPC] Remove Mulltiple Ownership");
/* If we are working now? */
if (g_atomic_int_get(&service->pending))