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

Problem connection to centrals to one peripheral

Hello,

I need help. I cannot see my earlier ongoing ticket!? I have been working With it for the last couple of Days and today i was asked to share my Project but now the whole ticket is gone:( What to do, do i need to do it all again or can you guys pick it up somewere?

/Kalle

Parents
  • If you dont have any backup. 

    I have tried to change parameters in example codes but i Always get the error code 0x3001 if i change the number of Connection (doenst matter if i increase peripherals or centrals). If i change it from 1 to let us say 2 or more, i get 0x3001.
    The function that return this error message is:
    ret = sd_ble_gap_adv_start(&adv_params, m_conn_cfg_tag);

    The parameter that i change is:

    #define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT      (1)

    In my last ticket we get so far that i was asked to send/share my Project. I asked how, if the responsible person had an >FTP or email for sharing this Project. After that the ticket dissapeared.

  • Hi,

    Do you enable ble in the application before starting advertising? Error 0x3001 indicates that ble is not enabled (BLE_ERROR_NOT_ENABLED). You enable it by calling these functions below:

     

    static void ble_stack_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
    
        // Configure the BLE stack using the default settings.
        // Fetch the start address of the application RAM.
        uint32_t ram_start = 0;
        err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Enable BLE stack.
        err_code = nrf_sdh_ble_enable(&ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Register a handler for BLE events.
        NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    }

  • I am getting a linker error: "undefined symbol m_app_twi" in the file mma8552fc.c. The file includes globals.h, where the variable m_app_twi is declared as an extern const. I can see that the definition of m_app_twi is inside m_applicationInit.c, and according to this thread, I would think this should work.

    Did you get this error? Where did you place your project, what SDK did you use and what version of Keil did you use?

    Best regards,

    Simon

  • I didnt have any errors, maybe something With paths..

    I have my Project under c:\nRF_13.0.0

    So the SDK is 13.0.0 and i am currently running KEIL V5.22.0.0. (i am now migrating all our Projects to IAR). 

    If you want i can build a new Project without m_app_twi but maybe it is good to have Everything included.

  • I got rid of the issue regarding m_app_twi by placing the definition APP_TWI_DEF() inside globals.h instead.

    The reason sd_ble_gap_adv_start() failed with 0x3001 (BLE_ERROR_NOT_ENABLED) is because the function PMBLE_ble_stack_init()-->softdevice_enable()-->sd_ble_enable() failed with 0x04 (NRF_ERROR_NO_MEM). 

    This can be resolved by adjusting the values RAM_START and RAM_SIZE. To figure out what to adjust it to you can enable logging and check the NRF_LOG_WARNING(..) in PMBLE_ble_stack_init()-->softdevice_enable().

    I adjusted RAM_SIZE to  0xDA64 and RAM_START to 0x20002CD8 and the error messages disappeared.

    Best regards,

    Simon

Reply
  • I got rid of the issue regarding m_app_twi by placing the definition APP_TWI_DEF() inside globals.h instead.

    The reason sd_ble_gap_adv_start() failed with 0x3001 (BLE_ERROR_NOT_ENABLED) is because the function PMBLE_ble_stack_init()-->softdevice_enable()-->sd_ble_enable() failed with 0x04 (NRF_ERROR_NO_MEM). 

    This can be resolved by adjusting the values RAM_START and RAM_SIZE. To figure out what to adjust it to you can enable logging and check the NRF_LOG_WARNING(..) in PMBLE_ble_stack_init()-->softdevice_enable().

    I adjusted RAM_SIZE to  0xDA64 and RAM_START to 0x20002CD8 and the error messages disappeared.

    Best regards,

    Simon

Children
  • How did you enable the logging? I dont get it to work....What do you mean with check the NRF_LOG_WARNING(..)..This things are  new to me:)

    Can you also attach the hex file of your build?

    /Kalle

  • Isnt it just to check the value of ram_start after that the function

        err_code = softdevice_app_ram_start_get(&ram_start);

    In the debugger this gives me the ram_start adress of: 0x20002598 which also is the same
    number that I can see in the "Options for target..." in keil IRAM1 ? How does the numbers in Keil "options for target" correlate with the ones in the code?

  • "Isnt it just to check the value of ram_start after that the function
      err_code = softdevice_app_ram_start_get(&ram_start);"

    No, this is not correct. This will give you the current value of ram start, not what it should be (after increasing BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT and more RAM is required) This is the reason it is equal to the value in "Options for target".

    In order to check what you should update it to, you have to look inside PMBLE_ble_stack_init()→softdevice_enable(). Take a look at the snippet below, where I have added a lot of comment to explain it.

    uint32_t softdevice_enable(uint32_t * ram_start)
    {
        .
        .
        .
        //Set value of app_ram_base to the current RAM_START
        uint32_t app_ram_base = *ram_start; 
    
        //Print out the current RAM_START
        NRF_LOG_DEBUG("RAM start at 0x%x.\r\n", app_ram_base);
        
        //--->Try to enable the ble stack with the RAM_START set in "Options for target"
        //--->If the function returns 0x04 (NRF_ERROR_NO_MEM), you need to increase RAM_START to the 
        //    value inside app_ram_base
        err_code = sd_ble_enable(&app_ram_base);
    
        //-->If sd_ble_enable() failed with 0x04, app_ram_base now contains the value which you should set RAM_START to
        //   in "options for target"
        if (app_ram_base != *ram_start)
        {
            NRF_LOG_WARNING("RAM start should be adjusted to 0x%x.\r\n", app_ram_base);
            NRF_LOG_WARNING("RAM size should be adjusted to 0x%x.\r\n",
                            ram_end_address_get() - app_ram_base);
        }
        .
        .

    "How did you enable the logging? I dont get it to work....What do you mean with check the NRF_LOG_WARNING(..)..This things are  new to me:)"

    Check out this link on how to enable logging

    In order to see the warning log, the level should be set to 2 or higher in sdk_config.h, but I think it should be set to 3 by default, so you should be fine:

    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRF_LOG_DEFAULT_LEVEL
    #define NRF_LOG_DEFAULT_LEVEL 3
    #endif

    Best regards,

    Simon

  • Thanks for your help! Now it works perfect!:)

  • I am glad it works, and I'm happy to help:)

Related