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:
19:13d84b136a62
Parent:
18:cf1dd5c931c2
Child:
20:31f727872290
diff -r cf1dd5c931c2 -r 13d84b136a62 Message.cpp
--- a/Message.cpp	Thu Oct 27 07:39:26 2016 +0000
+++ b/Message.cpp	Fri Apr 28 12:13:51 2017 +0000
@@ -2,8 +2,8 @@
  ******************************************************************************
  * @file    Message.cpp
  * @author  ST / Central Labs
- * @version V1.0.0
- * @date    6 Nov 2015
+ * @version V2.0.0
+ * @date    28 Apr 2017
  * @brief   NDef Message class implementation
  ******************************************************************************
  * @attention
@@ -45,17 +45,17 @@
 
 namespace NDefLib {
 
-uint16_t Message::getByteLength() const {
+uint16_t Message::get_byte_length() const {
 	uint16_t lenght = 2; //length size
 
 	if (mRecords.size() == 0)
-		return lenght + EmptyRecord().getByteLength();
+		return lenght + EmptyRecord().get_byte_length();
 
 	std::vector<Record*>::const_iterator it = mRecords.begin();
 	const std::vector<Record*>::const_iterator end = mRecords.end();
 
 	for (; it != end; ++it) {
-		lenght += (*it)->getByteLength();
+		lenght += (*it)->get_byte_length();
 	} //for
 
 	return lenght;
@@ -63,7 +63,7 @@
 
 uint16_t Message::write(uint8_t *buffer) const {
 
-	const uint16_t length = getByteLength() - 2;
+	const uint16_t length = get_byte_length() - 2;
 	uint16_t offset = 0;
 	buffer[offset++] = (uint8_t) ((length & 0xFF00) >> 8);
 	buffer[offset++] = (uint8_t) ((length & 0x00FF));
@@ -78,11 +78,11 @@
 	for (uint32_t i = 0; i < nRecord; i++) {
 		Record *r = mRecords[i];
 
-		r->setAsMiddleRecord();
+		r->set_as_middle_record();
 		if (i == 0)
-			r->setAsFirstRecord();
+			r->set_as_first_record();
 		if (i == nRecord - 1)
-			r->setAsLastRecord();
+			r->set_as_last_record();
 
 		offset += r->write(buffer + offset);
 	} //for
@@ -90,14 +90,14 @@
 	return offset;
 } //write
 
-void Message::parseMessage(const uint8_t * const rawNdefFile,
+void Message::parse_message(const uint8_t * const rawNdefFile,
 		const uint16_t length, Message *msg) {
 	uint16_t offset = 0;
 	Record *r;
 
 	RecordHeader header;
 	do {
-		const uint8_t headerLenght = header.loadHeader(rawNdefFile + offset);
+		const uint8_t headerLenght = header.load_header(rawNdefFile + offset);
 		r = RecordText::parse(header, rawNdefFile + offset + headerLenght);
 		if (r == NULL)
 			r = RecordAAR::parse(header, rawNdefFile + offset + headerLenght);
@@ -107,14 +107,14 @@
 		if (r == NULL)
 			r = RecordURI::parse(header, rawNdefFile + offset + headerLenght);
 
-		offset += header.getRecordLength();
-		msg->addRecord(r);
+		offset += header.get_record_length();
+		msg->add_record(r);
 	} while (offset < length);
 
 }
 
-void Message::removeAndDeleteAllRecord(Message &msg){
-    const uint32_t nRecords =msg.getNRecords();
+void Message::remove_and_delete_all_record(Message &msg){
+    const uint32_t nRecords =msg.get_N_records();
 	for(uint32_t i =0 ;i<nRecords ;i++){
         NDefLib::Record *r = msg[i];
         delete r;