Library to pull unique device ID from CPU chip. functions to load into a string that can be used in IoT access point ID and another to send the ID back on serial port. Tested on KL46Z but should work on STM and others by changing address where ID is located.
Dependents: stm32_print_unique_serial_number_copy bcsdk bcsdk bcsdk-sdchain
uniqueCPUID.cpp@2:08766dc8051a, 2016-03-30 (annotated)
- Committer:
- joeata2wh
- Date:
- Wed Mar 30 14:49:03 2016 +0000
- Revision:
- 2:08766dc8051a
- Parent:
- 0:b9461291f915
update to use MIT license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joeata2wh | 0:b9461291f915 | 1 | #include "mbed.h" |
joeata2wh | 0:b9461291f915 | 2 | #include "uniqueCPUID.h" |
joeata2wh | 0:b9461291f915 | 3 | |
joeata2wh | 2:08766dc8051a | 4 | /* |
joeata2wh | 2:08766dc8051a | 5 | By Joseph Ellsworth CTO of A2WH |
joeata2wh | 2:08766dc8051a | 6 | Take a look at A2WH.com Producing Water from Air using Solar Energy |
joeata2wh | 2:08766dc8051a | 7 | March-2016 License: https://developer.mbed.org/handbook/MIT-Licence |
joeata2wh | 2:08766dc8051a | 8 | Please contact us http://a2wh.com for help with custom design projects. |
joeata2wh | 2:08766dc8051a | 9 | */ |
joeata2wh | 0:b9461291f915 | 10 | |
joeata2wh | 0:b9461291f915 | 11 | void getUniqueIDAsStr(char *destStr) |
joeata2wh | 0:b9461291f915 | 12 | { |
joeata2wh | 0:b9461291f915 | 13 | unsigned long *Unique = uniqueSerialAddr; |
joeata2wh | 0:b9461291f915 | 14 | sprintf(destStr, "S%luX%luX%luX\000", Unique[0], Unique[1], Unique[2]); |
joeata2wh | 0:b9461291f915 | 15 | } |
joeata2wh | 0:b9461291f915 | 16 | |
joeata2wh | 0:b9461291f915 | 17 | |
joeata2wh | 0:b9461291f915 | 18 | void printUniqueId(Serial pc) { |
joeata2wh | 0:b9461291f915 | 19 | unsigned long *Unique = uniqueSerialAddr; |
joeata2wh | 0:b9461291f915 | 20 | printf("Simple Serial# %08luX %08luX %08luX\n", Unique[0], Unique[1], Unique[2]); |
joeata2wh | 0:b9461291f915 | 21 | } |