@@ -30,11 +30,11 @@ ssize_t profile_write_process(struct bt_conn *conn,
3030 const void *buf, uint16_t len,
3131 uint16_t offset)
3232{
33- pr_info (LOG_MODULE_BLE, " %s1" , __FUNCTION__);
33+ pr_info (LOG_MODULE_BLE, " %s1" , __FUNCTION__);
3434 BLEAttribute *bleattr = (BLEAttribute *)attr->user_data ;
3535 BLECharacteristic* blecharacteritic;
3636 BLEAttributeType type = bleattr->type ();
37- BLECentralHelper central = BLEPeripheralRole::instance ()->central ();
37+ BLECentralHelper central = BLEPeripheralRole::instance ()->central ();
3838 if ((BLETypeCharacteristic != type) || 0 != offset)
3939 {
4040 return 0 ;
@@ -64,8 +64,8 @@ uint8_t profile_notify_process (struct bt_conn *conn,
6464
6565// Only for central
6666uint8_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)
6969{
7070 BLEPeripheralHelper* peripheral = BLECentralRole::instance ()->peripheral (conn);// Find peripheral by bt_conn
7171 peripheral->discover (attr);
@@ -84,7 +84,7 @@ uint8_t profile_read_rsp_process(struct bt_conn *conn, int err,
8484 }
8585 BLEPeripheralHelper* peripheral = BLECentralRole::instance ()->peripheral (conn);// Find peripheral by bt_conn
8686 BLEAttribute* readatt = peripheral->attribute (params->single .handle );
87- BLECharacteristic *chrc = (BLECharacteristic *)readatt;
87+ BLECharacteristic *chrc = (BLECharacteristic *)readatt;
8888
8989 // assert(readatt->type() == BLETypeCharacteristic);
9090 chrc->setValue (*((BLEHelper *)peripheral), (const unsigned char *)data, length);
@@ -208,16 +208,16 @@ int BLEProfile::registerProfile()
208208 int ret = 0 ;
209209
210210 // Start debug
211- int i;
211+ int i;
212212
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+ }
221221
222222 delay (1000 );
223223 // End for debug
@@ -242,55 +242,55 @@ void BLEProfile::discover(const struct bt_gatt_attr *attr)
242242 if (attribute->discovering ())
243243 {
244244 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+ }
294294 attribute->discover (attr, &_discover_params);
295295 break ;
296296 }
@@ -321,16 +321,16 @@ void BLEProfile::discover(const struct bt_gatt_attr *attr)
321321 if (NULL == conn)
322322 {
323323 // Link lost
324- pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
324+ pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
325325 return ;
326326 }
327327 err = bt_gatt_discover (conn, &_discover_params);
328328 bt_conn_unref (conn);
329- if (err)
329+ if (err)
330330 {
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+ }
334334 }
335335}
336336
@@ -344,7 +344,7 @@ void BLEProfile::discover()
344344 if (NULL == conn)
345345 {
346346 // Link lost
347- pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
347+ pr_debug (LOG_MODULE_APP, " Can't find connection\n " );
348348 return ;
349349 }
350350
@@ -354,11 +354,11 @@ void BLEProfile::discover()
354354
355355 err = bt_gatt_discover (conn, &_discover_params);
356356 bt_conn_unref (conn);
357- if (err)
357+ if (err)
358358 {
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+ }
362362}
363363
364364BLEAttribute *BLEProfile::attribute (struct bt_gatt_subscribe_params *params)
@@ -390,7 +390,7 @@ BLEAttribute *BLEProfile::attribute(const struct bt_uuid* uuid)
390390
391391 if (false == att_found)
392392 {
393- pr_debug (LOG_MODULE_APP, " Attributes not found" );
393+ pr_debug (LOG_MODULE_APP, " Attributes not found" );
394394 // Didn't found the characteristic
395395 chrc_tmp = NULL ;
396396 }
0 commit comments