Pulse Oximeter (NONIN) communicates with mbed via Bluetooth dongle and sends Heart Rate and Oxygen Saturation via GPRS module
Dependencies: C12832 GPS GSM mbed
Fork of myBlueUSB_localfix by
Utils.cpp@0:003889bc474f, 2013-12-07 (annotated)
- Committer:
- nobukuma
- Date:
- Sat Dec 07 14:19:00 2013 +0000
- Revision:
- 0:003889bc474f
http://mbed.org/users/networker/code/myBlueUSB/ rev13??rev12??????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nobukuma | 0:003889bc474f | 1 | |
nobukuma | 0:003889bc474f | 2 | |
nobukuma | 0:003889bc474f | 3 | #include "mbed.h" |
nobukuma | 0:003889bc474f | 4 | #include "Utils.h" |
nobukuma | 0:003889bc474f | 5 | |
nobukuma | 0:003889bc474f | 6 | void printfBytes(const char* s, const u8* data, int len) |
nobukuma | 0:003889bc474f | 7 | { |
nobukuma | 0:003889bc474f | 8 | printf("%s %d:",s,len); |
nobukuma | 0:003889bc474f | 9 | if (len > 256) |
nobukuma | 0:003889bc474f | 10 | len = 256; |
nobukuma | 0:003889bc474f | 11 | while (len-- > 0) |
nobukuma | 0:003889bc474f | 12 | printf(" %02X",*data++); |
nobukuma | 0:003889bc474f | 13 | printf("\n"); |
nobukuma | 0:003889bc474f | 14 | } |
nobukuma | 0:003889bc474f | 15 | |
nobukuma | 0:003889bc474f | 16 | void printHexLine(const u8* d, int addr, int len) |
nobukuma | 0:003889bc474f | 17 | { |
nobukuma | 0:003889bc474f | 18 | printf("%04X ",addr); |
nobukuma | 0:003889bc474f | 19 | int i; |
nobukuma | 0:003889bc474f | 20 | for (i = 0; i < len; i++) |
nobukuma | 0:003889bc474f | 21 | printf("%02X ",d[i]); |
nobukuma | 0:003889bc474f | 22 | for (;i < 16; i++) |
nobukuma | 0:003889bc474f | 23 | printf(" "); |
nobukuma | 0:003889bc474f | 24 | char s[16+1]; |
nobukuma | 0:003889bc474f | 25 | memset(s,0,sizeof(s)); |
nobukuma | 0:003889bc474f | 26 | for (i = 0; i < len; i++) |
nobukuma | 0:003889bc474f | 27 | { |
nobukuma | 0:003889bc474f | 28 | int c = d[i]; |
nobukuma | 0:003889bc474f | 29 | if (c < 0x20 || c > 0x7E) |
nobukuma | 0:003889bc474f | 30 | c = '.'; |
nobukuma | 0:003889bc474f | 31 | s[i] = c; |
nobukuma | 0:003889bc474f | 32 | } |
nobukuma | 0:003889bc474f | 33 | printf("%s\n",s); |
nobukuma | 0:003889bc474f | 34 | } |
nobukuma | 0:003889bc474f | 35 | |
nobukuma | 0:003889bc474f | 36 | void printHex(const u8* d, int len) |
nobukuma | 0:003889bc474f | 37 | { |
nobukuma | 0:003889bc474f | 38 | int addr = 0; |
nobukuma | 0:003889bc474f | 39 | while (len) |
nobukuma | 0:003889bc474f | 40 | { |
nobukuma | 0:003889bc474f | 41 | int count = len; |
nobukuma | 0:003889bc474f | 42 | if (count > 16) |
nobukuma | 0:003889bc474f | 43 | count = 16; |
nobukuma | 0:003889bc474f | 44 | printHexLine(d+addr,addr,count); |
nobukuma | 0:003889bc474f | 45 | addr += 16; |
nobukuma | 0:003889bc474f | 46 | len -= count; |
nobukuma | 0:003889bc474f | 47 | } |
nobukuma | 0:003889bc474f | 48 | } |
nobukuma | 0:003889bc474f | 49 |