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

When 128bit characteristic UUID is different form 128bit service UUID,how to discovery it?

I have the same problem as how to discovery 128bit characteristic UUID which is totally different form 128bit service UUID,the uuid in this question is the same with me,but I can not find solution .

I modified the ble_nus_c_init()  like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define BASE_UUID {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00}}
#define BASE_UUID_FEE9 {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0xe9,0xfe,0x00,0x00}}
#define BASE_UUID_CHAR_RX {{0x00,0x96,0x12,0x16,0x54,0x92,0x75,0xb5,0xa2,0x45,0xfd,0xab,0x39,0xc4,0x4b,0xd4}}
#define BASE_UUID_CHAR_TX {{0x01,0x96,0x12,0x16,0x54,0x92,0x75,0xb5,0xa2,0x45,0xfd,0xab,0x39,0xc4,0x4b,0xd4}}
uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
{
uint32_t err_code;
ble_uuid_t uart_uuid,ble_uuid1,ble_uuid2;
ble_uuid128_t nus_base_uuid =BASE_UUID; //NUS_BASE_UUID;
ble_uuid128_t base_uuid1 = BASE_UUID_CHAR_RX;
ble_uuid128_t base_uuid2 = BASE_UUID_CHAR_TX;
VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init);
err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);
uart_uuid.type = p_ble_nus_c->uuid_type;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And I set NRF_SDH_BLE_VS_UUID_COUNT to 4 , modified the ram start and size.

I can't receive the event BLE_DB_DISCOVERY_COMPLETE, but  receive event  BLE_DB_DISCOVERY_ERROR and BLE_DB_DISCOVERY_SRV_NOT_FOUND

When I change 0xFEE9 to 0xFEE8 I can receive the event BLE_DB_DISCOVERY_COMPLETE,but characteristic.uuid.uuid = 0x00 I don't know why.

How to discovery 128bit characteristic UUID which is totally different form 128bit service UUID?

Can someone help me?

NRF52832   SDK14.2  code base "on ble_app_uart_c"   pca10040  s132

Thanks.

