![](/media/cache/profiles/b5c4ec91390a6fbccf8d918d443563ed.jpg.50x50_q85.jpg)
aconno acnsensa project for iOS devices with iBeacon packets support.
Dependencies: LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common
service_macros.h@38:c90e1670ffb3, 2018-08-17 (annotated)
- Committer:
- dbartolovic
- Date:
- Fri Aug 17 10:45:24 2018 +0000
- Branch:
- sensaformatfix
- Revision:
- 38:c90e1670ffb3
- Parent:
- 36:9e40cdef6bd6
Added service advertisement to telemetry data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dbartolovic | 36:9e40cdef6bd6 | 1 | /* |
dbartolovic | 36:9e40cdef6bd6 | 2 | * Made by Dominik @ aconno |
dbartolovic | 36:9e40cdef6bd6 | 3 | * All rights reserved |
dbartolovic | 36:9e40cdef6bd6 | 4 | * |
dbartolovic | 36:9e40cdef6bd6 | 5 | */ |
dbartolovic | 36:9e40cdef6bd6 | 6 | |
dbartolovic | 36:9e40cdef6bd6 | 7 | #ifndef __SERVICE_MACROS_H__ |
dbartolovic | 36:9e40cdef6bd6 | 8 | #define __SERVICE_MACROS_H__ |
dbartolovic | 36:9e40cdef6bd6 | 9 | |
dbartolovic | 36:9e40cdef6bd6 | 10 | |
dbartolovic | 36:9e40cdef6bd6 | 11 | #define _SERVICE_INIT_T(serv_name) Init##serv_name |
dbartolovic | 36:9e40cdef6bd6 | 12 | #define SERVICE_INIT_T(serv_name) _SERVICE_INIT_T(serv_name) |
dbartolovic | 36:9e40cdef6bd6 | 13 | |
dbartolovic | 36:9e40cdef6bd6 | 14 | |
dbartolovic | 36:9e40cdef6bd6 | 15 | #define CHARACTERISTIC_W(charType, type, var, func) \ |
dbartolovic | 36:9e40cdef6bd6 | 16 | \ |
dbartolovic | 36:9e40cdef6bd6 | 17 | public: \ |
dbartolovic | 36:9e40cdef6bd6 | 18 | \ |
dbartolovic | 36:9e40cdef6bd6 | 19 | inline GattAttribute::Handle_t get##func##Handle(){ \ |
dbartolovic | 36:9e40cdef6bd6 | 20 | return var.getValueHandle(); \ |
dbartolovic | 36:9e40cdef6bd6 | 21 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 22 | \ |
dbartolovic | 36:9e40cdef6bd6 | 23 | inline void set##func(const type &new_state){ \ |
dbartolovic | 36:9e40cdef6bd6 | 24 | ble.gattServer().write(var.getValueHandle(), \ |
dbartolovic | 36:9e40cdef6bd6 | 25 | (uint8_t*)&new_state, \ |
dbartolovic | 36:9e40cdef6bd6 | 26 | sizeof(type)); \ |
dbartolovic | 36:9e40cdef6bd6 | 27 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 28 | \ |
dbartolovic | 36:9e40cdef6bd6 | 29 | inline void set##func(type *new_state){ \ |
dbartolovic | 36:9e40cdef6bd6 | 30 | ble.gattServer().write(var.getValueHandle(), \ |
dbartolovic | 36:9e40cdef6bd6 | 31 | (uint8_t*)new_state, \ |
dbartolovic | 36:9e40cdef6bd6 | 32 | sizeof(type)); \ |
dbartolovic | 36:9e40cdef6bd6 | 33 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 34 | \ |
dbartolovic | 36:9e40cdef6bd6 | 35 | inline type get##func(){ \ |
dbartolovic | 36:9e40cdef6bd6 | 36 | type tmp; \ |
dbartolovic | 36:9e40cdef6bd6 | 37 | uint16_t size = sizeof(tmp); \ |
dbartolovic | 36:9e40cdef6bd6 | 38 | ble.gattServer().read(var.getValueHandle(), (uint8_t*)&tmp, \ |
dbartolovic | 36:9e40cdef6bd6 | 39 | &size); \ |
dbartolovic | 36:9e40cdef6bd6 | 40 | return tmp; \ |
dbartolovic | 36:9e40cdef6bd6 | 41 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 42 | \ |
dbartolovic | 36:9e40cdef6bd6 | 43 | inline type *get##func(type &tmp){ \ |
dbartolovic | 36:9e40cdef6bd6 | 44 | uint16_t size = sizeof(type); \ |
dbartolovic | 36:9e40cdef6bd6 | 45 | ble.gattServer().read(var.getValueHandle(), (uint8_t*)&tmp, \ |
dbartolovic | 36:9e40cdef6bd6 | 46 | &size); \ |
dbartolovic | 36:9e40cdef6bd6 | 47 | return &tmp; \ |
dbartolovic | 36:9e40cdef6bd6 | 48 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 49 | \ |
dbartolovic | 36:9e40cdef6bd6 | 50 | inline type *get##func(type *tmp){ \ |
dbartolovic | 36:9e40cdef6bd6 | 51 | uint16_t size = sizeof(type); \ |
dbartolovic | 36:9e40cdef6bd6 | 52 | ble.gattServer().read(var.getValueHandle(), (uint8_t*)tmp, \ |
dbartolovic | 36:9e40cdef6bd6 | 53 | &size); \ |
dbartolovic | 36:9e40cdef6bd6 | 54 | return tmp; \ |
dbartolovic | 36:9e40cdef6bd6 | 55 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 56 | \ |
dbartolovic | 36:9e40cdef6bd6 | 57 | private: \ |
dbartolovic | 36:9e40cdef6bd6 | 58 | charType##GattCharacteristic<type> var |
dbartolovic | 36:9e40cdef6bd6 | 59 | |
dbartolovic | 36:9e40cdef6bd6 | 60 | |
dbartolovic | 36:9e40cdef6bd6 | 61 | #define CHARACTERISTIC_A(charType, type, size_, var, func) \ |
dbartolovic | 36:9e40cdef6bd6 | 62 | \ |
dbartolovic | 36:9e40cdef6bd6 | 63 | public: \ |
dbartolovic | 36:9e40cdef6bd6 | 64 | \ |
dbartolovic | 36:9e40cdef6bd6 | 65 | inline GattAttribute::Handle_t get##func##Handle(){ \ |
dbartolovic | 36:9e40cdef6bd6 | 66 | return var.getValueHandle(); \ |
dbartolovic | 36:9e40cdef6bd6 | 67 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 68 | \ |
dbartolovic | 36:9e40cdef6bd6 | 69 | inline void set##func(type *new_state){ \ |
dbartolovic | 36:9e40cdef6bd6 | 70 | ble.gattServer().write(var.getValueHandle(), \ |
dbartolovic | 36:9e40cdef6bd6 | 71 | (uint8_t*)new_state, \ |
dbartolovic | 36:9e40cdef6bd6 | 72 | sizeof(type)*size_); \ |
dbartolovic | 36:9e40cdef6bd6 | 73 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 74 | \ |
dbartolovic | 36:9e40cdef6bd6 | 75 | inline type *get##func(type *tmp){ \ |
dbartolovic | 36:9e40cdef6bd6 | 76 | uint16_t size = sizeof(type)*size_; \ |
dbartolovic | 36:9e40cdef6bd6 | 77 | ble.gattServer().read(var.getValueHandle(), (uint8_t*)tmp, \ |
dbartolovic | 36:9e40cdef6bd6 | 78 | &size); \ |
dbartolovic | 36:9e40cdef6bd6 | 79 | return tmp; \ |
dbartolovic | 36:9e40cdef6bd6 | 80 | } \ |
dbartolovic | 36:9e40cdef6bd6 | 81 | \ |
dbartolovic | 36:9e40cdef6bd6 | 82 | private: \ |
dbartolovic | 36:9e40cdef6bd6 | 83 | charType##ArrayGattCharacteristic<type, size_> var |
dbartolovic | 36:9e40cdef6bd6 | 84 | |
dbartolovic | 36:9e40cdef6bd6 | 85 | #endif //__SERVICE_MACROS_H__ |