Skip to content

Commit 53c6f85

Browse files
committed
Apply resloution for the "Read long UUID of service problem" according to
NRFFOETT-1674.
1 parent b2080ab commit 53c6f85

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xServiceDiscovery.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@ nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_t *p_gatt
290290
UUID::LongUUIDBytes_t uuid;
291291

292292
#if (NRF_SD_BLE_API_VERSION >= 3)
293-
/* SoftDevice API since 3.0.0 (e.g. sd 140 5.0.0-1.alpha) provide sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter() helper function,
294-
* but it's not reliable for c++ build.
295-
* Instead of it memcpy gets proper response's value field by offset from handle-value pair: [2 B handle|16 B value=uuid_128b] */
296-
297-
memcpy(uuid, (&response->handle_value + 2), UUID::LENGTH_OF_LONG_UUID);
293+
ble_gattc_handle_value_t iter;
294+
memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
295+
(void) sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(const_cast<ble_gattc_evt_t*>(p_gattc_evt), &iter);
296+
memcpy(uuid, iter.p_value, UUID::LENGTH_OF_LONG_UUID);
298297
#else
299298
memcpy(uuid, &(response->handle_value[0].p_value[0]), UUID::LENGTH_OF_LONG_UUID);
300299
#endif
@@ -311,10 +310,10 @@ nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_t *p_gatt
311310
UUID::LongUUIDBytes_t uuid;
312311

313312
#if (NRF_SD_BLE_API_VERSION >= 3)
314-
/* SoftDevice API since 3.0.0 (e.g. sd 140 5.0.0-1.alpha) provide sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter() helper function,
315-
* but it's not reliable for c++ build.
316-
* Instead of it memcpy gets proper response's value by offset: [2 B type| 1B prop |2 B value handle| 16 B value=uuid_128b] */
317-
memcpy(uuid, (&response->handle_value + 5), UUID::LENGTH_OF_LONG_UUID);
313+
ble_gattc_handle_value_t iter;
314+
memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
315+
(void) sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(const_cast<ble_gattc_evt_t*>(p_gattc_evt), &iter);
316+
memcpy(uuid, &(iter.p_value[3]), UUID::LENGTH_OF_LONG_UUID);
318317
#else
319318
memcpy(uuid, &(response->handle_value[0].p_value[3]), UUID::LENGTH_OF_LONG_UUID);
320319
#endif

0 commit comments

Comments
 (0)