Principle: In the X1 development board, the onboard NFC chip comes with a unique serial number, and the unique ID is achieved by obtaining the UID of the chip.
Sample test program download:
Source code download:
http://dd.youyeetoo.cn:5000/sharing/gRXiVPew0
After downloading and decompressing, the source code directory structure is explained as follows:
File | Description |
---|---|
I2c. h | i2c underlying operation encapsulation |
I2c. c | i2c underlying operation encapsulation |
I2cCtrl. h | i2c application interface header file |
I2cCtrl. cpp | i2c application interface source file |
NFC_ Locker. h | Tool file |
Sha1. h | sha1 header file |
Sha1. cpp | sha1 implements files through shell |
Test_ Getid. cpp | Test code main |
Makefile | make compile script file |
jb@X1:~/cd linux-getid
#Compilation
jb@X1:~/linux-getid$ make
#Execution requires sudo permission to execute
jb@X1:~/linux-getid$ sudo ./test_getid
Connet NFC ID is OK:/dev/i2c-4
Get NFC UID OK:8AF0F5DA002402E0
calc 123 sha1 =40bd001563085fc35165329ea1ff5c5ecbdbbeef
Execution result:
Get NFC UID OK: Indicates reading NFC UID
Calc 123 sha1=represents the calculation of the sha1 hash value of string 123, which is a reference usage for making sha1 strings