From 03a87e0936cb53f8c70a0d47849c977e04c60539 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 28 Feb 2012 19:16:27 +0100 Subject: p2p: Check presence hook implementation The MAC layer state tell if the peer device is there or not. --- plugins/handover.c | 2 ++ plugins/p2p.c | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'plugins') 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 #include #include +#include #include #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, }; -- cgit v1.2.3