summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-09-23 00:45:45 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-09-23 00:45:45 +0200
commit054f0c77f0d4b6580fc911b4d268610bd8cb139d (patch)
tree4e3de2eefe2e933386ba945ef502cebe0c2dac67
parent18aeb43f4c4afbde72826951778a3701e58efae1 (diff)
downloadneard-054f0c77f0d4b6580fc911b4d268610bd8cb139d.tar.gz
neard-054f0c77f0d4b6580fc911b4d268610bd8cb139d.tar.bz2
neard-054f0c77f0d4b6580fc911b4d268610bd8cb139d.zip
npp: Fix npp_read
Data needs to be added to the device, not the tag. Also, check the version number.
-rw-r--r--plugins/npp.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/npp.c b/plugins/npp.c
index eac17a6..1796ffb 100644
--- a/plugins/npp.c
+++ b/plugins/npp.c
@@ -54,6 +54,12 @@ struct p2p_npp_frame {
struct p2p_npp_ndef_entry ndefs[];
} __attribute__((packed));
+#define NPP_MAJOR_VERSION (0x0 & 0xf)
+#define NPP_MINOR_VERSION 0x1
+#define NPP_VERSION ((NPP_MAJOR_VERSION << 4) | NPP_MINOR_VERSION)
+
+#define NPP_DEFAULT_ACTION 0x1
+
static bool npp_read(int client_fd,
uint32_t adapter_idx, uint32_t target_idx,
near_tag_io_cb cb, gpointer data)
@@ -79,6 +85,11 @@ static bool npp_read(int client_fd,
DBG("version %d %d NDEFs", frame.version, n_ndef);
+ if (frame.version != NPP_VERSION) {
+ near_error("Invalid NPP version 0x%x", frame.version);
+ return false;
+ }
+
for (i = 0; i < n_ndef; i++) {
bytes_recv = recv(client_fd, &entry, sizeof(entry), 0);
if (bytes_recv < 0) {
@@ -121,7 +132,7 @@ static bool npp_read(int client_fd,
DBG("Total NDEF length %d", total_ndef_length);
- err = near_tag_add_data(adapter_idx, target_idx,
+ err = near_device_add_data(adapter_idx, target_idx,
ndefs, total_ndef_length);
if (err < 0)
return false;