Hugo Pristauz / Mbed 2 deprecated S16_Blue_ToF

Dependencies:   BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers print.h Source File

print.h

00001 // print.h - print value of a characteristic
00002 //
00003 // Synopsis:
00004 //
00005 //    See also: CHARACTERISTIC, GET, SET
00006 //
00007 #ifndef _PRINT_H_
00008 #define _PRINT_H_
00009 
00010 #include <stdio.h>
00011 #include "ble/Gap.h"
00012 #include "bricks/o.h"
00013 #include "bricks/types.h"
00014 #include "bricks/characteristic.h"
00015 
00016 //==============================================================================
00017 // Some Callbacks
00018 //==============================================================================
00019 
00020    inline void print(O&o, Characteristic<Buffer> &chr, const char *name)
00021    {
00022       //Serial out(USBTX, USBRX);           // serial port to PC terminal
00023        
00024       Buffer data;  uint8_t *p = data;
00025       get(o,chr,data);
00026 
00027       printf("%s: %02x-%02x-%02x-%02x-%02x-",name,(int)(p[0]),(int)(p[1]),(int)(p[2]),(int)(p[3]),(int)(p[4]));
00028       printf("%02x-%02x-%02x-%02x-%02x\r\n",(int)(p[5]),(int)(p[6]),(int)(p[7]),(int)(p[8]),(int)(p[9]));
00029    }    
00030 
00031    inline void print(O&o, Characteristic<Bool> &chr, const char *name)
00032    {
00033       //Serial out(USBTX, USBRX);           // serial port to PC terminal
00034       Bool data;
00035 
00036       get(o,chr,data);
00037       printf("%s: %02x\r\n",name,data);
00038    }    
00039 
00040 // we provide also some PRINT methods for non Characteristics. If the value of
00041 // a characteristic needs to be printed the value must be fetched before with
00042 // the GET function.
00043 
00044    inline void print(O&o, Bool data, const char *name)
00045    {
00046       printf("%s: %02x\r\n",name,(int)data);
00047    }    
00048 
00049 #endif // _PRINT_H_