summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-21 16:42:35 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-21 16:42:35 +0000
commita90757289dbf36ef7f1d8de3dcce9236c1b94cf9 (patch)
tree055f84e72a3a504acd5a3927310526f47981769a
parent764131fd374a518e31c77ec5b953330ba55fec90 (diff)
Added out of range signal
-rw-r--r--hcid/dbus.c65
-rw-r--r--hcid/dbus.h1
2 files changed, 64 insertions, 2 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index b95aaaf6..c8916590 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -458,6 +458,12 @@ static int unregister_dbus_path(const char *path)
pdata->disc_devices = NULL;
}
+ if (pdata->oor_devices) {
+ slist_foreach(pdata->oor_devices, (slist_func_t) free, NULL);
+ slist_free(pdata->oor_devices);
+ pdata->oor_devices = NULL;
+ }
+
if (pdata->pin_reqs) {
slist_foreach(pdata->pin_reqs, (slist_func_t) free, NULL);
slist_free(pdata->pin_reqs);
@@ -714,6 +720,12 @@ int hcid_dbus_stop_device(uint16_t id)
pdata->disc_devices = NULL;
}
+ if (pdata->oor_devices) {
+ slist_foreach(pdata->oor_devices, (slist_func_t) free, NULL);
+ slist_free(pdata->oor_devices);
+ pdata->oor_devices = NULL;
+ }
+
if (pdata->pin_reqs) {
slist_foreach(pdata->pin_reqs, (slist_func_t) free, NULL);
slist_free(pdata->pin_reqs);
@@ -998,12 +1010,33 @@ int disc_device_req_name(struct hci_dbus_data *dbus_data)
return 0;
}
+static void send_out_of_range(const char *path, struct slist *l)
+{
+ DBusMessage *message;
+ const char *peer_addr;
+
+ while (l) {
+ peer_addr = l->data;
+
+ message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
+ "RemoteDeviceLost");
+ dbus_message_append_args(message,
+ DBUS_TYPE_STRING, &peer_addr,
+ DBUS_TYPE_INVALID);
+
+ send_reply_and_unref(connection, message);
+ l = l->next;
+ }
+}
+
void hcid_dbus_inquiry_complete(bdaddr_t *local)
{
DBusMessage *message;
struct hci_dbus_data *pdata;
+ struct slist *l;
char path[MAX_PATH_LENGTH];
char *local_addr;
+ struct discovered_dev_info *dev;
bdaddr_t tmp;
int id;
@@ -1022,6 +1055,23 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
goto done;
}
+ /* Out of range verification */
+ if (pdata->pdisc_active && !pdata->disc_active) {
+ send_out_of_range(path, pdata->oor_devices);
+
+ slist_foreach(pdata->oor_devices, (slist_func_t) free, NULL);
+ slist_free(pdata->oor_devices);
+ pdata->oor_devices = NULL;
+
+ l = pdata->disc_devices;
+ while (l) {
+ dev = l->data;
+ baswap(&tmp, &dev->bdaddr);
+ pdata->oor_devices = slist_append(pdata->oor_devices, batostr(&tmp));
+ l = l->next;
+ }
+ }
+
pdata->pinq_idle = 1;
/*
* Enable resolution again: standard inquiry can be
@@ -1153,6 +1203,11 @@ void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status)
slist_free(pdata->disc_devices);
pdata->disc_devices = NULL;
+ /* free out of range devices list */
+ slist_foreach(pdata->oor_devices, (slist_func_t) free, NULL);
+ slist_free(pdata->oor_devices);
+ pdata->oor_devices = NULL;
+
if (pdata->pdiscovery_requestor) {
name_listener_remove(connection, pdata->pdiscovery_requestor,
(name_cb_t) periodic_discover_req_exit, pdata);
@@ -1238,10 +1293,16 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, i
if (!pdata->disc_active && !pdata->pdisc_active)
pdata->pdisc_active = 1;
- /* reset the idle flag when the inquiry complete event arrives */
- if (pdata->pdisc_active)
+ /* reset the idle flag when the inquiry complete event arrives */
+ if (pdata->pdisc_active) {
pdata->pinq_idle = 0;
+ /* Out of range list update */
+ l = slist_find(pdata->oor_devices, peer_addr, (cmp_func_t) strcmp);
+ if (l)
+ pdata->oor_devices = slist_remove(pdata->oor_devices, l->data);
+ }
+
/* send the device found signal */
signal_device = dev_signal_factory(pdata->dev_id, "RemoteDeviceFound",
DBUS_TYPE_STRING, &peer_addr,
diff --git a/hcid/dbus.h b/hcid/dbus.h
index b4f597e7..f83b5ca8 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -113,6 +113,7 @@ struct hci_dbus_data {
int pinq_idle; /* tracks the idle time for periodic inquiry */
int discover_type; /* type requested */
struct slist *disc_devices;
+ struct slist *oor_devices; /* out of range device list */
char *pdiscovery_requestor; /* periodic discovery requestor unique name */
char *discovery_requestor; /* discovery requestor unique name */
DBusMessage *discovery_cancel; /* discovery cancel message request */