This pull request renames NDEFRead and NDEFSend to NDEFReadMessage and NDEFSendRawMessage respectively. Furthermore, it add a new example called NDEFSendMessage that uses the new methods to create messages.
Advanced users can create their own custom messages using NDEFSendRawMessage like this:
// Create a message with 1 record
const char ndefMessage[] = {0xD1, // MB/ME/CF/1/IL/TNF
0x01, // Type length (1 byte)
0x08, // Payload length (status, language, content)
'T', // Type -> 'T' for text, 'U' for URI
0x02, // Status
'e', 'n', // Language
'H', 'e', 'l', 'l', 'o',}; // Content
In the NDEFSendMessage example, the message is created using methods. Users can create as many records as they want, with a maximum of 255 bytes per message. However, the library only supports the creation of one message at a time.
message.addTextRecord("Hello"); // English by default
message.addTextRecord("world", "en"); // English explicitly, the library only supports two letter language codes (ISO 639-1) by now
message.addTextRecord("Hola mundo!", "es"); // Spanish explicitly, check a language code table at https://www.science.co.il/language/Locale-codes.php
message.addTextRecord("Bonjour le monde!", "fr"); // French explicitly
message.addUriRecord("google.com"); // No prefix explicitly
message.addUriRecord("https://www.electroniccats.com"); // https://www. prefix explicitly
message.addUriRecord("tel:1234567890"); // The library can handle all the prefixes listed at https://github.com/ElectronicCats/ElectronicCats-PN7150/blob/master/API.md#uri-prefixes
String ssid = "Bomber Cat"; // SSID of the WiFi network
String authenticationType = "WPA2 PERSONAL"; // Supported authentication types at https://github.com/ElectronicCats/ElectronicCats-PN7150/blob/master/API.md#wifi-authentication-types
String encryptionType = "AES"; // Supported encryption types at https://github.com/ElectronicCats/ElectronicCats-PN7150/blob/master/API.md#wifi-encryption-types
String password = "Password"; // Password of the WiFi network
message.addWiFiRecord(ssid, authenticationType, encryptionType, password);
message.addUriRecord("mailto:deimoshall@gmail.com");
message.addMimeMediaRecord("text/plain", "Hello world!", 12); // Media-type as defined in RFC 2046
The first approach gives the user more control over the message, but it requires more knowledge about the NDEF format. The second one is easier, but it has the following limitations:
Only supports two letter language codes (ISO 639-1)
Does not support nested records
Does not support multiple messages
Only supports well-known and media-type records
Chunk flag (CF) is always set to 0
Short record (SR) flag is always set to 1
ID length (IL) is always set to 0, so there is no ID field
In future versions this limitations could be removed.
The status of the completed and pending tasks is as follows:
[ ] Add support for empty records
[x] Add support for NFC Forum well-known type [NFC RTD] records
[x] Add support for Media-type as defined in RFC 2046 [RFC 2046] records
[ ] Add support for Absolute URI as defined in RFC 3986 [RFC 3986] records
[ ] Add support for NFC Forum external type [NFC RTD] records
This pull request renames
NDEFRead
andNDEFSend
toNDEFReadMessage
andNDEFSendRawMessage
respectively. Furthermore, it add a new example calledNDEFSendMessage
that uses the new methods to create messages.Advanced users can create their own custom messages using
NDEFSendRawMessage
like this:In the
NDEFSendMessage
example, the message is created using methods. Users can create as many records as they want, with a maximum of 255 bytes per message. However, the library only supports the creation of one message at a time.The first approach gives the user more control over the message, but it requires more knowledge about the NDEF format. The second one is easier, but it has the following limitations:
The status of the completed and pending tasks is as follows: