![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A blue button is always a nice toy ...
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/print.h@27:32267cee7cb8, 2017-01-14 (annotated)
- Committer:
- hux
- Date:
- Sat Jan 14 08:43:14 2017 +0000
- Revision:
- 27:32267cee7cb8
- Parent:
- 24:0f08f68579bd
Setup a GATT Detector Service. There is some bug in the GATT setup, resulting in different behavior between Nordic nRF51822-DK and NUCLEO-L476RG, but with the workaround it works also for the NUCLEO board. (using Bricks V1A)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 24:0f08f68579bd | 1 | // print.h - print value of a characteristic |
hux | 24:0f08f68579bd | 2 | // |
hux | 24:0f08f68579bd | 3 | // Synopsis: |
hux | 24:0f08f68579bd | 4 | // |
hux | 24:0f08f68579bd | 5 | // See also: CHARACTERISTIC, GET, SET |
hux | 24:0f08f68579bd | 6 | // |
hux | 24:0f08f68579bd | 7 | #ifndef _PRINT_H_ |
hux | 24:0f08f68579bd | 8 | #define _PRINT_H_ |
hux | 24:0f08f68579bd | 9 | |
hux | 24:0f08f68579bd | 10 | #include "ble/Gap.h" |
hux | 27:32267cee7cb8 | 11 | #include "bricks/o.h" |
hux | 27:32267cee7cb8 | 12 | #include "bricks/types.h" |
hux | 27:32267cee7cb8 | 13 | #include "bricks/characteristic.h" |
hux | 24:0f08f68579bd | 14 | |
hux | 24:0f08f68579bd | 15 | //============================================================================== |
hux | 24:0f08f68579bd | 16 | // Some Callbacks |
hux | 24:0f08f68579bd | 17 | //============================================================================== |
hux | 24:0f08f68579bd | 18 | |
hux | 27:32267cee7cb8 | 19 | inline void print(O&o, Characteristic<Buffer> &chr, const char *name) |
hux | 24:0f08f68579bd | 20 | { |
hux | 24:0f08f68579bd | 21 | Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 24:0f08f68579bd | 22 | |
hux | 24:0f08f68579bd | 23 | Buffer data; uint8_t *p = data; |
hux | 27:32267cee7cb8 | 24 | get(o,chr,data); |
hux | 24:0f08f68579bd | 25 | |
hux | 24:0f08f68579bd | 26 | out.printf("%s: %02x-%02x-%02x-%02x-%02x-",name,(int)(p[0]),(int)(p[1]),(int)(p[2]),(int)(p[3]),(int)(p[4])); |
hux | 24:0f08f68579bd | 27 | out.printf("%02x-%02x-%02x-%02x-%02x\r\n",(int)(p[5]),(int)(p[6]),(int)(p[7]),(int)(p[8]),(int)(p[9])); |
hux | 24:0f08f68579bd | 28 | } |
hux | 24:0f08f68579bd | 29 | |
hux | 27:32267cee7cb8 | 30 | inline void print(O&o, Characteristic<Bool> &chr, const char *name) |
hux | 27:32267cee7cb8 | 31 | { |
hux | 27:32267cee7cb8 | 32 | Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 27:32267cee7cb8 | 33 | Bool data; |
hux | 27:32267cee7cb8 | 34 | |
hux | 27:32267cee7cb8 | 35 | get(o,chr,data); |
hux | 27:32267cee7cb8 | 36 | out.printf("%s: %02x\r\n",name,(int)data); |
hux | 27:32267cee7cb8 | 37 | } |
hux | 27:32267cee7cb8 | 38 | |
hux | 27:32267cee7cb8 | 39 | // we provide also some PRINT methods for non Characteristics. If the value of |
hux | 27:32267cee7cb8 | 40 | // a characteristic needs to be printed the value must be fetched before with |
hux | 27:32267cee7cb8 | 41 | // the GET function. |
hux | 27:32267cee7cb8 | 42 | |
hux | 27:32267cee7cb8 | 43 | inline void print(O&o, Bool data, const char *name) |
hux | 27:32267cee7cb8 | 44 | { |
hux | 27:32267cee7cb8 | 45 | Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 27:32267cee7cb8 | 46 | out.printf("%s: %02x\r\n",(int)&data); |
hux | 27:32267cee7cb8 | 47 | } |
hux | 27:32267cee7cb8 | 48 | |
hux | 24:0f08f68579bd | 49 | #endif // _SET_H_ |