@@ -41,6 +41,10 @@ extern BLEDeviceInstanceBase *createBLEDeviceInstance(void);
41
41
class BLEDevice
42
42
{
43
43
public:
44
+ /* *
45
+ * Initialize the BLE controller. This should be called before using
46
+ * anything else in the BLE_API.
47
+ */
44
48
ble_error_t init ();
45
49
ble_error_t reset (void );
46
50
@@ -116,29 +120,102 @@ class BLEDevice
116
120
*/
117
121
void setAdvertisingParams (const GapAdvertisingParams &advParams);
118
122
123
+ /* *
124
+ * Reset any advertising payload prepared from prior calls to
125
+ * accumulateAdvertisingPayload().
126
+ */
119
127
void clearAdvertisingPayload (void );
128
+
129
+ /* *
130
+ * Accumulate an AD structure in the advertising payload. Please note that
131
+ * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
132
+ * as an additional 31 bytes if the advertising payload proves to be too
133
+ * small.
134
+ *
135
+ * @param flags
136
+ * The flag to be added.
137
+ */
120
138
ble_error_t accumulateAdvertisingPayload (GapAdvertisingData::Flags flags);
139
+
140
+ /* *
141
+ * Accumulate an AD structure in the advertising payload. Please note that
142
+ * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
143
+ * as an additional 31 bytes if the advertising payload proves to be too
144
+ * small.
145
+ *
146
+ * @param app
147
+ * The appearance of the peripheral.
148
+ */
121
149
ble_error_t accumulateAdvertisingPayload (GapAdvertisingData::Appearance app);
150
+
151
+ /* *
152
+ * Accumulate an AD structure in the advertising payload. Please note that
153
+ * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
154
+ * as an additional 31 bytes if the advertising payload proves to be too
155
+ * small.
156
+ *
157
+ * @param app
158
+ * The max transmit power to be used by the controller. This is
159
+ * only a hint.
160
+ */
122
161
ble_error_t accumulateAdvertisingPayloadTxPower (int8_t power);
162
+
163
+ /* *
164
+ * @param app
165
+ * The appearance of the peripheral.
166
+ */
167
+ /* *
168
+ * Accumulate a variable length byte-stream as an AD structure in the
169
+ * advertising payload. Please note that the payload is limited to 31 bytes.
170
+ * The SCAN_RESPONSE message may be used as an additional 31 bytes if the
171
+ * advertising payload proves to be too small.
172
+ *
173
+ * @param type The type which describes the variable length data.
174
+ * @param data data bytes.
175
+ * @param len length of data.
176
+ */
123
177
ble_error_t accumulateAdvertisingPayload (GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len);
124
178
179
+ /* *
180
+ * Start advertising (GAP Discoverable, Connectable modes, Broadcast
181
+ * Procedure).
182
+ */
125
183
ble_error_t startAdvertising (void );
184
+
185
+ /* *
186
+ * Stop advertising (GAP Discoverable, Connectable modes, Broadcast
187
+ * Procedure).
188
+ */
126
189
ble_error_t stopAdvertising (void );
127
190
128
191
ble_error_t disconnect (void );
129
192
130
193
/* APIs to set GAP callbacks. */
131
194
void onTimeout (Gap::EventCallback_t timeoutCallback);
132
195
void onConnection (Gap::EventCallback_t connectionCallback);
196
+ /* *
197
+ * Used to setup a callback for GAP disconnection.
198
+ */
133
199
void onDisconnection (Gap::EventCallback_t disconnectionCallback);
134
200
135
- /* APIs to set GATT server callbacks */
201
+ /* *
202
+ * Setup a callback for the GATT event DATA_SENT.
203
+ */
136
204
void onDataSent (GattServer::EventCallback_t callback);
205
+
206
+ /* *
207
+ * Setup a callback for when a characteristic has its value updated by a
208
+ * client.
209
+ */
137
210
void onDataWritten (GattServer::EventCallback_t callback);
138
211
void onUpdatesEnabled (GattServer::EventCallback_t callback);
139
212
void onUpdatesDisabled (GattServer::EventCallback_t callback);
140
213
void onConfirmationReceived (GattServer::EventCallback_t callback);
141
214
215
+ /* *
216
+ * Add a service declaration to the local server ATT table. Also add the
217
+ * characteristics contained within.
218
+ */
142
219
ble_error_t addService (GattService &service);
143
220
144
221
Gap::GapState_t getGapState (void ) const ;
@@ -177,8 +254,7 @@ class BLEDevice
177
254
178
255
/* Accumulation of AD structures in the advertisement payload should
179
256
* eventually result in a call to the target's setAdvertisingData() before
180
- * the server begins advertising. This flag marks the status of the pending
181
- * update.*/
257
+ * the server begins advertising. This flag marks the status of the pending update.*/
182
258
bool needToUpdateAdvData;
183
259
184
260
/* *
0 commit comments