void _bt_unregister_adv_slot_owner(int slot_id)
{
+ if (le_adv_slot[slot_id].hold_timer_id > 0) {
+ BT_INFO("Hold state adv is not unregistered");
+ return;
+ }
+
g_free(le_adv_slot[slot_id].sender);
le_adv_slot[slot_id].sender = NULL;
le_adv_slot[slot_id].adv_handle = 0;
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (enable == TRUE)
__bt_register_adv_slot_owner(sender, adv_handle, slot_id);
- else
- _bt_unregister_adv_slot_owner(slot_id);
le_adv_slot[slot_id].is_advertising = enable;
BT_INFO_C("### Set advertising [%d], Slot id [%d]", enable, slot_id);
NULL,
&err);
g_free(device_path);
- if (err != NULL) {
- BT_ERR("UnpairDevice Fail: %s", err->message);
- g_error_free(err);
+ if (result == NULL) {
+ if (err != NULL) {
+ BT_ERR("UnpairDevice Fail: %s", err->message);
+ g_error_free(err);
+ }
return BLUETOOTH_ERROR_INTERNAL;
}
g_timeout_add(1000, __bt_connect_le_timer_cb, NULL);
return BLUETOOTH_ERROR_NONE;
+ } else if (ret != BLUETOOTH_ERROR_NOT_IN_OPERATION) {
+ BT_ERR("Unable to hold advertising");
}
- BT_ERR("Unable to hold advertising");
-
return __bt_connect_le_device_internal(req_id, bd_addr, auto_connect);
}