Pulls unique serial number from CPU and prints to serial console and displays on LCD. Used to generate a guaranteed unique ID for IoT apps where the IoT device needs to become it's own access point. Should work on native hardware unlike the MBED MAC address which would not be available on some custom PCB. Tested on KL46Z but should also work on most STM CPU.

Dependencies:   SLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
joeata2wh
Date:
Wed Mar 09 17:50:16 2016 +0000
Parent:
0:eddce2241b50
Commit message:
added lu specifier to avoid compiler warning in printf

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r eddce2241b50 -r 61ccbbc268f6 main.cpp
--- a/main.cpp	Tue Mar 08 20:54:53 2016 +0000
+++ b/main.cpp	Wed Mar 09 17:50:16 2016 +0000
@@ -39,7 +39,7 @@
 void getUniqueIDAsStr(char *destStr)
 {
     unsigned long *Unique = uniqueSerialAddr;
-    sprintf(destStr, "S%X%X%X\000", Unique[0], Unique[1], Unique[2]);
+    sprintf(destStr, "S%luX%luX%luX\000", Unique[0], Unique[1], Unique[2]);
 }
 
 
@@ -72,7 +72,7 @@
 {
     pc.baud(9600);
     unsigned long *Unique = uniqueSerialAddr;
-    printf("Simple Serial# %08X %08X %08X\n", Unique[0], Unique[1], Unique[2]);
+    printf("Simple Serial# %08luX %08luX %08luX\n", Unique[0], Unique[1], Unique[2]);
 
     char uniqueAsStr[33];
     getUniqueIDAsStr(uniqueAsStr);