summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWootak Jung <wootak.jung@samsung.com>2023-12-28 09:12:59 +0900
committerWootak Jung <wootak.jung@samsung.com>2024-01-09 10:42:59 +0900
commitf42d4e330d28509100a506f2b40701c47a5098d6 (patch)
tree77587dbc4997573d64f4af5b9080645e625cf650
parentc7d545402879abb7dc635ea7ecaf5fcd56ad0200 (diff)
downloadbluez-f42d4e330d28509100a506f2b40701c47a5098d6.tar.gz
bluez-f42d4e330d28509100a506f2b40701c47a5098d6.tar.bz2
bluez-f42d4e330d28509100a506f2b40701c47a5098d6.zip
adapter: Fix issue where the adv restart logic operates even though adv stop is requested
Fix the adv restart logic to only operate when adv is enabled Change-Id: I9aebdc393050b6c7b3674281ffd801c6db18f14c Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
-rw-r--r--src/adapter.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/adapter.c b/src/adapter.c
index a7a5fe9a..3b159a3d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4825,8 +4825,15 @@ static DBusMessage *adapter_set_advertising(DBusConnection *conn,
DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
- if (adapter->adv_restart_timeout > 0)
- return btd_error_in_progress(msg);
+ if (adapter->adv_restart_timeout) {
+ if (enable) {
+ return btd_error_in_progress(msg);
+ } else {
+ DBG("Advertising stop received. No need to restart advertising");
+ g_source_remove(adapter->adv_restart_timeout);
+ adapter->adv_restart_timeout = 0;
+ }
+ }
DBG("%s advertising slot_id %d", enable ? "Enable" : "Disable", slot_id);
@@ -13753,6 +13760,7 @@ static void multi_adv_state_change_callback(uint16_t index, uint16_t length,
const struct mgmt_ev_vendor_specific_multi_adv_state_changed *ev = param;
struct btd_adapter *adapter = user_data;
struct multi_adv_data *data;
+ struct adv_info *adv;
if (length < sizeof(*ev)) {
error("Too small adv state change event");
@@ -13762,8 +13770,11 @@ static void multi_adv_state_change_callback(uint16_t index, uint16_t length,
DBG("adv id %d, state change reason %d, connection_handle %x",
ev->adv_instance, ev->state_change_reason, ev->connection_handle);
+ adv = find_advertiser(adapter, ev->adv_instance);
+ DBG("current advertising status %d", adv->status);
+
if ((ev->adv_instance > 0 && ev->adv_instance < adapter_le_get_max_adv_instance()) &&
- ev->state_change_reason == 0) {
+ ev->state_change_reason == 0 && adv->status) {
/* advertising is stopped by controller, it should be enabled again.
* If fails, state should be changed to FALSE */
data = g_new0(struct multi_adv_data, 1);