Thread (8 messages) flat view 8 messages, 4 authors, 2021-10-20

Re: [BlueZ PATCH v3 3/3] adv_monitor: Receive the Device Lost event

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-10-19 21:17:41

Hi Manish,

On Wed, Oct 13, 2021 at 12:00 PM Manish Mandlik [off-list ref] wrote:
quoted hunk ↗ jump to hunk
This patch registers a callback function to receive Advertisement
Monitor Device Lost event.

Test performed:
- verified by logs that Monitor Device is received from the controller
  and sent to the bluetoothd when the controller starts/stops monitoring
  a bluetooth device.

---

Changes in v3:
- Fix indentation of the adv_monitor_device_lost_callback() name and
  it's arguments.

Changes in v2:
- Update function name adv_monitor_tracking_callback() to
  adv_monitor_device_lost_callback() as it will receive only Device Lost
  event.

 src/adv_monitor.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index 715ac5904..385ab26e6 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -1531,6 +1531,27 @@ static void adv_monitor_removed_callback(uint16_t index, uint16_t length,
                ev->monitor_handle);
 }

+/* Processes Adv Monitor tracking event from kernel */
+static void adv_monitor_device_lost_callback(uint16_t index, uint16_t length,
+                                       const void *param, void *user_data)
+{
+       struct btd_adv_monitor_manager *manager = user_data;
+       const struct mgmt_ev_adv_monitor_device_lost *ev = param;
+       uint16_t handle = le16_to_cpu(ev->monitor_handle);
+       const uint16_t adapter_id = manager->adapter_id;
+       char addr[18];
+
+       if (length < sizeof(*ev)) {
+               btd_error(adapter_id,
+                               "Wrong size of Adv Monitor Device Lost event");
+               return;
+       }
+
+       ba2str(&ev->addr.bdaddr, addr);
+       DBG("Adv monitor with handle 0x%04x stopped tracking the device %s",
+                       handle, addr);
Isn't there a DeviceLost in the AdvertisementMonitor1 interface?
Otherwise this is quite pointless since the only thing it is doing is
printing the event without taking any action.
quoted hunk ↗ jump to hunk
+}
+
 /* Allocates a manager object */
 static struct btd_adv_monitor_manager *manager_new(
                                                struct btd_adapter *adapter,
@@ -1555,6 +1576,10 @@ static struct btd_adv_monitor_manager *manager_new(
                        manager->adapter_id, adv_monitor_removed_callback,
                        manager, NULL);

+       mgmt_register(manager->mgmt, MGMT_EV_ADV_MONITOR_DEVICE_LOST,
+                       manager->adapter_id, adv_monitor_device_lost_callback,
+                       manager, NULL);
+
        return manager;
 }

--
2.33.0.882.g93a45727a2-goog

-- 
Luiz Augusto von Dentz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help