@@ -30,11 +30,11 @@ ssize_t profile_write_process(struct bt_conn *conn,
30
30
const void *buf, uint16_t len,
31
31
uint16_t offset)
32
32
{
33
- pr_info (LOG_MODULE_BLE, " %s1" , __FUNCTION__);
33
+ pr_info (LOG_MODULE_BLE, " %s1" , __FUNCTION__);
34
34
BLEAttribute *bleattr = (BLEAttribute *)attr->user_data ;
35
35
BLECharacteristic* blecharacteritic;
36
36
BLEAttributeType type = bleattr->type ();
37
- BLECentralHelper central = BLEPeripheralRole::instance ()->central ();
37
+ BLECentralHelper central = BLEPeripheralRole::instance ()->central ();
38
38
if ((BLETypeCharacteristic != type) || 0 != offset)
39
39
{
40
40
return 0 ;
@@ -64,8 +64,8 @@ uint8_t profile_notify_process (struct bt_conn *conn,
64
64
65
65
// Only for central
66
66
uint8_t profile_discover_process (struct bt_conn *conn,
67
- const struct bt_gatt_attr *attr,
68
- struct bt_gatt_discover_params *params)
67
+ const struct bt_gatt_attr *attr,
68
+ struct bt_gatt_discover_params *params)
69
69
{
70
70
BLEPeripheralHelper* peripheral = BLECentralRole::instance ()->peripheral (conn);// Find peripheral by bt_conn
71
71
peripheral->discover (attr);
@@ -84,7 +84,7 @@ uint8_t profile_read_rsp_process(struct bt_conn *conn, int err,
84
84
}
85
85
BLEPeripheralHelper* peripheral = BLECentralRole::instance ()->peripheral (conn);// Find peripheral by bt_conn
86
86
BLEAttribute* readatt = peripheral->attribute (params->single .handle );
87
- BLECharacteristic *chrc = (BLECharacteristic *)readatt;
87
+ BLECharacteristic *chrc = (BLECharacteristic *)readatt;
88
88
89
89
// assert(readatt->type() == BLETypeCharacteristic);
90
90
chrc->setValue (*((BLEHelper *)peripheral), (const unsigned char *)data, length);
@@ -208,16 +208,16 @@ int BLEProfile::registerProfile()
208
208
int ret = 0 ;
209
209
210
210
// Start debug
211
- int i;
211
+ int i;
212
212
213
- for (i = 0 ; i < _attr_index; i++) {
214
- {
215
- pr_info (LOG_MODULE_APP, " gatt-: i %d, type %d, u16 0x%x" ,
216
- i,
217
- _attr_base[i].uuid ->type ,
218
- BT_UUID_16 (_attr_base[i].uuid )->val );
219
- }
220
- }
213
+ for (i = 0 ; i < _attr_index; i++) {
214
+ {
215
+ pr_info (LOG_MODULE_APP, " gatt-: i %d, type %d, u16 0x%x" ,
216
+ i,
217
+ _attr_base[i].uuid ->type ,
218
+ BT_UUID_16 (_attr_base[i].uuid )->val );
219
+ }
220
+ }
221
221
222
222
delay (1000 );
223
223
// End for debug
@@ -242,55 +242,55 @@ void BLEProfile::discover(const struct bt_gatt_attr *attr)
242
242
if (attribute->discovering ())
243
243
{
244
244
if (NULL != attr)
245
- {
246
- // Discover success
247
- switch (_discover_params.type )
248
- {
249
- case BT_GATT_DISCOVER_CHARACTERISTIC:
250
- {
251
- struct bt_gatt_attr *attr_dec = declarationAttr (attribute);
252
- attr_dec++;
253
- attr_dec->handle = attr->handle + 1 ;
254
- break ;
255
- }
256
- case BT_GATT_DISCOVER_DESCRIPTOR:
257
- {
258
- BLECharacteristic *chrc = (BLECharacteristic *)attribute;
259
- struct bt_gatt_attr *attr_dec = declarationAttr (attribute);
260
- struct bt_gatt_attr *attr_chrc = attr_dec + 1 ;
261
- struct bt_gatt_attr *attr_cccd = attr_dec + 2 ;
262
- struct bt_gatt_subscribe_params *sub_param_tmp = chrc->getSubscribeParams ();
263
- struct bt_gatt_subscribe_params *sub_param = _sub_param + _sub_param_idx;
264
- struct bt_conn *conn = bt_conn_lookup_addr_le (_peripheral->bt_le_address ());
265
- if (NULL == conn)
266
- {
267
- // Link lost
268
- return ;
269
- }
270
-
271
- _sub_param_idx++;
272
- attr_cccd->handle = attr->handle ;
273
- memcpy (sub_param, sub_param_tmp, sizeof (struct bt_gatt_subscribe_params ));
274
- sub_param->ccc_handle = attr_cccd->handle ;
275
- sub_param->value_handle = attr_chrc->handle ;
276
-
277
- // Enable CCCD to allow peripheral send Notification/Indication
278
- err = bt_gatt_subscribe (conn, sub_param);
279
- bt_conn_unref (conn);
280
- if (err && err != -EALREADY)
281
- {
282
- pr_debug (LOG_MODULE_APP, " Subscribe failed (err %d)\n " , err);
283
- }
284
- break ;
285
- }
286
- case BT_GATT_DISCOVER_PRIMARY:
287
- default :
288
- {
289
- // Do nothing
290
- break ;
291
- }
292
- }
293
- }
245
+ {
246
+ // Discover success
247
+ switch (_discover_params.type )
248
+ {
249
+ case BT_GATT_DISCOVER_CHARACTERISTIC:
250
+ {
251
+ struct bt_gatt_attr *attr_dec = declarationAttr (attribute);
252
+ attr_dec++;
253
+ attr_dec->handle = attr->handle + 1 ;
254
+ break ;
255
+ }
256
+ case BT_GATT_DISCOVER_DESCRIPTOR:
257
+ {
258
+ BLECharacteristic *chrc = (BLECharacteristic *)attribute;
259
+ struct bt_gatt_attr *attr_dec = declarationAttr (attribute);
260
+ struct bt_gatt_attr *attr_chrc = attr_dec + 1 ;
261
+ struct bt_gatt_attr *attr_cccd = attr_dec + 2 ;
262
+ struct bt_gatt_subscribe_params *sub_param_tmp = chrc->getSubscribeParams ();
263
+ struct bt_gatt_subscribe_params *sub_param = _sub_param + _sub_param_idx;
264
+ struct bt_conn *conn = bt_conn_lookup_addr_le (_peripheral->bt_le_address ());
265
+ if (NULL == conn)
266
+ {
267
+ // Link lost
268
+ return ;
269
+ }
270
+
271
+ _sub_param_idx++;
272
+ attr_cccd->handle = attr->handle ;
273
+ memcpy (sub_param, sub_param_tmp, sizeof (struct bt_gatt_subscribe_params ));
274
+ sub_param->ccc_handle = attr_cccd->handle ;
275
+ sub_param->value_handle = attr_chrc->handle ;
276
+
277
+ // Enable CCCD to allow peripheral send Notification/Indication
278
+ err = bt_gatt_subscribe (conn, sub_param);
279
+ bt_conn_unref (conn);
280
+ if (err && err != -EALREADY)
281
+ {
282
+ pr_debug (LOG_MODULE_APP, " Subscribe failed (err %d)\n " , err);
283
+ }
284
+ break ;
285
+ }
286
+ case BT_GATT_DISCOVER_PRIMARY:
287
+ default :
288
+ {
289
+ // Do nothing
290
+ break ;
291
+ }
292
+ }
293
+ }
294
294
attribute->discover (attr, &_discover_params);
295
295
break ;
296
296
}
@@ -321,16 +321,16 @@ void BLEProfile::discover(const struct bt_gatt_attr *attr)
321
321
if (NULL == conn)
322
322
{
323
323
// Link lost
324
- pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
324
+ pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
325
325
return ;
326
326
}
327
327
err = bt_gatt_discover (conn, &_discover_params);
328
328
bt_conn_unref (conn);
329
- if (err)
329
+ if (err)
330
330
{
331
- pr_debug (LOG_MODULE_APP, " Discover failed(err %d)\n " , err);
332
- return ;
333
- }
331
+ pr_debug (LOG_MODULE_APP, " Discover failed(err %d)\n " , err);
332
+ return ;
333
+ }
334
334
}
335
335
}
336
336
@@ -344,7 +344,7 @@ void BLEProfile::discover()
344
344
if (NULL == conn)
345
345
{
346
346
// Link lost
347
- pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
347
+ pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
348
348
return ;
349
349
}
350
350
@@ -354,11 +354,11 @@ void BLEProfile::discover()
354
354
355
355
err = bt_gatt_discover (conn, &_discover_params);
356
356
bt_conn_unref (conn);
357
- if (err)
357
+ if (err)
358
358
{
359
- pr_debug (LOG_MODULE_APP, " Discover failed(err %d)\n " , err);
360
- return ;
361
- }
359
+ pr_debug (LOG_MODULE_APP, " Discover failed(err %d)\n " , err);
360
+ return ;
361
+ }
362
362
}
363
363
364
364
BLEAttribute *BLEProfile::attribute (struct bt_gatt_subscribe_params *params)
@@ -390,7 +390,7 @@ BLEAttribute *BLEProfile::attribute(const struct bt_uuid* uuid)
390
390
391
391
if (false == att_found)
392
392
{
393
- pr_debug (LOG_MODULE_APP, " Attributes not found" );
393
+ pr_debug (LOG_MODULE_APP, " Attributes not found" );
394
394
// Didn't found the characteristic
395
395
chrc_tmp = NULL ;
396
396
}
0 commit comments