Skip to content

Commit

Permalink
refactor: size by length in some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Dec 29, 2023
1 parent f5a2105 commit 4e8b0dc
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 206 deletions.
10 changes: 5 additions & 5 deletions examples/NDEFReadMessage/NDEFReadMessage.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void messageReceivedCallback() {
}

Serial.print("NDEF message: ");
Serial.println(getHexRepresentation(message.getContent(), message.getContentSize()));
Serial.println(getHexRepresentation(message.getContent(), message.getContentLength()));

// Show NDEF message details, it is composed of records
do {
Expand Down Expand Up @@ -253,16 +253,16 @@ void displayRecordInfo(NdefRecord record) {

case record.type.MEDIA_HANDOVER_BLE:
Serial.print("\tBLE Handover");
Serial.println("\t- Payload size: " + String(record.getPayloadSize()) + " bytes");
Serial.println("\t- Payload size: " + String(record.getPayloadLength()) + " bytes");
Serial.print("\t- Payload = ");
Serial.println(getHexRepresentation(record.getPayload(), record.getPayloadSize()));
Serial.println(getHexRepresentation(record.getPayload(), record.getPayloadLength()));
break;

case record.type.MEDIA_HANDOVER_BLE_SECURE:
Serial.print("\tBLE secure Handover");
Serial.println("\t- Payload size: " + String(record.getPayloadSize()) + " bytes");
Serial.println("\t- Payload size: " + String(record.getPayloadLength()) + " bytes");
Serial.print("\t- Payload = ");
Serial.println(getHexRepresentation(record.getPayload(), record.getPayloadSize()));
Serial.println(getHexRepresentation(record.getPayload(), record.getPayloadLength()));
break;

default:
Expand Down
87 changes: 20 additions & 67 deletions examples/NDEFSendRawMessage/NDEFSendRawMessage.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,73 +28,26 @@ Electroniccats_PN7150 nfc(PN7150_IRQ, PN7150_VEN, PN7150_ADDR); // Creates a gl
NdefMessage message;

// Three records, "Hello", "world" and Uri "https://www.electroniccats.com"
// const char ndefMessage[] = {0x91, // MB/ME/CF/1/IL/TNF
// 0x01, // Type length (1 byte)
// 0x08, // Payload length
// 'T', // Type -> 'T' for text, 'U' for URI
// 0x02, // Status
// 'e', 'n', // Language
// 'H', 'e', 'l', 'l', 'o', // Message Payload
// 0x11, // MB/ME/CF/1/IL/TNF
// 0x01, // Type length (1 byte)
// 0x08, // Payload length
// 'T', // Type -> 'T' for text, 'U' for URI
// 0x02, // Status
// 'e', 'n', // Language
// 'w', 'o', 'r', 'l', 'd', // Message Payload
// 0x51, // MB/ME/CF/1/IL/TNF
// 0x01, // Type length (1 byte)
// 0x13, // Payload length
// 'U', // Type -> 'T' for text, 'U' for URI
// 0x02, // Status
// 'e', 'l', 'e', 'c', 't', 'r', 'o', 'n', 'i', 'c', 'c', 'a', 't', 's', '.', 'c', 'o', 'm'}; // Message Payload

// One uri record "https://www.electroniccats.com"
// const char ndefMessage[] = {0xD1,
// 0x01,
// 0x13,
// 'U',
// 0x02,
// 'e', 'l', 'e', 'c', 't', 'r', 'o', 'n', 'i', 'c', 'c', 'a', 't', 's', '.', 'c', 'o', 'm'};

// One media record of type "application/vnd.wfa.wsc", with network name = test, Authentication type = OPEN, Encription type = AES, Password = password
const char ndefMessage[] = {
0xD2, // MB/ME/CF/1/IL/TNF
0X17, // Type length
0x2A, // Payload length
'a', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o', 'n', '/', 'v', 'n', 'd', '.', 'w', 'f', 'a', '.', 'w', 's', 'c', // Type
0x10,
0x0E,
0x00,
0x36,
0x10,
0x26,
0x00,
0x01,
0x01,
0x10,
0x45,
0x00,
0x09, // Length of the Network Name attribute
// 't', 'e', 's', 't', 's',
'B', 'o', 'm', 'b', 'e', 'r', 'c', 'a', 't',
0x10,
0x03,
0x00,
0x02, // Length of the Authentication Type attribute
0x00,
0x01, // Value for Authentication type
0x10,
0x0F,
0x00,
0x02, // Length of the Encryption Type attribute
0x00,
0x01, // Value for Encryption type
0x10,
0x27,
0x00,
0x04, // Length of the Network Key attribute
'p', 'a', 's', 's'};
const char ndefMessage[] = {0x91, // MB/ME/CF/1/IL/TNF
0x01, // Type length (1 byte)
0x08, // Payload length
'T', // Type -> 'T' for text, 'U' for URI
0x02, // Status
'e', 'n', // Language
'H', 'e', 'l', 'l', 'o', // Message Payload
0x11, // MB/ME/CF/1/IL/TNF
0x01, // Type length (1 byte)
0x08, // Payload length
'T', // Type -> 'T' for text, 'U' for URI
0x02, // Status
'e', 'n', // Language
'w', 'o', 'r', 'l', 'd', // Message Payload
0x51, // MB/ME/CF/1/IL/TNF
0x01, // Type length (1 byte)
0x13, // Payload length
'U', // Type -> 'T' for text, 'U' for URI
0x02, // Status
'e', 'l', 'e', 'c', 't', 'r', 'o', 'n', 'i', 'c', 'c', 'a', 't', 's', '.', 'c', 'o', 'm'}; // Message Payload

void setup() {
Serial.begin(9600);
Expand Down
Loading

0 comments on commit 4e8b0dc

Please sign in to comment.