mbed base bard check program for BlueTooth USB dongle module (3 switches, 6 leds, I2C LCD, A/D)
Fork of BTstack by
usbbt/bd_addr.cpp@3:7b7d1273e2d5, 2016-10-17 (annotated)
- Committer:
- tamaki
- Date:
- Mon Oct 17 00:25:18 2016 +0000
- Revision:
- 3:7b7d1273e2d5
- Parent:
- 0:1ed23ab1345f
mbed base bard check program
; for BlueTooth USB dongle module
; (3 switches, 6 leds, I2C LCD, A/D)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:1ed23ab1345f | 1 | #include "mbed.h" |
va009039 | 0:1ed23ab1345f | 2 | #include "bd_addr.h" |
va009039 | 0:1ed23ab1345f | 3 | bd_addr::bd_addr() |
va009039 | 0:1ed23ab1345f | 4 | { |
va009039 | 0:1ed23ab1345f | 5 | |
va009039 | 0:1ed23ab1345f | 6 | } |
va009039 | 0:1ed23ab1345f | 7 | |
va009039 | 0:1ed23ab1345f | 8 | bd_addr::bd_addr(char* s) |
va009039 | 0:1ed23ab1345f | 9 | { |
va009039 | 0:1ed23ab1345f | 10 | for(int i = 0; i <= 5; i++) { |
va009039 | 0:1ed23ab1345f | 11 | ad[i] = strtol(s+i*3, NULL, 16); |
va009039 | 0:1ed23ab1345f | 12 | } |
va009039 | 0:1ed23ab1345f | 13 | } |
va009039 | 0:1ed23ab1345f | 14 | |
va009039 | 0:1ed23ab1345f | 15 | uint8_t* bd_addr::data(uint8_t* addr) |
va009039 | 0:1ed23ab1345f | 16 | { |
va009039 | 0:1ed23ab1345f | 17 | if (addr != NULL) { |
va009039 | 0:1ed23ab1345f | 18 | ad[5] = addr[0]; |
va009039 | 0:1ed23ab1345f | 19 | ad[4] = addr[1]; |
va009039 | 0:1ed23ab1345f | 20 | ad[3] = addr[2]; |
va009039 | 0:1ed23ab1345f | 21 | ad[2] = addr[3]; |
va009039 | 0:1ed23ab1345f | 22 | ad[1] = addr[4]; |
va009039 | 0:1ed23ab1345f | 23 | ad[0] = addr[5]; |
va009039 | 0:1ed23ab1345f | 24 | } |
va009039 | 0:1ed23ab1345f | 25 | return ad; |
va009039 | 0:1ed23ab1345f | 26 | } |
va009039 | 0:1ed23ab1345f | 27 | |
va009039 | 0:1ed23ab1345f | 28 | char* bd_addr::to_str() |
va009039 | 0:1ed23ab1345f | 29 | { |
va009039 | 0:1ed23ab1345f | 30 | snprintf(ad_str, sizeof(ad_str), "%02X:%02X:%02X:%02X:%02X:%02X", |
va009039 | 0:1ed23ab1345f | 31 | ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]); |
va009039 | 0:1ed23ab1345f | 32 | return ad_str; |
va009039 | 0:1ed23ab1345f | 33 | } |