Skip to content

Commit 0a99daa

Browse files
committed
Jira 714 Find the limits of the number of Services and Characteristics
Make the BLE support more characteristics and services by separate the service registration Changed files BLEProfileManager.cpp - Remove register all service at same time BLEProfileManager.h - Change the comments BLEServiceImp.cpp - Add the register service after update the characteristic
1 parent baf05aa commit 0a99daa

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

libraries/CurieBLE/src/internal/BLEProfileManager.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ int BLEProfileManager::serviceCount(const BLEDevice &bledevice) const
245245

246246
int BLEProfileManager::registerProfile(BLEDevice &bledevice)
247247
{
248-
int ret = 0;
249-
250248
bt_gatt_attr_t *start;
251249
BleStatus err_code = BLE_STATUS_SUCCESS;
252250

@@ -292,35 +290,20 @@ int BLEProfileManager::registerProfile(BLEDevice &bledevice)
292290
{
293291
BLEServiceImp *service = node->value;
294292
start = _attr_base + _attr_index;
295-
service->updateProfile(start, _attr_index);
296-
node = node->next;
297-
}
298-
299-
#if 0
300-
// Start debug
301-
int i;
302-
303-
for (i = 0; i < _attr_index; i++) {
293+
err_code = service->updateProfile(start, _attr_index);
294+
if (BLE_STATUS_SUCCESS != err_code)
304295
{
305-
pr_info(LOG_MODULE_APP, "gatt-: i %d, type %d, u16 0x%x",
306-
i,
307-
_attr_base[i].uuid->type,
308-
BT_UUID_16(_attr_base[i].uuid)->val);
296+
break;
309297
}
298+
node = node->next;
310299
}
311300

312-
delay(1000);
313-
// End for debug
314-
#endif
315-
316-
ret = bt_gatt_register(_attr_base,
317-
_attr_index);
318-
pr_debug(LOG_MODULE_APP, "%s: ret, %d,_attr_index-%d", __FUNCTION__, ret, _attr_index);
319-
if (0 == ret)
301+
// Will not regiter the profile if ARC registered any profile
302+
if (_attr_index > 0)
320303
{
321304
_profile_registered = true;
322305
}
323-
return ret;
306+
return err_code;
324307
}
325308

326309
void BLEProfileManager::clearProfile(BLEServiceLinkNodeHeader* serviceHeader)

libraries/CurieBLE/src/internal/BLEProfileManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class BLEProfileManager{
6565
*
6666
* @param[in] bledevice The BLE Device
6767
*
68-
* @return int std C errno
68+
* @return int BLE errno @BleStatus
6969
*
7070
* @note none
7171
*/

libraries/CurieBLE/src/internal/BLEServiceImp.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ int BLEServiceImp::updateProfile(bt_gatt_attr_t *attr_start, int& index)
120120
int base_index = index;
121121
int offset = 0;
122122
int counter = 0;
123+
int ret = 0;
123124
start->uuid = BLEServiceImp::getPrimayUuid();
124125
start->perm = BT_GATT_PERM_READ;
125126
start->read = bt_gatt_attr_read_service;
@@ -139,7 +140,10 @@ int BLEServiceImp::updateProfile(bt_gatt_attr_t *attr_start, int& index)
139140
counter += offset;
140141
node = node->next;
141142
}
142-
return counter;
143+
ret = bt_gatt_register(attr_start,
144+
counter);
145+
146+
return errorno_to_ble_status(ret);
143147
}
144148

145149
int BLEServiceImp::getAttributeCount()

0 commit comments

Comments
 (0)