btpclient: Fix gap reset not sending response
authorTedd Ho-Jeong An <tedd.an@intel.com>
Sat, 29 Aug 2020 00:08:03 +0000 (17:08 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:32 +0000 (19:08 +0530)
This patch fixes the GAP reset command to response the default settings
after resetting the stack.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/btpclient.c

index 1c3719c..d7f46a4 100644 (file)
@@ -527,6 +527,19 @@ static void reset_unreg_agent_reply(struct l_dbus_proxy *proxy,
        ag.registered = false;
 }
 
+static void update_current_settings(struct btp_adapter *adapter,
+                                                       uint32_t new_settings)
+{
+       struct btp_new_settings_ev ev;
+
+       adapter->current_settings = new_settings;
+
+       ev.current_settings = L_CPU_TO_LE32(adapter->current_settings);
+
+       btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index,
+                                                       sizeof(ev), &ev);
+}
+
 static void btp_gap_reset(uint8_t index, const void *param, uint16_t length,
                                                                void *user_data)
 {
@@ -534,6 +547,7 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length,
        const struct l_queue_entry *entry;
        uint8_t status;
        bool prop;
+       uint32_t default_settings;
 
        if (!adapter) {
                status = BTP_ERROR_INVALID_INDEX;
@@ -576,10 +590,13 @@ static void btp_gap_reset(uint8_t index, const void *param, uint16_t length,
                        goto failed;
                }
 
-       adapter->current_settings = adapter->default_settings;
+       default_settings = adapter->default_settings;
+
+       update_current_settings(adapter, default_settings);
 
        /* TODO for we assume all went well */
-       btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index, 0, NULL);
+       btp_send(btp, BTP_GAP_SERVICE, BTP_OP_GAP_RESET, index,
+                               sizeof(default_settings), &default_settings);
        return;
 
 failed:
@@ -650,19 +667,6 @@ failed:
        btp_send_error(btp, BTP_GAP_SERVICE, index, status);
 }
 
-static void update_current_settings(struct btp_adapter *adapter,
-                                                       uint32_t new_settings)
-{
-       struct btp_new_settings_ev ev;
-
-       adapter->current_settings = new_settings;
-
-       ev.current_settings = L_CPU_TO_LE32(adapter->current_settings);
-
-       btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_NEW_SETTINGS, adapter->index,
-                                                       sizeof(ev), &ev);
-}
-
 static void btp_gap_set_connectable(uint8_t index, const void *param,
                                        uint16_t length, void *user_data)
 {