Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
nfc_ndef.h
Go to the documentation of this file.
1#ifndef NFC_H
2#define NFC_H
3
4#include "stdint.h"
5#include "errors.h"
6
7/*********************
8 * DEFINES
9 *********************/
10// From ST lib_NDEF.h
11#define URI_ID_0x00 0x00
12#define URI_ID_0x01 0x01
13#define URI_ID_0x02 0x02
14#define URI_ID_0x03 0x03
15#define URI_ID_0x04 0x04
16#define URI_ID_0x05 0x05
17#define URI_ID_0x06 0x06
18#define URI_ID_0x07 0x07
19#define URI_ID_0x08 0x08
20#define URI_ID_0x09 0x09
21#define URI_ID_0x0A 0x0A
22#define URI_ID_0x0B 0x0B
23#define URI_ID_0x0C 0x0C
24#define URI_ID_0x0D 0x0D
25#define URI_ID_0x0E 0x0E
26#define URI_ID_0x0F 0x0F
27#define URI_ID_0x10 0x10
28#define URI_ID_0x11 0x11
29#define URI_ID_0x12 0x12
30#define URI_ID_0x13 0x13
31#define URI_ID_0x14 0x14
32#define URI_ID_0x15 0x15
33#define URI_ID_0x16 0x16
34#define URI_ID_0x17 0x17
35#define URI_ID_0x18 0x18
36#define URI_ID_0x19 0x19
37#define URI_ID_0x1A 0x1A
38#define URI_ID_0x1B 0x1B
39#define URI_ID_0x1C 0x1C
40#define URI_ID_0x1D 0x1D
41#define URI_ID_0x1E 0x1E
42#define URI_ID_0x1F 0x1F
43#define URI_ID_0x20 0x20
44#define URI_ID_0x21 0x21
45#define URI_ID_0x22 0x22
46#define URI_ID_0x23 0x23
47#define URI_RFU 0x24
48
49#define URI_ID_0x01_STRING "http://www.\0"
50#define URI_ID_0x02_STRING "https://www.\0"
51#define URI_ID_0x03_STRING "http://\0"
52#define URI_ID_0x04_STRING "https://\0"
53#define URI_ID_0x05_STRING "tel:\0"
54#define URI_ID_0x06_STRING "mailto:\0"
55#define URI_ID_0x07_STRING "ftp://anonymous:anonymous@\0"
56#define URI_ID_0x08_STRING "ftp://ftp.\0"
57#define URI_ID_0x09_STRING "ftps://\0"
58#define URI_ID_0x0A_STRING "sftp://\0"
59#define URI_ID_0x0B_STRING "smb://\0"
60#define URI_ID_0x0C_STRING "nfs://\0"
61#define URI_ID_0x0D_STRING "ftp://\0"
62#define URI_ID_0x0E_STRING "dav://\0"
63#define URI_ID_0x0F_STRING "news:\0"
64#define URI_ID_0x10_STRING "telnet://\0"
65#define URI_ID_0x11_STRING "imap:\0"
66#define URI_ID_0x12_STRING "rtsp://\0"
67#define URI_ID_0x13_STRING "urn:\0"
68#define URI_ID_0x14_STRING "pop:\0"
69#define URI_ID_0x15_STRING "sip:\0"
70#define URI_ID_0x16_STRING "sips:\0"
71#define URI_ID_0x17_STRING "tftp:\0"
72#define URI_ID_0x18_STRING "btspp://\0"
73#define URI_ID_0x19_STRING "btl2cap://\0"
74#define URI_ID_0x1A_STRING "btgoep://\0"
75#define URI_ID_0x1B_STRING "tcpobex://\0"
76#define URI_ID_0x1C_STRING "irdaobex://\0"
77#define URI_ID_0x1D_STRING "file://\0"
78#define URI_ID_0x1E_STRING "urn:epc:id:\0"
79#define URI_ID_0x1F_STRING "urn:epc:tag\0"
80#define URI_ID_0x20_STRING "urn:epc:pat:\0"
81#define URI_ID_0x21_STRING "urn:epc:raw:\0"
82#define URI_ID_0x22_STRING "urn:epc:\0"
83#define URI_ID_0x23_STRING "urn:nfc:\0"
84
85#define URI_ID_STRING_MAX_LEN 27 // strlen(URI_ID_0x07_STRING)+1
86
87#define NFC_TEXT_MAX_LEN 215
88#define NFC_INFO_MAX_LEN 30
89
90#define NFC_NDEF_MAX_SIZE (URI_ID_STRING_MAX_LEN + NFC_TEXT_MAX_LEN + NFC_INFO_MAX_LEN + 1)
91
92#define NFC_NDEF_TYPE_TEXT 0x01
93#define NFC_NDEF_TYPE_URI 0x02
94
95/**********************
96 * TYPEDEFS
97 **********************/
98
102typedef struct __attribute__((packed)) ndef_struct_s {
103 uint8_t ndef_type; // NDEF message type NFC_NDEF_TYPE_TEXT / NFC_NDEF_TYPE_URI
104 uint8_t uri_id; // URI string id (only applicable for NFC_NDEF_TYPE_URI)
105 char text[NFC_TEXT_MAX_LEN + 1]; // String to store NDEF text/uri +1 for \0
106 char info[NFC_INFO_MAX_LEN + 1]; // String to store NDEF uri information +1 for \0
108
109/**********************
110 * GLOBAL PROTOTYPES
111 **********************/
112uint16_t os_get_uri_header(uint8_t uri_id, char *uri_header);
114uint16_t os_ndef_to_string(ndef_struct_t *ndef_message, char *out_string);
115
116#endif
ndef_struct_t
Definition nfc_ndef.h:107
#define NFC_INFO_MAX_LEN
Definition nfc_ndef.h:88
#define NFC_TEXT_MAX_LEN
Definition nfc_ndef.h:87
struct __attribute__((packed)) ndef_struct_s
Structure to store an NDEF message.
Definition nfc_ndef.h:102
uint8_t os_parse_ndef(uint8_t *in_buffer, ndef_struct_t *parsed)
uint16_t os_get_uri_header(uint8_t uri_id, char *uri_header)
uint16_t os_ndef_to_string(ndef_struct_t *ndef_message, char *out_string)
unsigned short uint16_t
Definition usbd_conf.h:54
unsigned char uint8_t
Definition usbd_conf.h:53