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
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.
Diff: RecordType/RecordMail.cpp
- Revision:
- 20:31f727872290
- Parent:
- 19:13d84b136a62
--- a/RecordType/RecordMail.cpp Fri Apr 28 12:13:51 2017 +0000 +++ b/RecordType/RecordMail.cpp Wed Jul 12 12:33:42 2017 +0000 @@ -42,8 +42,9 @@ const std::string RecordMail::sBodyTag("&body="); void RecordMail::update_content(){ - if(!mContentIsChange) + if (!mContentIsChange) { return; + } mContent.reserve(mToAddress.size() + sSubjectTag.size() + mSubject.size() + sBodyTag.size() + mBody.size()); mContent = mToAddress; @@ -55,35 +56,36 @@ mContentIsChange=false; } - -RecordMail* RecordMail::parse(const RecordHeader &header, - const uint8_t* buffer) { +RecordMail* RecordMail::parse(const RecordHeader &header, const uint8_t* buffer) { //not a uri tag or a mail tag - if (buffer[0] != RecordURI::sNDEFUriIdCode - || buffer[1] != RecordURI::MAIL) { + if (buffer[0] != RecordURI::sNDEFUriIdCode || buffer[1] != RecordURI::MAIL) { return NULL; } - const std::string uriContent((const char*) (buffer + 2), - header.get_payload_length() - 1); + const std::string uriContent((const char*) (buffer + 2), header.get_payload_length() - 1); std::size_t subjectStart = uriContent.find(sSubjectTag); - if (subjectStart == std::string::npos) //subject not present + if (subjectStart == std::string::npos) { //subject not present return NULL; + } const std::size_t destSize = subjectStart; subjectStart += sSubjectTag.size(); //skip the tag string std::size_t bodyStart = uriContent.find(sBodyTag); - if (bodyStart == std::string::npos) //body not present + if (bodyStart == std::string::npos) { //body not present return NULL; + } const std::size_t subjectLenght = bodyStart - subjectStart; bodyStart += sBodyTag.size(); // skip the tag string const std::size_t bodyLenght = uriContent.size() - bodyStart; return new RecordMail(uriContent.substr(0, destSize), - uriContent.substr(subjectStart, subjectLenght), - uriContent.substr(bodyStart, bodyLenght)); + uriContent.substr(subjectStart, subjectLenght), + uriContent.substr(bodyStart, bodyLenght)); } } /* namespace NDefLib */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/