This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting err_code = 12289 even though sd_ble_enable was already called before.

Hi. I am working with nrf52832 trying to get Bluetooth and UART and a I2C peripheral working at the same time. I had a working version of the I2C peripheral and UART working together and tried to merge Bluetooth in, referencing the experimental_ble_app_blinky example provided in nRF5_SDK_12.3.0.

Currently when I added ble_stack_init() into my existing program plus all the elements it needs for compiling, I have it in function without breaking any functions I had with UART. However, after I added gap_params_init() after ble_stack_init(), along with everything it needed to compile, of course, my device started to keep rebooting, after the program compiled and ran.

I changed APP_ERROR_CHECK(err_code) statements in my gap_params_init function into printf statements to print out the error code and I got err_code = 12289 for both sd_ble_gap_device_name_set and sd_ble_gap_ppcp_set.

I have already found out that this error code means that sd_ble_enable has not been called, however, I had also made sure that sd_ble_enable was actually called before it gets to gap_params_init(). The sd_ble_enable was called inside a function named softdevice_enable, and softdevice_enable was called inside ble_stack_init(). I have also added debugging printf statements inside my ble_stack_init function and made sure that softdevice_enable was indeed called successfully before the program gets to gap_params_init().

I am not sure why I am getting this error code.

  • Hi, Andreas,

    Thank you for your help. I followed your advice and modified the Makefile you provided and now I can get through gap_params_init(); services_init(); and advertising_init(); without breaking anything function I already had. I need to study what were the differences between my old Makefile and the one you provided though to learn the reason why this happened though...

    Also, when I got to conn_params_init(); and compiled it, my device started to keep rebooting again, I added debugging printf statements and found out that this time I am getting err_code = 8 for ble_conn_params_init. I think I found somebody else who had the same problem here (https://devzone.nordicsemi.com/f/nordic-q-a/4268/error-code-0x08/15241#15241) but I need some time to study about the APP_TIMER too.

    Anyway, thank you for helping me solve my question I originally was asking! I will ask again if I have new questions.

    Sincerely,

    Connie

  • Hi.

    Yes, this error is given by app_timer_create which is called in ble_conn_params_init():

    /**@brief Function for creating a timer instance.
     *
     * @param[in]  p_timer_id        Pointer to timer identifier.
     * @param[in]  mode              Timer mode.
     * @param[in]  timeout_handler   Function to be executed when the timer expires.
     *
     * @retval     NRF_SUCCESS               If the timer was successfully created.
     * @retval     NRF_ERROR_INVALID_PARAM   If a parameter was invalid.
     * @retval     NRF_ERROR_INVALID_STATE   If the application timer module has not been initialized or
     *                                       the timer is running.
     *
     * @note This function does the timer allocation in the caller's context. It is also not protected
     *       by a critical region. Therefore care must be taken not to call it from several interrupt
     *       levels simultaneously.
     * @note The function can be called again on the timer instance and will re-initialize the instance if
     *       the timer is not running.
     * @attention The FreeRTOS and RTX app_timer implementation does not allow app_timer_create to
     *       be called on the previously initialized instance.
     */
    uint32_t app_timer_create(app_timer_id_t const *      p_timer_id,
                              app_timer_mode_t            mode,
                              app_timer_timeout_handler_t timeout_handler);
    

    You have either not initialized the timer or the timer is already running.

    Best regards,

    Andreas

Related