Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers service_macros.h Source File

service_macros.h

00001 /*
00002  * Made by Dominik @ aconno
00003  * All rights reserved
00004  *
00005  */
00006 
00007 #ifndef __SERVICE_MACROS_H__
00008 #define __SERVICE_MACROS_H__
00009 
00010 
00011 #define _SERVICE_INIT_T(serv_name)          Init##serv_name
00012 #define SERVICE_INIT_T(serv_name)           _SERVICE_INIT_T(serv_name)
00013 
00014 
00015 #define CHARACTERISTIC_W(charType, type, var, func)                            \
00016                                                                                \
00017 public:                                                                        \
00018                                                                                \
00019 inline GattAttribute::Handle_t get##func##Handle(){                            \
00020     return var.getValueHandle();                                               \
00021 }                                                                              \
00022                                                                                \
00023 inline void set##func(const type &new_state){                                  \
00024     ble.gattServer().write(var.getValueHandle(),                               \
00025                            (uint8_t*)&new_state,                               \
00026                            sizeof(type));                                      \
00027 }                                                                              \
00028                                                                                \
00029 inline void set##func(type *new_state){                                        \
00030     ble.gattServer().write(var.getValueHandle(),                               \
00031                            (uint8_t*)new_state,                                \
00032                            sizeof(type));                                      \
00033 }                                                                              \
00034                                                                                \
00035 inline type get##func(){                                                       \
00036     type tmp;                                                                  \
00037     uint16_t size = sizeof(tmp);                                               \
00038     ble.gattServer().read(var.getValueHandle(), (uint8_t*)&tmp,                \
00039                                                           &size);              \
00040     return tmp;                                                                \
00041 }                                                                              \
00042                                                                                \
00043 inline type *get##func(type &tmp){                                             \
00044     uint16_t size = sizeof(type);                                              \
00045     ble.gattServer().read(var.getValueHandle(), (uint8_t*)&tmp,                \
00046                                                           &size);              \
00047     return &tmp;                                                               \
00048 }                                                                              \
00049                                                                                \
00050 inline type *get##func(type *tmp){                                             \
00051     uint16_t size = sizeof(type);                                              \
00052     ble.gattServer().read(var.getValueHandle(), (uint8_t*)tmp,                 \
00053                                                           &size);              \
00054     return tmp;                                                                \
00055 }                                                                              \
00056                                                                                \
00057 private:                                                                       \
00058 charType##GattCharacteristic<type> var
00059 
00060 
00061 #define CHARACTERISTIC_A(charType, type, size_, var, func)                     \
00062                                                                                \
00063 public:                                                                        \
00064                                                                                \
00065 inline GattAttribute::Handle_t get##func##Handle(){                            \
00066     return var.getValueHandle();                                               \
00067 }                                                                              \
00068                                                                                \
00069 inline void set##func(type *new_state){                                        \
00070     ble.gattServer().write(var.getValueHandle(),                               \
00071                            (uint8_t*)new_state,                                \
00072                            sizeof(type)*size_);                                \
00073 }                                                                              \
00074                                                                                \
00075 inline type *get##func(type *tmp){                                             \
00076     uint16_t size = sizeof(type)*size_;                                        \
00077     ble.gattServer().read(var.getValueHandle(), (uint8_t*)tmp,                 \
00078                                                           &size);              \
00079     return tmp;                                                                \
00080 }                                                                              \
00081                                                                                \
00082 private:                                                                       \
00083 charType##ArrayGattCharacteristic<type, size_> var
00084 
00085 #endif //__SERVICE_MACROS_H__