summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-02-28 19:16:27 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2012-02-28 19:16:27 +0100
commit03a87e0936cb53f8c70a0d47849c977e04c60539 (patch)
tree114ca487b99624b8e33443c9822f4bde33b6031f /plugins
parent1b368ff97b1e98f20b224b0cf0909ddbf79cd73c (diff)
downloadneard-03a87e0936cb53f8c70a0d47849c977e04c60539.tar.gz
neard-03a87e0936cb53f8c70a0d47849c977e04c60539.tar.bz2
neard-03a87e0936cb53f8c70a0d47849c977e04c60539.zip
p2p: Check presence hook implementation
The MAC layer state tell if the peer device is there or not.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/handover.c2
-rw-r--r--plugins/p2p.c23
2 files changed, 22 insertions, 3 deletions
diff --git a/plugins/handover.c b/plugins/handover.c
index 32dae30..9a00104 100644
--- a/plugins/handover.c
+++ b/plugins/handover.c
@@ -47,6 +47,8 @@ static near_bool_t handover_read(int client_fd,
{
DBG("");
+ cb(adapter_idx, target_idx, 0);
+
return FALSE;
}
diff --git a/plugins/p2p.c b/plugins/p2p.c
index dfa7475..7bf4807 100644
--- a/plugins/p2p.c
+++ b/plugins/p2p.c
@@ -36,6 +36,7 @@
#include <near/log.h>
#include <near/types.h>
#include <near/target.h>
+#include <near/adapter.h>
#include <near/tlv.h>
#include "p2p.h"
@@ -176,10 +177,26 @@ static int p2p_read(uint32_t adapter_idx,
return err;
}
+static int p2p_check_presence(uint32_t adapter_idx, uint32_t target_idx,
+ near_tag_io_cb cb)
+{
+ int present = -ENODEV;
+
+ DBG("Present %d", near_adapter_get_dep_state(adapter_idx));
+
+ if (near_adapter_get_dep_state(adapter_idx) == TRUE)
+ present = 0;
+
+ cb(adapter_idx, target_idx, present);
+
+ return 0;
+}
+
static struct near_tag_driver p2p_driver = {
- .type = NFC_PROTO_NFC_DEP,
- .priority = NEAR_TAG_PRIORITY_HIGH,
- .read_tag = p2p_read,
+ .type = NFC_PROTO_NFC_DEP,
+ .priority = NEAR_TAG_PRIORITY_HIGH,
+ .read_tag = p2p_read,
+ .check_presence = p2p_check_presence,
};