Dawn Framework 1.0
Universal data acquisition framework for embedded systems
iprph.hxx
1// dawn/include/dawn/proto/nimble/iprph.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <vector>
9
10#include "dawn/io/common.hxx"
11#include "dawn/porting/config.hxx"
12#include "dawn/proto/nimble/adv.hxx"
13
14namespace dawn
15{
24{
25public:
32 constexpr static uint32_t UUID_AIOS[4] = {0x18150010, 0x7474754e, 0x694e2058, 0x454c426d};
33
36 constexpr static uint16_t UUID16_AIOS = 0x1815;
37
44 constexpr static uint32_t UUID_INPUT_TRIGGER_SET[4] = {0x2a570010,
45 0x7474754e,
46 0x694e2058,
47 0x454c426d};
48
55 constexpr static uint32_t UUID_OUTPUT_TRIGGER_SET[4] = {0x2a5c0010,
56 0x7474754e,
57 0x694e2058,
58 0x454c426d};
59
66 constexpr static uint32_t UUID_TIME_TRIGGER_SET[4] = {0x2a3f0010,
67 0x7474754e,
68 0x694e2058,
69 0x454c426d};
70
78 constexpr static uint32_t UUID_ESS[4] = {0x181a0010, 0x7474754e, 0x694e2058, 0x454c426d};
81 constexpr static uint16_t UUID16_ESS = 0x181a;
82
89 constexpr static uint32_t UUID_IMDS[4] = {0x185a0010, 0x7474754e, 0x694e2058, 0x454c426d};
90
93 constexpr static uint16_t UUID16_IMDS = 0x185a;
94
101 constexpr static uint32_t UUID_BSS[4] = {0x183b0010, 0x7474754e, 0x694e2058, 0x454c426d};
102
105 constexpr static uint16_t UUID16_BSS = 0x183b;
106
113 constexpr static uint32_t UUID_DIGITAL[4] = {0x2a560010, 0x7474754e, 0x694e2058, 0x454c426d};
114
117 constexpr static uint16_t UUID16_DIGITAL = 0x2a56;
118
125 constexpr static uint32_t UUID_ANALOG[4] = {0x2a580010, 0x7474754e, 0x694e2058, 0x454c426d};
126
129 constexpr static uint16_t UUID16_ANALOG = 0x2a58;
130
137 constexpr static uint32_t UUID_AGGREGATE[4] = {0x2a5a0010, 0x7474754e, 0x694e2058, 0x454c426d};
138
141 constexpr static uint16_t UUID16_AGGREGATE = 0x2a5a;
142
149 constexpr static uint32_t UUID_TEMP[4] = {0x2a6e0010, 0x7474754e, 0x694e2058, 0x454c426d};
150
153 constexpr static uint16_t UUID16_TEMP = 0x2a6e;
154
162 constexpr static uint32_t UUID_ACCEL[4] = {0x2c060010, 0x7474754e, 0x694e2058, 0x454c426d};
163
166 constexpr static uint16_t UUID16_ACCEL = 0x2c06;
167
174 constexpr static uint32_t UUID_HUM[4] = {0x2a6f0010, 0x7474754e, 0x694e2058, 0x454c426d};
175
178 constexpr static uint16_t UUID16_HUM = 0x2a6f;
179
186 constexpr static uint32_t UUID_PRESS[4] = {0x2a6d0010, 0x7474754e, 0x694e2058, 0x454c426d};
189 constexpr static uint16_t UUID16_PRESS = 0x2a6d;
190
197 constexpr static uint32_t UUID_UVIDX[4] = {0x2a760010, 0x7474754e, 0x694e2058, 0x454c426d};
198
201 constexpr static uint16_t UUID16_UVIDX = 0x2a76;
202
209 constexpr static uint32_t UUID_TWINDSPEED[4] = {0x2a700010, 0x7474754e, 0x694e2058, 0x454c426d};
210
213 constexpr static uint16_t UUID16_TWINDSPEED = 0x2a70;
214
221 constexpr static uint32_t UUID_TWINDDIR[4] = {0x2a710010, 0x7474754e, 0x694e2058, 0x454c426d};
222
225 constexpr static uint16_t UUID16_TWINDDIR = 0x2a71;
226
233 constexpr static uint32_t UUID_VOLTAGE[4] = {0x2b180010, 0x7474754e, 0x694e2058, 0x454c426d};
234
237 constexpr static uint16_t UUID16_VOLTAGE = 0x2b18;
238
245 constexpr static uint32_t UUID_VOLTAGEFREQ[4] = {0x2be80010, 0x7474754e, 0x694e2058, 0x454c426d};
246
249 constexpr static uint16_t UUID16_VOLTAGEFREQ = 0x2be8;
250
257 constexpr static uint32_t UUID_VOLTAGESPEC[4] = {0x2b190010, 0x7474754e, 0x694e2058, 0x454c426d};
258
261 constexpr static uint16_t UUID16_VOLTAGESPEC = 0x2b19;
262
269 constexpr static uint32_t UUID_VOLTAGESTAT[4] = {0x2b1a0010, 0x7474754e, 0x694e2058, 0x454c426d};
270
273 constexpr static uint16_t UUID16_VOLTAGESTAT = 0x2b1a;
274
281 constexpr static uint32_t UUID_CURRENT[4] = {0x2aee0010, 0x7474754e, 0x694e2058, 0x454c426d};
282
285 constexpr static uint16_t UUID16_CURRENT = 0x2aee;
286
293 constexpr static uint32_t UUID_CURRENTRANGE[4] = {0x2aef0010, 0x7474754e, 0x694e2058, 0x454c426d};
296 constexpr static uint16_t UUID16_CURRENTRANGE = 0x2aef;
297
304 constexpr static uint32_t UUID_CURRENTSPEC[4] = {0x2af00010, 0x7474754e, 0x694e2058, 0x454c426d};
305
308 constexpr static uint16_t UUID16_CURRENTSPEC = 0x2af0;
309
316 constexpr static uint32_t UUID_CURRENTSTATS[4] = {0x2af10010, 0x7474754e, 0x694e2058, 0x454c426d};
317
320 constexpr static uint16_t UUID16_CURRENTSTATS = 0x2af1;
321
328 constexpr static uint32_t UUID_ILLUMINANCE[4] = {0x2afb0010, 0x7474754e, 0x694e2058, 0x454c426d};
329
332 constexpr static uint16_t UUID16_ILLUMINANCE = 0x2afb;
333
342 constexpr static uint32_t UUID_RESISTANCE[4] = {0x272a0010, 0x7474754e, 0x694e2058, 0x454c426d};
343
346 constexpr static uint16_t UUID16_RESISTANCE = 0x272a;
347
354 constexpr static std::pair<uint16_t, float> charScale[] = {
355 {UUID16_TEMP, 100.0f},
357 {UUID16_HUM, 100.0f},
359 {UUID16_PRESS, 100.0f},
361 {UUID16_RESISTANCE, 1.0f},
363 {UUID16_UVIDX, 1.0f},
365 {UUID16_ILLUMINANCE, 100.0f},
367 };
368
371 constexpr static size_t charScaleSize =
373
383 static float charScaleGet(uint16_t u)
384 {
385 for (size_t i = 0; i < IProtoNimblePrphCb::charScaleSize; ++i)
386 {
387 if (IProtoNimblePrphCb::charScale[i].first == u)
388 {
389 return IProtoNimblePrphCb::charScale[i].second;
390 }
391 }
392
393 return 0.0f;
394 }
395
406 virtual int serviceRegister(struct ble_gatt_svc_def *svc) = 0;
407
417 virtual int startService(int id) = 0;
418
428 virtual int stopService(int id) = 0;
429
438 virtual void regObject(SObjectId::ObjectId id) = 0;
439
450
457 virtual size_t getObjectsLen() = 0;
458};
459
467{
468public:
475 struct
476 {
477 CIOCommon *io;
479 uint16_t handle;
483 } typedef SPrphNotiferCb;
484
495 {
496 DAWNASSERT(desc_ != nullptr, "NULL pointer");
497 DAWNASSERT(cb_ != nullptr, "NULL pointer");
498
499 this->desc = desc_;
500 this->cb = cb_;
501 };
502
510
519 virtual int init() = 0;
520
529 virtual int deinit() = 0;
530
539 virtual int start() = 0;
540
549 virtual int stop() = 0;
550
557 std::vector<SObjectId::ObjectId> vio;
558
567
575};
576} // Namespace dawn
Base class for all I/O objects.
Definition common.hxx:27
Interface for BLE peripheral services with GATT characteristics.
Definition iprph.hxx:24
static uint16_t UUID16_UVIDX
16-bit UUID for UV Index characteristic.
Definition iprph.hxx:201
virtual int startService(int id)=0
Start a specific service.
static uint16_t UUID16_VOLTAGESTAT
16-bit UUID for Voltage Statistics characteristic.
Definition iprph.hxx:273
static uint32_t UUID_UVIDX[4]
UV Index Characteristic UUID (0x2A76).
Definition iprph.hxx:197
static uint32_t UUID_CURRENTSPEC[4]
Electric Current Specification Characteristic UUID (0x2AF0).
Definition iprph.hxx:304
static uint32_t UUID_TWINDDIR[4]
True Wind Direction Characteristic UUID (0x2A71).
Definition iprph.hxx:221
static uint32_t UUID_VOLTAGE[4]
Voltage Characteristic UUID (0x2B18).
Definition iprph.hxx:233
static uint32_t UUID_ESS[4]
Environmental Sensing Service UUID (0x181A).
Definition iprph.hxx:78
static uint16_t UUID16_AGGREGATE
16-bit UUID for Aggregate characteristic.
Definition iprph.hxx:141
static uint32_t UUID_BSS[4]
Binary Sensor Service UUID (0x183B).
Definition iprph.hxx:101
static uint16_t UUID16_VOLTAGE
16-bit UUID for Voltage characteristic.
Definition iprph.hxx:237
static uint32_t UUID_CURRENTSTATS[4]
Electric Current Statistics Characteristic UUID (0x2AF1).
Definition iprph.hxx:316
virtual size_t getObjectsLen()=0
Get count of registered I/O objects.
static float charScaleGet(uint16_t u)
Get scaling factor for a characteristic UUID.
Definition iprph.hxx:383
static size_t charScaleSize
Number of characteristic scaling entries.
Definition iprph.hxx:371
static uint32_t UUID_INPUT_TRIGGER_SET[4]
AIOS Input Trigger Set characteristic (0x2A57).
Definition iprph.hxx:44
static uint32_t UUID_ACCEL[4]
Acceleration Characteristic UUID (0x2C06).
Definition iprph.hxx:162
static uint32_t UUID_CURRENTRANGE[4]
Electric Current Range Characteristic UUID (0x2AEF).
Definition iprph.hxx:293
static uint16_t UUID16_HUM
16-bit UUID for Humidity characteristic.
Definition iprph.hxx:178
static uint32_t UUID_ANALOG[4]
Analog Characteristic UUID (0x2A58).
Definition iprph.hxx:125
static uint16_t UUID16_CURRENTRANGE
16-bit UUID for Electric Current Range characteristic.
Definition iprph.hxx:296
static uint32_t UUID_OUTPUT_TRIGGER_SET[4]
AIOS Output Trigger Set characteristic (0x2A5C).
Definition iprph.hxx:55
static uint16_t UUID16_TWINDSPEED
16-bit UUID for True Wind Speed characteristic.
Definition iprph.hxx:213
static uint16_t UUID16_IMDS
16-bit Bluetooth SIG UUID for IMDS.
Definition iprph.hxx:93
virtual CIOCommon * getObject(SObjectId::ObjectId id)=0
Get protocol object by ID.
static uint16_t UUID16_ANALOG
16-bit UUID for Analog characteristic.
Definition iprph.hxx:129
static uint32_t UUID_PRESS[4]
Pressure Characteristic UUID (0x2A6D).
Definition iprph.hxx:186
static uint16_t UUID16_CURRENT
16-bit UUID for Electric Current characteristic.
Definition iprph.hxx:285
static uint32_t UUID_CURRENT[4]
Electric Current Characteristic UUID (0x2AEE).
Definition iprph.hxx:281
static uint32_t UUID_VOLTAGESTAT[4]
Voltage Statistics Characteristic UUID (0x2B1A).
Definition iprph.hxx:269
static std::pair< uint16_t, float > charScale[]
Scaling factors for GATT characteristics.
Definition iprph.hxx:354
static uint16_t UUID16_BSS
16-bit Bluetooth SIG UUID for BSS.
Definition iprph.hxx:105
static uint32_t UUID_TEMP[4]
Temperature Characteristic UUID (0x2A6E).
Definition iprph.hxx:149
static uint32_t UUID_DIGITAL[4]
Digital Characteristic UUID (0x2A56).
Definition iprph.hxx:113
static uint32_t UUID_TWINDSPEED[4]
True Wind Speed Characteristic UUID (0x2A70).
Definition iprph.hxx:209
static uint32_t UUID_VOLTAGEFREQ[4]
Voltage Frequency Characteristic UUID (0x2BE8).
Definition iprph.hxx:245
static uint32_t UUID_ILLUMINANCE[4]
Illuminance Characteristic UUID (0x2AFB).
Definition iprph.hxx:328
static uint16_t UUID16_TEMP
16-bit UUID for Temperature characteristic.
Definition iprph.hxx:153
static uint32_t UUID_AGGREGATE[4]
Aggregate Characteristic UUID (0x2A5A).
Definition iprph.hxx:137
static uint16_t UUID16_ILLUMINANCE
16-bit UUID for Illuminance characteristic.
Definition iprph.hxx:332
static uint32_t UUID_RESISTANCE[4]
Electric Resistance Characteristic UUID (0x272A).
Definition iprph.hxx:342
virtual int serviceRegister(struct ble_gatt_svc_def *svc)=0
Register a GATT service with the peripheral.
static uint16_t UUID16_RESISTANCE
16-bit UUID for Electric Resistance characteristic.
Definition iprph.hxx:346
static uint16_t UUID16_DIGITAL
16-bit UUID for Digital characteristic.
Definition iprph.hxx:117
static uint16_t UUID16_ACCEL
16-bit UUID for Acceleration characteristic.
Definition iprph.hxx:166
virtual void regObject(SObjectId::ObjectId id)=0
Register an I/O object for this service.
static uint32_t UUID_VOLTAGESPEC[4]
Voltage Specification Characteristic UUID (0x2B19).
Definition iprph.hxx:257
static uint32_t UUID_IMDS[4]
Industrial Measurement Device Service UUID (0x185A).
Definition iprph.hxx:89
static uint16_t UUID16_CURRENTSTATS
16-bit UUID for Electric Current Statistics characteristic.
Definition iprph.hxx:320
static uint16_t UUID16_ESS
16-bit Bluetooth SIG UUID for ESS.
Definition iprph.hxx:81
static uint16_t UUID16_CURRENTSPEC
16-bit UUID for Electric Current Specification characteristic.
Definition iprph.hxx:308
static uint32_t UUID_TIME_TRIGGER_SET[4]
AIOS Time Trigger Set characteristic (0x2A3F).
Definition iprph.hxx:66
static uint32_t UUID_HUM[4]
Humidity Characteristic UUID (0x2A6F).
Definition iprph.hxx:174
static uint16_t UUID16_VOLTAGESPEC
16-bit UUID for Voltage Specification characteristic.
Definition iprph.hxx:261
virtual int stopService(int id)=0
Stop a specific service.
static uint16_t UUID16_TWINDDIR
16-bit UUID for True Wind Direction characteristic.
Definition iprph.hxx:225
static uint16_t UUID16_VOLTAGEFREQ
16-bit UUID for Voltage Frequency characteristic.
Definition iprph.hxx:249
static uint16_t UUID16_AIOS
16-bit Bluetooth SIG UUID for AIOS.
Definition iprph.hxx:36
static uint32_t UUID_AIOS[4]
Automation I/O Service UUID (0x1815).
Definition iprph.hxx:32
static uint16_t UUID16_PRESS
16-bit UUID for Pressure characteristic.
Definition iprph.hxx:189
Base interface for GATT services exposed by BLE peripheral.
Definition iprph.hxx:467
virtual int deinit()=0
Deinitialize service.
std::vector< SObjectId::ObjectId > vio
Vector of I/O objects exposed by this service.
Definition iprph.hxx:557
const SObjectCfg::SObjectCfgItem * desc
Configuration descriptor for this service.
Definition iprph.hxx:574
virtual int start()=0
Start service.
virtual int init()=0
Initialize service.
IProtoNimblePrphCb * cb
Callback interface to peripheral.
Definition iprph.hxx:566
virtual ~IProtoNimblePrphService()
Virtual destructor.
Definition iprph.hxx:509
IProtoNimblePrphService(const SObjectCfg::SObjectCfgItem *desc_, IProtoNimblePrphCb *cb_)
Constructor.
Definition iprph.hxx:494
virtual int stop()=0
Stop service.
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Context data for characteristic notification callbacks.
Definition iprph.hxx:476
io_ddata_t * data
GATT attribute handle for notification.
Definition iprph.hxx:481
uint16_t handle
Pointer to I/O object being monitored.
Definition iprph.hxx:479
Single configuration item within object.
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21