How to print the MAC address of an mbed to the dispBoB

Dependencies:   dispBoB mbed PCA9635

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers macAddress.cpp Source File

macAddress.cpp

00001 #include "mbed.h"
00002 #include "dispBoB.h"
00003 #include "stdio.h"
00004 
00005 dispBoB db(p28, p27, p26);                  //object instantiation
00006 extern "C" int mbed_mac_address(char *);
00007 
00008 int main() {
00009     uint64_t uid = 0;
00010     char mac[6];
00011     mbed_mac_address(mac);                  //this copies the MAC address into the 
00012     uid = mac[0] << 40 | mac[1] << 32 |     //variable 'uid'
00013           mac[2] << 24 | mac[3] << 16 |
00014           mac[4] << 8  | mac[5] << 0;   
00015     char MACAddressBuffer[9];
00016     sprintf(MACAddressBuffer, "%x", uid);   //convert type uint64_t --> char* (format hex)
00017     db.scroll(MACAddressBuffer, 0.2);       //scroll foramtted MAC address across dispBoB
00018 }