A nice BLE demo program which allows remote switch of an LED via GATT interface.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_Button by
bricks/print.h@11:80f2c19ecbce, 2017-01-07 (annotated)
- Committer:
- hux
- Date:
- Sat Jan 07 23:48:53 2017 +0000
- Revision:
- 11:80f2c19ecbce
New Blob class derived from BLE class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 11:80f2c19ecbce | 1 | // print.h - print value of a characteristic |
hux | 11:80f2c19ecbce | 2 | // |
hux | 11:80f2c19ecbce | 3 | // Synopsis: |
hux | 11:80f2c19ecbce | 4 | // |
hux | 11:80f2c19ecbce | 5 | // See also: CHARACTERISTIC, GET, SET |
hux | 11:80f2c19ecbce | 6 | // |
hux | 11:80f2c19ecbce | 7 | #ifndef _PRINT_H_ |
hux | 11:80f2c19ecbce | 8 | #define _PRINT_H_ |
hux | 11:80f2c19ecbce | 9 | |
hux | 11:80f2c19ecbce | 10 | #include "ble/Gap.h" |
hux | 11:80f2c19ecbce | 11 | #include "bricks/blob.h" |
hux | 11:80f2c19ecbce | 12 | |
hux | 11:80f2c19ecbce | 13 | //============================================================================== |
hux | 11:80f2c19ecbce | 14 | // Some Callbacks |
hux | 11:80f2c19ecbce | 15 | //============================================================================== |
hux | 11:80f2c19ecbce | 16 | |
hux | 11:80f2c19ecbce | 17 | inline void print(Blob &blue, GattCharacteristic &chr, const char *name) |
hux | 11:80f2c19ecbce | 18 | { |
hux | 11:80f2c19ecbce | 19 | Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 11:80f2c19ecbce | 20 | |
hux | 11:80f2c19ecbce | 21 | Buffer data; uint8_t *p = data; |
hux | 11:80f2c19ecbce | 22 | blue.get(chr,data); |
hux | 11:80f2c19ecbce | 23 | |
hux | 11:80f2c19ecbce | 24 | 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 | 11:80f2c19ecbce | 25 | 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 | 11:80f2c19ecbce | 26 | } |
hux | 11:80f2c19ecbce | 27 | |
hux | 11:80f2c19ecbce | 28 | #endif // _SET_H_ |