Utility library to read and write Ndef messages from/to a Type4 NFC tag

Dependents:   NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more

Fork of NDefLib by ST Expansion SW Team

NDEF NFC library

This library provides an abstract API to create NDEF formatted messages and records and to read/write them from/to a Type4 NFC Tag.

Implementations

At the moment, the NDEF API is implemented by X_NUCLEO_NFC01A1 and X_NUCLEO_NFC02A1 Dynamic NFC Tag libraries respectively driving the X-NUCLEO-NFC01A1 and X-NUCLEO-NFC02A1 boards.

Revision:
18:cf1dd5c931c2
Parent:
12:ed4d9b8d1410
Child:
19:13d84b136a62
--- a/RecordHeader.h	Wed Aug 31 08:32:13 2016 +0000
+++ b/RecordHeader.h	Thu Oct 27 07:39:26 2016 +0000
@@ -221,11 +221,32 @@
 	}
 
 	/**
+	 * Set the id length.
+	 * @param size.
+	 */
+	void setIdLength(uint8_t size) {
+		if(size!=0){
+			idLength = size;
+			setIL(true);
+		}else
+			setIL(false);
+
+	}
+
+	/**
+	 * Get the id length.
+	 * @return id length
+	 */
+	uint8_t getIdLength() const {
+		return idLength;
+	}
+
+	/**
 	 * Get the number of bytes needed to store this record.
 	 * @return 3 or 6
 	 */
 	uint16_t getRecordLength() const {
-		return (getSR() ? 3 : 6) + typeLength + payloadLength;
+		return (getSR() ? 3 : 6) + (getIL() ? idLength : 0)+typeLength + payloadLength;
 	}
 
 	/**
@@ -250,6 +271,8 @@
 					>> 8);
 			outBuffer[index++] = (uint8_t) (payloadLength & 0x000000FF);
 		} //if-else
+		if(getIL())
+			outBuffer[index++] =idLength;
 		return index;
 	} //writeHeader
 
@@ -271,6 +294,10 @@
 					| ((uint32_t) buffer[index + 3]);
 			index += 4;
 		} //if-else
+		if(getIL())
+			idLength=buffer[index++];
+		else
+			idLength=0;
 		return index;
 	} //loadHeader
 
@@ -290,6 +317,7 @@
 	}
 
 private:
+	uint8_t idLength;
 	uint8_t headerFlags;
 	uint8_t typeLength;
 	uint32_t payloadLength;