This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Question related to NDEF length

Dear all,

Have a look on the following code for ndef:

UINT8 ActualData [] = 	{
	/*NDEF Tag Application Name*/ 														
0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01, 												
																						
/*Capability Container ID*/ 															
0xE1, 0x03, 																			
0x00, 0x0F,	/* CCLEN */																	
0x20,		/* Mapping version 2.0 */													
0x00, 0xF9,	/* MLe (49 bytes); Maximum R-APDU data size */								
0x00, 0xF6, /* MLc (52 bytes); Maximum C-APDU data size */								
0x04, 		/* Tag, File Control TLV (4 = NDEF file) */									
0x06, 		/* Length, File Control TLV (6 = 6 bytes of data for this tag) */			
0xE1, 0x04,	/* File Identifier */														
0x0B, 0xDF, /* Max NDEF size (3037 bytes of useable memory) */							
0x00, 		/* NDEF file read access condition, read access without any security */		
0x00, 		/* NDEF file write access condition; write access without any security */	
																						
/* NDEF File ID */ 																		
0xE1, 0x04, 																			
																						
/* NDEF File for Hello World  (48 bytes total length) */								
0x00, 0xE0, /* NLEN; NDEF length (3 byte long message) */ 						//49
0xD1, 0x01, 0xDC, 																		
0x54, /* T = text */																	
0x02, 																					
0x65, 0x6E, /* 'e', 'n', */																
//35																						
/* 'Hello, world!' NDEF data; Empty NDEF message, length should match NLEN*/			
/*0x48, 0x65, 0x6C, 0x6C, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21*/		
/* '--Honeywell--' NDEF data; Empty NDEF message, length should match NLEN*/		
0x2d, 0x2d, 0x48, 0x6f, 0x6e, 0x65, 0x79, 0x77, 0x65, 0x6c, 0x6c, 0x2d, 0x2d,  
/* '--Honeywell--' NDEF data; Empty NDEF message, length should match NLEN*/
//line feed
0x0A,0x0D,
'V', 'M', 'C', '-', '1', '7', 'R','P', '0','1', 
0x0A,0x0D,
'F', 'a', 'n', 's', 'p', 'e', 'e','d', ':',' ',
'-','-','-','-','-','-','-',
//79
0x0A,0x0D,
'U','s','e','r',' ','s','e','l','e','c','t',':',' ',
//94
'-','-','-','-','-','-','-',
0x0A,0x0D,
'A', 'i', 'r', ' ', 'F', 'l', 'o','w',' ', 'S','e','t','p', ':',' ',
'-','-','-','-','-','-','-',
0x0A,0x0D,
'F', 'a', 'n', ' ', 's', 'p','e','e','d',' ', 'S','e','t', ':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'A','i','r',' ','F','l','o','w',':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'T', 'e', 'm', 'p',' ', 'S', 't','a','b', 'l', 'e', ':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'T', 'e', 'm', 'p',' ', 'S', 't','a','r', 't', ':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'T', 'e', 'm', 'p',' ', 'E', 'n','d', ':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'T', 'h', 'e', 'r','m', 'a', 'l',' ','R', 'e','s', ':',' ',
'-','-','-','-','-','-','-',
/*
0x0A,0x0D,
'E', 'l', 'e', 'c ','t', ' ', 'P','o','w', 'e', 'r', ':',' ',
'-','-','-','-','-','-','-',

0x0A,0x0D,
'S', 't', 'a', 't ','e',':',' ',
'-','-','-','-','-','-','-'*/};

if i count here, my total length will be 262 byte.
If i convert the value into hexadecimal, it will be 0X106. However, when i tried to read it again using the mobile phone, it says it failed to obtain the NDEF message.
the readable text can only reach to my "thermal res". which is 224 byte. therefore, i am post here to ask anyone, is there any suggestion, so i can get the whole desire 262-long byte message? 

Thank you in advance!

Best Regards,


Stella

  • Hey Stella,

    For any packet over 255 bytes (0xFF) you need to use a long record header.  Using a long record header is defined in the NDEF spec, but below is an example.  We changed a bit in the record header byte ( 0xD1 -> 0xC1) to indicate we are using a long record.  This now requires 4 bytes for NLEN, instead of just 1.

    Basically, you now have 2 bytes for NLEN and 4 bytes for payload length (even though you'd only ever need 2.) 

     

    const unsigned char RF430_DEFAULT_DATA[]	=	{  												\
    		/*NDEF Tag Application Name*/ 															\
    		0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01, 												\
    																								\
    		/*Capability Container ID*/ 															\
    		0xE1, 0x03, 																			\
    		0x00, 0x0F,	/* CCLEN */																	\
    		0x20,		/* Mapping version 2.0 */													\
    		0x00, 0xF9,	/* MLe (49 bytes); Maximum R-APDU data size */								\
    		0x00, 0xF6, /* MLc (52 bytes); Maximum C-APDU data size */								\
    		0x04, 		/* Tag, File Control TLV (4 = NDEF file) */									\
    		0x06, 		/* Length, File Control TLV (6 = 6 bytes of data for this tag) */			\
    		0xE1, 0x04,	/* File Identifier */														\
    		0x0B, 0xDF, /* Max NDEF size (3037 bytes of useable memory) */							\
    		0x00, 		/* NDEF file read access condition, read access without any security */		\
    		0x00, 		/* NDEF file write access condition; write access without any security */	\
    																								\
    		/* NDEF File ID */ 																		\
    		0xE1, 0x04, 																			\
    																								\
    		/* NDEF File for Hello World  (48 bytes total length) */								\
    		0x00, 0x33, /* 0x39 NLEN; NDEF length (3 byte long message) */ 							\
    		0xC1, /* Record Header	*/																\
    		0x01, /* Type Length	*/																\
    		0x00, 0x00, 0x00, 0x2C,  /* Payload length This NLEN - 7 	*/				    		\
    		0x54, /* T = text */																	\
    		0x02, /* ID length	*/																	\
    		0x65, 0x6E, /* 'e', 'n', ID */															\
    																								\
    		/* Payload	*/																			\
    																								\
    		/* 'Temperature: '*/																	\
    		0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x3a, 0x20, 			\
    		/* ' 80.0 F' */																			\
    		0x20, 0x38, 0x30, 0x2E, 0x30, 0x20, 0x46, 0x0A, /* 0x0D, */ 							\
    		/* 'Temperature: ' */																	\
    		0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x3a, 0x20, 			\
    		/* ' 40.0 C' */																			\
    		0x20, 0x34, 0x30, 0x2E, 0x30, 0x20, 0x43												\
    		};

    Try this out, and let me know once you get it working.  

    Thanks,

    JD