Bluetooth support for MBED with $2 Bluetooth dongles. Includes a USB host and built in support for bluetooth HID devices such as mice, keyboards and wii controllers.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Utils.cpp Source File

Utils.cpp

00001 
00002 
00003 #include "mbed.h"
00004 #include "Utils.h"
00005 
00006 void printfBytes(const char* s, const u8* data, int len)
00007 {
00008     printf("%s %d:",s,len);
00009     if (len > 256)
00010         len = 256;
00011     while (len-- > 0)
00012         printf(" %02X",*data++);
00013     printf("\n");
00014 }
00015 
00016 void printHexLine(const u8* d, int addr, int len)
00017 {
00018     printf("%04X ",addr);
00019     int i;
00020     for (i = 0; i < len; i++)
00021         printf("%02X ",d[i]);
00022     for (;i < 16; i++)
00023         printf("   ");
00024     char s[16+1];
00025     memset(s,0,sizeof(s));
00026     for (i = 0; i < len; i++)
00027     {
00028         int c = d[i];
00029         if (c < 0x20 || c > 0x7E)
00030             c = '.';
00031         s[i] = c;
00032     }
00033     printf("%s\n",s);
00034 }
00035 
00036 void printHex(const u8* d, int len)
00037 {
00038     int addr = 0;
00039     while (len)
00040     {
00041         int count = len;
00042         if (count > 16)
00043             count = 16;
00044         printHexLine(d+addr,addr,count);
00045         addr += 16;
00046         len -= count;
00047     }
00048 }