Issue with Advertising on nRF52810 – Error 0x000005

Hello,

I am using the nRF52810 with SoftDevice S112_nrf52_7.0.1 and trying to create a simple program that sends the character "1" to a mobile device. However, I am encountering error 0x000005, and the advertising does not start. As a result, I cannot see the network on my mobile device to connect to it.

I have attached the relevant code for reference. Could you please help me troubleshoot this issue?

Thank you in advance!

Best regards,

#include <stdint.h>
#include "nrf.h"
#include "nrf_sdh.h"
#include "nrf_sdh_ble.h"
#include "ble_advertising.h"
#include "nrf_ble_gatt.h"
#include "app_timer.h"
#include "boards.h"
#include "SEGGER_RTT.h"
#include "nrf_delay.h"

#define DEVICE_NAME "mi red"
#define APP_BLE_CONN_CFG_TAG 1
#define APP_ADV_INTERVAL 64
#define APP_ADV_DURATION 0

BLE_ADVERTISING_DEF(m_advertising);
NRF_BLE_GATT_DEF(m_gatt);

static void ble_stack_init(void) {
ret_code_t err_code;
err_code = nrf_sdh_enable_request();
SEGGER_RTT_printf(0, "nrf_sdh_enable_request: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);

uint32_t ram_start = 0;
err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
SEGGER_RTT_printf(0, "nrf_sdh_ble_default_cfg_set: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);

err_code = nrf_sdh_ble_enable(&ram_start);
SEGGER_RTT_printf(0, "nrf_sdh_ble_enable: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);
}

static void advertising_init(void) {
ret_code_t err_code;
ble_advertising_init_t init;

memset(&init, 0, sizeof(init));

init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = false;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
m_advertising.adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;

err_code = ble_advertising_init(&m_advertising, &init);
SEGGER_RTT_printf(0, "ble_advertising_init: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);
}

static void advertising_start(void) {
ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
SEGGER_RTT_printf(0, "ble_advertising_start: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);
}

static void advertising_stop(void) {
ret_code_t err_code = sd_ble_gap_adv_stop(m_advertising.adv_handle); // Usar la API de GAP para detener el advertising
SEGGER_RTT_printf(0, "sd_ble_gap_adv_stop: 0x%08X\n", err_code);

if (err_code != NRF_SUCCESS) {
SEGGER_RTT_printf(0, "Failed to stop advertising: 0x%08X\n", err_code);
}
}

static void gatt_init(void)
{
ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
SEGGER_RTT_printf(0, "nrf_ble_gatt_init: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);
}

static void gap_params_init(void)
{
ret_code_t err_code;
ble_gap_conn_sec_mode_t sec_mode;

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
SEGGER_RTT_printf(0, "sd_ble_gap_device_name_set: 0x%08X\n", err_code);
APP_ERROR_CHECK(err_code);
}

int main(void) {
// Initialize
SEGGER_RTT_Init();
SEGGER_RTT_printf(0, "Starting BLE advertising example\n");

ble_stack_init();

advertising_init();

gatt_init();
gap_params_init();
//
// Start advertising
ret_code_t err_code = sd_ble_gap_adv_stop(&m_advertising);
SEGGER_RTT_printf(0, "sd_ble_gap_adv_stop: 0x%08X\n", err_code);

nrf_delay_ms(4000);
advertising_start();

//nrf_delay_ms(1000);
//advertising_start();
nrf_delay_ms(4000);
// Main loop
while (true) {
__WFE(); // Wait for event (low power mode)
}
}

Parents Reply Children
Related