• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef  NFCFORUM_H_
17 #define  NFCFORUM_H_
18 
19 #include <stdbool.h>
20 
21 #include "rtdTypes.h"
22 #include "NT3H.h"
23 
24 #define NDEF_START_BYTE     0x03
25 #define NDEF_END_BYTE       0xFE
26 
27 #define NTAG_ERASED         0xD0
28 
29 typedef struct {
30     uint8_t startByte;
31     uint8_t payloadLength;
32 } NDEFHeaderStr;
33 
34 #define BIT_MB (1<<7)
35 #define BIT_ME (1<<6)
36 #define BIT_CF (1<<5)
37 #define BIT_SR (1<<4)
38 #define BIT_IL (1<<3)
39 #define BIT_TNF (1<<0)
40 #define MASK_MB  0x80
41 #define MASK_ME  0x40
42 #define MASK_CF  0x20
43 #define MASK_SR  0x10
44 #define MASK_IL  0x08
45 #define MASK_TNF 0x07
46 
47 typedef struct {
48     uint8_t     header;
49     uint8_t     typeLength;
50     uint8_t     payloadLength;
51     RTDTypeStr type;
52 } NDEFRecordStr;
53 
54 uint8_t composeRtdText(const NDEFDataStr *ndef,  NDEFRecordStr *ndefRecord, uint8_t *I2CMsg);
55 uint8_t composeRtdUri(const NDEFDataStr *ndef,  NDEFRecordStr *ndefRecord, uint8_t *I2CMsg);
56 void composeNDEFMBME(bool isFirstRecord, bool isLastRecord, NDEFRecordStr *ndefRecord);
57 
58 #endif /* NFCFORUM.H_H_ */
59