Parents
  • This is what you need, modify it as you see fit:

    In your init function:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ble_uuid128_t your_service_base_uuid = YOUR_SERVICE_BASE_UUID;
    ble_uuid128_t your_characteristic_base_uuid = YOUR_CHARACTERISTIC_BASE_UUID;
    APP_ERROR_CHECK(sd_ble_uuid_vs_add(&your_service_base_uuid, &your_service.type));
    APP_ERROR_CHECK(sd_ble_uuid_vs_add(&your_characteristic_base_uuid, &your_characteristic.type));
    your_service.uuid = BLE_UUID_YOUR_SERVICE;
    your_characteristic.uuid = BLE_UUID_YOUR_CHARACTERISTIC;
    APP_ERROR_CHECK(ble_db_discovery_evt_register(&your_service));
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    In your db_evt_handler:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) {
    if ((p_evt->params.discovered_db.srv_uuid.uuid == your_service.uuid) &&
    (p_evt->params.discovered_db.srv_uuid.type == your_service.type)) {
    for (uint8_t i = 0; i < p_evt->params.discovered_db.char_count; i++) {
    if (p_evt->params.discovered_db.charateristics[i].characteristic.uuid.type == your_characteristic.type) {
    if (p_evt->params.discovered_db.charateristics[i].characteristic.uuid.uuid == your_characteristic.uuid) {
    cccd_handle = p_evt->params.discovered_db.charateristics[i].cccd_handle;
    value_handle = p_evt->params.discovered_db.charateristics[i].characteristic.handle_value;
    }
    }
    }
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    That should work. If it doesn't, my bet is that your calls to ble_db_discovery_evt_register are returning errors. Check the return codes of those functions to verify that they are returning NRF_SUCCESS.

  • Hi Andy

    Thank you for your reply.

    I had modify my init function as you say , but still failed.

    This is my init code:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #define HXJ_BASE_UUID {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00}}
    #define HXJ_BASE_UUID_FEE9 {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0xe9,0xfe,0x00,0x00}}
    #define HXJ_BASE_UUID_CHAR_RX {{0x00,0x96,0x12,0x16,0x54,0x92,0x75,0xb5,0xa2,0x45,0xfd,0xab,0x39,0xc4,0x4b,0xd4}}
    #define HXJ_BASE_UUID_CHAR_TX {{0x01,0x96,0x12,0x16,0x54,0x92,0x75,0xb5,0xa2,0x45,0xfd,0xab,0x39,0xc4,0x4b,0xd4}}
    uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
    {
    uint32_t err_code;
    ble_uuid_t uart_uuid;
    ble_uuid128_t nus_base_uuid =HXJ_BASE_UUID;//NUS_BASE_UUID;
    ble_uuid128_t service_base_uuid = HXJ_BASE_UUID_FEE9;
    ble_uuid128_t characteristicRX_base_uuid = HXJ_BASE_UUID_CHAR_RX;
    ble_uuid128_t characteristicTX_base_uuid = HXJ_BASE_UUID_CHAR_TX;
    VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
    VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init);
    p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID;
    p_ble_nus_c->evt_handler = p_ble_nus_c_init->evt_handler;
    p_ble_nus_c->handles.nus_tx_handle = BLE_GATT_HANDLE_INVALID;
    p_ble_nus_c->handles.nus_rx_handle = BLE_GATT_HANDLE_INVALID;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    All of the four 128bit UUID ,I can get it by nRF Connect APP. Red mark is UUID.

    I tried a lot of values for serviceFEE9.uuid、charRX.uuid and charTX.uuid in the init function。But in the ble_nus_c_on_db_disc_evt() , the value of p_evt->evt_type has not been BLE_DB_DISCOVERY_COMPLETE.(often 0x01、0x02、0x010A)

    But in the nRF Connect APP , I can receive data when I click the blue mark.

    Look forward to your reply

  • Hi 

    There are many service in the BLE peripheral device. The BLE peripheral UUID I can get from nRF Connect APP, see the picture below please.

    The blue mark (fee8) is the UUID I can discovery . The red mark (fee9) is the UUID I want to discovery , but failed.The way I used to discovery the two uuid(fee8 and fee9) is the same(Like the init function above).

    In the nRF Connect APP ,when I click the yellow mark, I can receive the data I want.

  • That´s not what I´m asking. I´m asking if you're also trying to discover other services in your central application. And how are you starting the discovery in your central application?

  • The 0xfee9 service UUID is the only service I want to discovery. I had discovery other services successful.

    This is the code I used to discovery in my central application , this is in the ble_evt_handler() function:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    I am making changes based on ble_app_uart_c project.
  • I found I can't insert the code success, let me try again:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    case BLE_GAP_EVT_CONNECTED:
    {
    ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
    err_code = ble_nus_c_handles_assign(&m_ble_nus_c[p_gap_evt->conn_handle], p_ble_evt->evt.gap_evt.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
    // start discovery of services. The NUS Client waits for a discovery result
    err_code = ble_db_discovery_start(&m_db_disc[p_gap_evt->conn_handle], p_ble_evt->evt.gap_evt.conn_handle);
    APP_ERROR_CHECK(err_code);
    }
    break;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • HI

    When I register both 0xfee8 and 0xfee9 at the same time by ble_db_discovery_evt_register() function. The value of p_evt->evt_type is 0x01.p_evt->params.err_code is 0x0011 (NRF_ERROR_INVALID_DATA) What does this error mean?

Reply
  • HI

    When I register both 0xfee8 and 0xfee9 at the same time by ble_db_discovery_evt_register() function. The value of p_evt->evt_type is 0x01.p_evt->params.err_code is 0x0011 (NRF_ERROR_INVALID_DATA) What does this error mean?

Children
  • 0x11 isn't invalid data, it's busy. That probably means that the discovery procedure had already started or something like that. You will have to check which function exactly is returning that error.

  • This does not matter , beacuse I already know that the problem is on init function.

    What I want to know now is why I can receive data by nRF Connect APP , but when I add the same UUID to 52832 , I can't discovery it.

    Please refer to my reply above.

    Thanks

  • Can you try to discover the Generic Access Service?

    Fullscreen
    1
    2
    BLE_UUID_BLE_ASSIGN(serviceFEE9, 0x1800);
    APP_ERROR_CHECK(ble_db_discovery_evt_register(&serviceFEE9));
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    You should at least be able to discover that one. Just to check that the discovery module at least works.

  • Yes,I can discovery 0x1800(the p_evt->params.discovered_db.char_count is 5 and char uuid is 0x2axx),and the service which marked blue I can discovery too.So I think my  discovery module is work.

    But the red mark I can't discovery.

  • Can you try changing this:

    Fullscreen
    1
    2
    //ble_uuid128_t service_base_uuid = HXJ_BASE_UUID_FEE9;
    ble_uuid128_t service_base_uuid = HXJ_BASE_UUID;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I don't think it should make a difference but who knows. I can't see anything else weird with your code.