Skip to content

Commit d1c16d2

Browse files
lib: bluetooth: ble_adv: change error codes to nrf_error
Change error codes to nrf_errors. Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
1 parent 2125727 commit d1c16d2

14 files changed

Lines changed: 416 additions & 395 deletions

File tree

applications/firmware_loader/ble_mcumgr/src/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ static int ble_change_address(void)
176176
int main(void)
177177
{
178178
int err;
179+
uint32_t nrf_err;
179180
struct ble_adv_config ble_adv_cfg = {
180181
.conn_cfg_tag = CONFIG_NRF_SDH_BLE_CONN_TAG,
181182
.evt_handler = ble_adv_evt_handler,
@@ -231,17 +232,15 @@ int main(void)
231232
ble_adv_cfg.sr_data.uuid_lists.complete.uuid = &adv_uuid_list[0];
232233
ble_adv_cfg.sr_data.uuid_lists.complete.len = ARRAY_SIZE(adv_uuid_list);
233234

234-
err = ble_adv_init(&ble_adv, &ble_adv_cfg);
235-
236-
if (err) {
237-
LOG_ERR("Failed to initialize advertising, err %d", err);
235+
nrf_err = ble_adv_init(&ble_adv, &ble_adv_cfg);
236+
if (nrf_err) {
237+
LOG_ERR("Failed to initialize advertising, nrf_error %#x", nrf_err);
238238
return 0;
239239
}
240240

241-
err = ble_adv_start(&ble_adv, BLE_ADV_MODE_FAST);
242-
243-
if (err) {
244-
LOG_ERR("Failed to start advertising, err %d", err);
241+
nrf_err = ble_adv_start(&ble_adv, BLE_ADV_MODE_FAST);
242+
if (nrf_err) {
243+
LOG_ERR("Failed to start advertising, nrf_error %#x", nrf_err);
245244
return 0;
246245
}
247246

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ No changes since the latest nRF Connect SDK Bare Metal release.
6868
Libraries
6969
=========
7070

71+
* Updated the following libraries to return ``nrf_errors`` instead of ``errnos``:
72+
73+
* BLE Advertising library.
74+
7175
* :ref:`lib_ble_conn_params` library:
7276

7377
* Added missing Kconfig dependencies.

include/bm/bluetooth/ble_adv.h

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct ble_adv_evt {
136136
union {
137137
/** @ref BLE_ADV_EVT_ERROR event data. */
138138
struct {
139-
int reason;
139+
uint32_t reason;
140140
} error;
141141
};
142142
};
@@ -256,19 +256,19 @@ void ble_adv_on_ble_evt(const ble_evt_t *ble_evt, void *ble_adv);
256256
* @param[in] ble_adv BLE advertising instance.
257257
* @param[in] ble_adv_config Initialization configuration.
258258
*
259-
* @retval 0 On success.
260-
* @retval -FAULT If @p ble_adv or @p ble_adv_config are @c NULL.
261-
* @retval -EINVAL If the configuration @p ble_adv_config is invalid.
259+
* @retval NRF_SUCCESS On success.
260+
* @retval NRF_ERROR_NULL If @p ble_adv or @p ble_adv_config are @c NULL.
261+
* @retval NRF_ERROR_INVALID_PARAM If the configuration @p ble_adv_config is invalid.
262262
*/
263-
int ble_adv_init(struct ble_adv *ble_adv, struct ble_adv_config *ble_adv_config);
263+
uint32_t ble_adv_init(struct ble_adv *ble_adv, struct ble_adv_config *ble_adv_config);
264264

265265
/**
266266
* @brief Set the connection configuration tag used for connections.
267267
*
268268
* @param[in] ble_adv BLE advertising instance.
269269
* @param[in] ble_cfg_tag Connection configuration tag.
270270
*/
271-
int ble_adv_conn_cfg_tag_set(struct ble_adv *ble_adv, uint8_t ble_cfg_tag);
271+
uint32_t ble_adv_conn_cfg_tag_set(struct ble_adv *ble_adv, uint8_t ble_cfg_tag);
272272

273273
/**
274274
* @brief Start advertising in given mode.
@@ -279,12 +279,12 @@ int ble_adv_conn_cfg_tag_set(struct ble_adv *ble_adv, uint8_t ble_cfg_tag);
279279
* @param[in] ble_adv BLE advertising instance.
280280
* @param[in] mode Desired advertising mode.
281281
*
282-
* @retval 0 On success.
283-
* @retval -EPERM Library is not initialized.
284-
* @retval -EFAULT @p ble_adv is @c NULL.
285-
* @retval -EINVAL Invalid parameters.
282+
* @retval NRF_SUCCESS On success.
283+
* @retval NRF_ERROR_INVALID_STATE Library is not initialized.
284+
* @retval NRF_ERROR_NULL @p ble_adv is @c NULL.
285+
* @retval NRF_ERROR_INVALID_PARAM Invalid parameters.
286286
*/
287-
int ble_adv_start(struct ble_adv *ble_adv, enum ble_adv_mode mode);
287+
uint32_t ble_adv_start(struct ble_adv *ble_adv, enum ble_adv_mode mode);
288288

289289
/**
290290
* @brief Set the peer address for directed advertising.
@@ -296,12 +296,12 @@ int ble_adv_start(struct ble_adv *ble_adv, enum ble_adv_mode mode);
296296
* @param[in] p_advertising Advertising Module instance.
297297
* @param[in] p_peer_addr Pointer to a peer address.
298298
*
299-
* @retval 0 On success.
300-
* @retval -EPERM Library is not initialized.
301-
* @retval -EFAULT @p ble_adv is @c NULL.
302-
* @retval -EINVAL Invalid parameters.
299+
* @retval NRF_SUCCESS On success.
300+
* @retval NRF_ERROR_INVALID_STATE Library is not initialized.
301+
* @retval NRF_ERROR_NULL @p ble_adv is @c NULL.
302+
* @retval NRF_ERROR_INVALID_PARAM Invalid parameters.
303303
*/
304-
int ble_adv_peer_addr_reply(struct ble_adv *ble_adv, const ble_gap_addr_t *peer_addr);
304+
uint32_t ble_adv_peer_addr_reply(struct ble_adv *ble_adv, const ble_gap_addr_t *peer_addr);
305305

306306
/**
307307
* @brief Set a whitelist for fast and slow advertising.
@@ -315,14 +315,14 @@ int ble_adv_peer_addr_reply(struct ble_adv *ble_adv, const ble_gap_addr_t *peer_
315315
* @param[in] gap_irks The list of peer IRK to whitelist.
316316
* @param[in] irk_cnt The number of peer IRK to whitelist.
317317
*
318-
* @retval 0 On success.
319-
* @retval -EPERM Library is not initialized.
320-
* @retval -EFAULT @p ble_adv is @c NULL.
321-
* @retval -EINVAL Invalid parameters.
318+
* @retval NRF_SUCCESS On success.
319+
* @retval NRF_ERROR_INVALID_STATE Library is not initialized.
320+
* @retval NRF_ERROR_NULL @p ble_adv is @c NULL.
321+
* @retval NRF_ERROR_INVALID_PARAM Invalid parameters.
322322
*/
323-
int ble_adv_whitelist_reply(struct ble_adv *ble_adv,
324-
const ble_gap_addr_t *gap_addrs, uint32_t addr_cnt,
325-
const ble_gap_irk_t *gap_irks, uint32_t irk_cnt);
323+
uint32_t ble_adv_whitelist_reply(struct ble_adv *ble_adv,
324+
const ble_gap_addr_t *gap_addrs, uint32_t addr_cnt,
325+
const ble_gap_irk_t *gap_irks, uint32_t irk_cnt);
326326

327327
/**
328328
* @brief Restart advertising without whitelist.
@@ -332,11 +332,12 @@ int ble_adv_whitelist_reply(struct ble_adv *ble_adv,
332332
*
333333
* @param[in] ble_adv Advertising Module instance.
334334
*
335-
* @retval 0 On success.
336-
* @retval -EPERM Library is not initialized.
337-
* @retval -EFAULT @p ble_adv is @c NULL.
335+
* @retval NRF_SUCCESS On success.
336+
* @retval NRF_ERROR_INVALID_STATE Library is not initialized.
337+
* @retval NRF_ERROR_NULL @p ble_adv is @c NULL.
338+
* @retval NRF_ERROR_INVALID_PARAM Invalid advertising parameters.
338339
*/
339-
int ble_adv_restart_without_whitelist(struct ble_adv *ble_adv);
340+
uint32_t ble_adv_restart_without_whitelist(struct ble_adv *ble_adv);
340341

341342
/**@brief Function for updating advertising data.
342343
*
@@ -355,9 +356,9 @@ int ble_adv_restart_without_whitelist(struct ble_adv *ble_adv);
355356
* @retval @ref NRF_SUCCESS or any error from @ref ble_advdata_encode or
356357
* @ref sd_ble_gap_adv_set_configure().
357358
*/
358-
int ble_adv_data_update(struct ble_adv *ble_adv,
359-
const struct ble_adv_data *adv,
360-
const struct ble_adv_data *sr);
359+
uint32_t ble_adv_data_update(struct ble_adv *ble_adv,
360+
const struct ble_adv_data *adv,
361+
const struct ble_adv_data *sr);
361362

362363
#ifdef __cplusplus
363364
}

include/bm/bluetooth/ble_adv_data.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ struct ble_adv_data {
185185
* @param[out] buf Output buffer.
186186
* @param[in,out] len Size of @p buf on input, length of encoded data on output.
187187
*
188-
* @retval 0 If the operation was successful.
189-
* @retval -EINVAL Invalid parameter.
190-
* @retval -E2BIG Buffer is too small to encode all data.
188+
* @retval NRF_SUCCESS If the operation was successful.
189+
* @retval NRF_ERROR_INVALID_ADDR Invalid address.
190+
* @retval NRF_ERROR_INVALID_PARAM Invalid parameter provided in the adverising data context.
191+
* @retval NRF_ERROR_NULL @p ble_adv_data, @p buf or @p len is NULL.
192+
* @retval NRF_ERROR_DATA_SIZE Buffer is too small to encode all data.
191193
*
192194
* @warning This API may override the application's request to use the long name and use a short
193195
* name instead. This truncation will occur in case the long name does not fit the provided buffer
@@ -199,7 +201,7 @@ struct ble_adv_data {
199201
* application can specify, and if the preference is too large to fit in the provided buffer, the
200202
* name can be truncated further.
201203
*/
202-
int ble_adv_data_encode(const struct ble_adv_data *ble_adv_data, uint8_t *buf, uint16_t *len);
204+
uint32_t ble_adv_data_encode(const struct ble_adv_data *ble_adv_data, uint8_t *buf, uint16_t *len);
203205

204206
/**
205207
* @brief Search Advertising or Scan Response data for specific data types.

0 commit comments

Comments
 (0)