Dawn Framework 1.0
Universal data acquisition framework for embedded systems
prph_custom.hxx
1// dawn/include/dawn/proto/nimble/prph_custom.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <vector>
9
10#include "dawn/proto/nimble/iprph.hxx"
11#include "host/ble_gatt.h"
12
13namespace dawn
14{
22{
23public:
24 enum
25 {
26 CUSTOM_CHR_F_READ = 0x01,
27 CUSTOM_CHR_F_WRITE = 0x02,
28 CUSTOM_CHR_F_NOTIFY = 0x04,
29 };
30
31 struct
32 {
33 uint32_t flags;
34 uint32_t uuid[4];
36 } typedef SProtoNimblePrphCustomChar;
37
38 struct
39 {
40 uint32_t cfg0;
41 uint32_t cfg1;
42 uint32_t cfg2;
43 uint32_t uuid[4];
44 SProtoNimblePrphCustomChar chr[];
45 } typedef SProtoNimblePrphCustomSvc;
46
47 struct SCustomCharCb
48 {
49 CIOCommon *io;
50 uint16_t handle;
51 io_ddata_t *data;
52 };
53
54 struct SCustomChar
55 {
57 uint8_t flags;
58 uint8_t uuid[16];
59 };
60
62 ~CProtoNimblePrphCustom() override;
63
64 int init() override;
65 int deinit() override;
66 int start() override;
67 int stop() override;
68
69private:
70 int id;
71 bool created;
72 ble_gatt_svc_def svc;
73 ble_gatt_chr_def *chrs;
74 std::vector<SCustomChar> vchars;
75 std::vector<SCustomCharCb *> vcbs;
76
77#ifdef CONFIG_DAWN_IO_NOTIFY
78 static int notifierCb(void *priv, io_ddata_t *data);
79#endif
80 static int callback(uint16_t conn_handle,
81 uint16_t attr_handle,
82 struct ble_gatt_access_ctxt *ctxt,
83 void *arg);
84
85 int allocCustom();
86 int createCustom();
87 void deleteCustom();
88 void configureDesc(const SObjectCfg::SObjectCfgItem *item);
89};
90
91} // namespace dawn
Base class for all I/O objects.
Definition common.hxx:27
Custom Service defined by user.
int deinit()
Deinitialize service.
int init()
Initialize service.
int start()
Start service.
Interface for BLE peripheral services with GATT characteristics.
Definition iprph.hxx:24
Base interface for GATT services exposed by BLE peripheral.
Definition iprph.hxx:467
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
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
32-bit encoded object identifier (union with bit field).
Definition objectid.hxx:218