NEC Near Field Communication RF module library for mbed H001-000003-001 (950MHz), H001-000013-001 (920MHz), TY24FM-E2024 (2.4GHz)

Dependents:   NECnfc_sample Drone_air Drone_ground

NEC Near Field Communication RF module library

NEC製の近距離無線モジュール用のライブラリです。

詳細はこちら

Revision:
5:e5a358e9ed94
Parent:
4:07e752ff8dce
Child:
6:2e1fc47e5bca
--- a/NECnfc.cpp	Tue Sep 15 06:17:57 2015 +0000
+++ b/NECnfc.cpp	Mon Oct 19 01:36:35 2015 +0000
@@ -72,9 +72,11 @@
     int r;
 
     if (!_received) return -1;
+    if (_rxmsg.msgid != NECMSG_SEND_DAT && _rxmsg.msgid != NECMSG_SEND_NOACK) return -1;
 
     r = _rxmsg.length - NEC_HEADER_SIZE;
-    memcpy(data, _rxmsg.parameter, r < len ? r : len);
+    if (r > len) r = len;
+    memcpy(data, _rxmsg.parameter, r);
     if (dest) *dest = ntohl(_rxmsg.dstid);
     if (src) *src = ntohl(_rxmsg.srcid);
     return r;