Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to create our service successfully

Hello

I'm using SDK 15, S132 PCA10040 

I have followed this tut.

I've tried 2 scenarios which in both I get error value:

1. when advertising_init() is before services_init() then advertising_init()->ble_advertising_init()->ble_advdata_set->()ble_advdata_encode() returns NRF_ERROR_INVALID_PARAM (#7).

2. when services_init() is before advertising_init() then advertising_init()->ble_advertising_init()->ble_advdata_set->()sd_ble_gap_adv_data_set() returns NRF_ERROR_INVALID_ADDR (#16).

I've been looking in few FAQ's but couldn't find the answer.

Application's definitions and declaration:

#define BLE_UUID_OUR_BASE_UUID              {0xD8,0xD0,0xAA,0x28,0x10,0x7E,0x58,0x73,0x30,0xF0,0x5E,0x9A,0xFB,0xCA,0x13,0x89}
#define BLE_UUID_OUR_SERVICE                0x04AE

static ble_uuid_t m_adv_uuids[] =       /**< Universally unique service identifiers. */
{
    {BLE_UUID_OUR_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN}
};

services_init() and our_service_init() functions

static void services_init(void)
{
    ret_code_t         err_code;
    nrf_ble_qwr_init_t qwr_init = {0};

    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;

    err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
    APP_ERROR_CHECK(err_code);

    our_service_init(m_adv_uuids);
}

void our_service_init(ble_uuid_t * p_our_service)
{
    uint32_t   err_code;// Variable to hold return codes from library and softdevice functions
    
    // OUR_JOB: Declare 16-bit service and 128-bit base UUIDs and add them to the BLE stack
    ble_uuid_t        service_uuid;
    ble_uuid128_t     base_uuid = BLE_UUID_OUR_BASE_UUID;
    service_uuid.uuid = BLE_UUID_OUR_SERVICE;
    err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
    APP_ERROR_CHECK(err_code);
}

advertising_init() function:

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      = true;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;

    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

    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;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

Please help me understand what is wrong here.

Thanks in advance.

Parents
  • HI Ran, 

    the tutorial you're using is based on SDK v11.0.0 and is therefore not compatible with SDK v15.0.0. I recommend that you use this tutorial instead, which is based on SDK v15.0.0.


    Best regards

    Bjørn   

  • Hello Bjorn,

    I've followed steps 1-3 from tut, but function ble_stack_init()->nrf_sdh_ble_enable()->sd_ble_enable() returns NRF_ERROR_NO_MEM #4.

    I'm using IAR 8.22.1.

    My ICF file is:

    /*###ICF### Section handled by ICF editor, don't touch! ****/
    /*-Editor annotation file-*/
    /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
    /*-Specials-*/
    define symbol __ICFEDIT_intvec_start__ = 0x26000;
    /*-Memory Regions-*/
    define symbol __ICFEDIT_region_ROM_start__   = 0x26000;
    define symbol __ICFEDIT_region_ROM_end__     = 0x5a000;/*0x7ffff;*/
    define symbol __ICFEDIT_region_RAM_start__   = 0x20002218;
    define symbol __ICFEDIT_region_RAM_end__     = 0x2000dde0;/*0x2000ffff;*/
    export symbol __ICFEDIT_region_RAM_start__;
    export symbol __ICFEDIT_region_RAM_end__;
    /*-Sizes-*/
    define symbol __ICFEDIT_size_cstack__   = 8192;
    define symbol __ICFEDIT_size_heap__     = 8192;
    /**** End of ICF editor section. ###ICF###*/
    
    define memory mem with size = 4G;
    define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
    define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];
    
    define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
    define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
    define block RO_END    with alignment = 8, size = 0     { };
    
    initialize by copy { readwrite };
    do not initialize  { section .noinit };
    
    keep { section .intvec };
    place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
    place in ROM_region   { readonly,
                            block RO_END };
    place in RAM_region   { readwrite,
                            block CSTACK,
                            block HEAP };
    
    

    The error is in both cases:

    ROM_end__     = 0x7ffff;            //Original value

    RAM_end__     = 0x2000ffff;     //Original value

    or,

    ROM_end__     = 0x5a000;       //As is tutorial

    RAM_end__     = 0x2000dde0; //As is tutorial

    BTW, the RAM_start__ in my ICF file is  = 0x20002218 and not 0x20002220.

    Please help me with this issue.

    Tanks in advance.

  • Hello,

    I've found the problem.

    When I changed the RAM_start__ from 0x20002218 to 0x20002220, the scanner device recognized the PCA10040 device as "Nord" with the correct UUID as in tut.

Reply Children
No Data
Related