modified for stm chips

Dependencies:   mbed uniqueCPUID

Fork of frdm_print_unique_serial_number by Joseph Ellsworth

Print unique serial number for CPU. Ideal for use as SSID in IoT projects.

Committer:
joeata2wh
Date:
Fri Mar 11 03:25:07 2016 +0000
Revision:
2:9ffb69ac065b
Parent:
1:61ccbbc268f6
Child:
3:5425c805fa1f
change to support STM32chip.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeata2wh 0:eddce2241b50 1 /*
joeata2wh 0:eddce2241b50 2 by Joseph Ellsworth CTO A2WH.
joeata2wh 0:eddce2241b50 3 Freeuse for all. No promises, No warranty *
joeata2wh 0:eddce2241b50 4 Please contact us http://a2wh.com for help with custom design projects.
joeata2wh 0:eddce2241b50 5
joeata2wh 0:eddce2241b50 6 Most STM and Freescale ARM chips include a unique Serail Number embedded
joeata2wh 0:eddce2241b50 7 in the CPU. This is a perfect number to use in IoT as a SSID. I use
joeata2wh 0:eddce2241b50 8 this to produce the WIFi SID so I can walk up with a phone and download
joeata2wh 0:eddce2241b50 9 telemetry. I found a blog discussion for mbed that suggested using the
joeata2wh 0:eddce2241b50 10 MAC but this assumes mbed hardware whereas this version uses the serial
joeata2wh 0:eddce2241b50 11 number built in to the CPU so it should work on native boards.
joeata2wh 0:eddce2241b50 12 */
joeata2wh 0:eddce2241b50 13
joeata2wh 0:eddce2241b50 14 #include "mbed.h"
joeata2wh 0:eddce2241b50 15
joeata2wh 2:9ffb69ac065b 16 #include "uniqueCPUID.h"
joeata2wh 0:eddce2241b50 17
joeata2wh 2:9ffb69ac065b 18 Serial pc(USBTX, USBRX);
joeata2wh 0:eddce2241b50 19
joeata2wh 0:eddce2241b50 20
joeata2wh 0:eddce2241b50 21
joeata2wh 0:eddce2241b50 22 int main()
joeata2wh 0:eddce2241b50 23 {
joeata2wh 0:eddce2241b50 24 pc.baud(9600);
joeata2wh 2:9ffb69ac065b 25
joeata2wh 0:eddce2241b50 26
joeata2wh 0:eddce2241b50 27 char uniqueAsStr[33];
joeata2wh 0:eddce2241b50 28 getUniqueIDAsStr(uniqueAsStr);
joeata2wh 0:eddce2241b50 29 pc.printf("Serial as SID %s\n", uniqueAsStr); // send back to PC
joeata2wh 0:eddce2241b50 30
joeata2wh 0:eddce2241b50 31
joeata2wh 0:eddce2241b50 32 while (true) {
joeata2wh 2:9ffb69ac065b 33 wait(6.0);
joeata2wh 0:eddce2241b50 34
joeata2wh 2:9ffb69ac065b 35 pc.printf("Serial as SID %s\n", uniqueAsStr); // send back to PC
joeata2wh 0:eddce2241b50 36 }
joeata2wh 0:eddce2241b50 37 }