using two different UUID

Hi,

I'm uisng pca10100, nrf52833.

My project have both scanning and advertising. And I want to using two different custom UUID per each scan and advertise.

I define each uuid, each function and each data. But it's only work one UUID which I define first.

For example, my central (scanning) UUID is start with 64b40000-... ,and my peripheral (advertising) UUID is start with f6d80000-...

and this is my initialize code

#1 is scan initialize

//app_client() function..

static ble_uuid_t const m_wdw_uuid =
{
    .uuid = BLE_UUID_WDW_SERVICE,
    .type = WDW_SERVICE_UUID_TYPE
};


//..

static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

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

    init_scan.connect_if_match = true;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_wdw_uuid);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
    APP_ERROR_CHECK(err_code);
}

#2 is advertise initialize

//app_server() function..

static ble_uuid_t m_adv_uuids[] =                                                   /**< Universally unique service identifier. */
{
    {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
};


//..

static void advertising_init(void)
{
    uint32_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_LIMITED_DISC_MODE;

    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_on_disconnect_disabled = true; //no re-advertising after disconnect

    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);
}

and I seperate 'ble_uuid128_t' data .. and also seperate 'sd_ble_uuid_vs_add'

/** @brief 128 bit UUID values. */
typedef struct
{
  uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */
} ble_c_uuid128_t;

typedef struct
{
  uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */
} ble_s_uuid128_t;

//ble.h

SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_c_uuid_vs_add(ble_c_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));

SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_s_uuid_vs_add(ble_s_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));

but it doesn't still work.. what am I missing?

+add)

If I using uuid scanning filter, it doesn't paired, but it paired well when I using name filter..and also communicate well.

why central-peripheral cannot connect when using uuid scanning filter?

BR,

lyrics

Parents
  • Hi Lyrics,

    The two snippets where you initialize scanning and advertising immediately looks OK, though I don't see where m_wdw_uuid and m_adv_uuids comes from. Also, you have some SVCALL definition that immediately looks very suspicious (the SoftDevice use supervisor calls, but these are not SoftDevice functions, so I am very unsure about what this is. Does this code really work with one UUID?

    If you want to see how to add custom UUIDs I suggest you refer to the NUS implementation  <SDK>\components\ble\ble_services\ble_nus\ble_nus.c (you may also need to adjust the NRF_SDH_BLE_VS_UUID_COUNT in sdk_config.h).

    You do not write in which way this doe snot fail, and I do not see enough of your code or config to suggest anything with confidence. However, if you want to filter on multiple UUIDs with the BLE Scan module you need to set NRF_BLE_SCAN_UUID_CNT in sdk_config.h to a higher number.

    Einar

Reply
  • Hi Lyrics,

    The two snippets where you initialize scanning and advertising immediately looks OK, though I don't see where m_wdw_uuid and m_adv_uuids comes from. Also, you have some SVCALL definition that immediately looks very suspicious (the SoftDevice use supervisor calls, but these are not SoftDevice functions, so I am very unsure about what this is. Does this code really work with one UUID?

    If you want to see how to add custom UUIDs I suggest you refer to the NUS implementation  <SDK>\components\ble\ble_services\ble_nus\ble_nus.c (you may also need to adjust the NRF_SDH_BLE_VS_UUID_COUNT in sdk_config.h).

    You do not write in which way this doe snot fail, and I do not see enough of your code or config to suggest anything with confidence. However, if you want to filter on multiple UUIDs with the BLE Scan module you need to set NRF_BLE_SCAN_UUID_CNT in sdk_config.h to a higher number.

    Einar

Children
No Data
Related