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:
Wed Mar 30 14:49:10 2016 +0000
Revision:
3:5425c805fa1f
Parent:
2:9ffb69ac065b
update to use MIT license

Who changed what in which revision?

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