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

nRF Connect log

Hi,

I'm testing heart rate measurement example with my nRF52 DK. In the nRF connect application, I see the logs are converted from Hexadecimal value to user-readable values. I want to implement this in my own project with accelerometer values. In the accelerometer project, I only see values in hexadecimal. Thank you for your time and information. 

  • Yes, I did. 

    static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
    {
    ble_acl_on_db_disc_evt(&m_acl_c, p_evt);
    }

    I followed this tutorial How to build the simple nrf52 BLE central. I will attach the code blocks of  service initialisation and database discovery event below, please check them.

    uint32_t ble_acl_c_init(ble_acl_c_t * p_ble_acl_c, ble_acl_c_init_t * p_ble_acl_c_init)
    {
        VERIFY_PARAM_NOT_NULL(p_ble_acl_c);
        VERIFY_PARAM_NOT_NULL(p_ble_acl_c_init);
        VERIFY_PARAM_NOT_NULL(p_ble_acl_c_init->evt_handler);
    
        uint32_t      err_code;
        ble_uuid_t    acl_uuid;
        ble_uuid128_t acl_service_base_uuid = {BLE_UUID_OUR_BASE_UUID};
    
        acl_uuid.type = p_ble_acl_c->uuid_type;
        acl_uuid.uuid = BLE_UUID_OUR_SERVICE;
    
        p_ble_acl_c->evt_handler                 = p_ble_acl_c_init->evt_handler;
        p_ble_acl_c->error_handler               = p_ble_acl_c_init->error_handler;
        p_ble_acl_c->p_gatt_queue                = p_ble_acl_c_init->p_gatt_queue;
        p_ble_acl_c->conn_handle                 = BLE_CONN_HANDLE_INVALID;
        p_ble_acl_c->peer_acl_db.acl_cccd_handle = BLE_GATT_HANDLE_INVALID;
        p_ble_acl_c->peer_acl_db.acl_handle      = BLE_GATT_HANDLE_INVALID;
    
        err_code = sd_ble_uuid_vs_add(&acl_service_base_uuid, &p_ble_acl_c->uuid_type);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        VERIFY_SUCCESS(err_code);
        
        return ble_db_discovery_evt_register(&acl_uuid);
    }

    void ble_acl_on_db_disc_evt(ble_acl_c_t * p_ble_acl_c, const ble_db_discovery_evt_t * p_evt)
    {
        // Check if the Heart Rate Service was discovered.
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE &&
            p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_OUR_SERVICE &&
            p_evt->params.discovered_db.srv_uuid.type == p_ble_acl_c->uuid_type)
        {
            // Find the CCCD Handle of the Heart Rate Measurement characteristic.
            uint32_t i;
    
            ble_acl_c_evt_t evt;
    
            evt.evt_type    = BLE_ACL_C_EVT_DISCOVERY_COMPLETE;
            evt.conn_handle = p_evt->conn_handle;
    
    
            for (uint32_t i = 0; i < p_evt->params.discovered_db.char_count; i++)
            {
                const ble_gatt_db_char_t * p_char = &(p_evt->params.discovered_db.charateristics[i]);
                switch (p_char->characteristic.uuid.uuid)
                {
                    case BLE_UUID_OUR_CHARACTERISTC_UUID:
                        evt.params.peer_db.acl_cccd_handle = p_char->cccd_handle;
                        evt.params.peer_db.acl_handle      = p_char->characteristic.handle_value;
                        break;
                    default:
                        break;
                }
            }
    
            NRF_LOG_DEBUG("Accelerometer Service discovered at peer.");
            //If the instance has been assigned prior to db_discovery, assign the db_handles.
            if (p_ble_acl_c->conn_handle != BLE_CONN_HANDLE_INVALID)
            {
                if (p_ble_acl_c->peer_acl_db.acl_handle == BLE_GATT_HANDLE_INVALID)
                {
                    p_ble_acl_c->peer_acl_db = evt.params.peer_db;
                }
            }
    
            p_ble_acl_c->evt_handler(p_ble_acl_c, &evt);
        }
    }

    If you need additional details, I can give you. And one more question, while programming our own service in peripheral, we mention the UUID is vendor-specific using BLE_UUID_TYPE_VENDOR_BEGIN, but in central, the tutorial didn't mention it anywhere. I doubt if that could be the problem. 

    Thank you.

  • <debug> ble_db_disc: Starting discovery of service with UUID 0xABCD on connection handle 0x0

    From my error message, I can see the central is looking for service with UUID 0xABCD. Also to make sure, my peripheral is also advertising 128-bit base UUID with service ABCE in it. 

    I don't understand what is creating the error.

    <error> nrf_ble_gq: SD GATT procedure (2) failed on connection handle 0 with error: 0x00000007.
  • Problem fixed. The service declaration in central and peripheral were bit different, I changed it. Now it can connects and identify the service.

    <info> app: Connected.
    <debug> nrf_ble_gq: Registering connection handle: 0x0000
    <debug> ble_db_disc: Starting discovery of service with UUID 0xABCD on connection handle 0x0.
    <debug> nrf_ble_gq: Adding item to the request queue
    <debug> nrf_ble_gq: GATTC Primary Services Discovery Request
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted again later.
    <debug> nrf_ble_gq: Processing the request queue...
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted again later.
    <debug> nrf_sdh_ble: BLE event: 0x3A.
    <debug> nrf_ble_gatt: ATT MTU updated to 23 bytes on connection 0x0 (response).
    <info> app: GATT ATT MTU on connection 0x0 changed to 23.
    <debug> nrf_ble_gq: Processing the request queue...
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    <debug> nrf_ble_gq: SD GATT procedure (2) succeeded on connection handle: 0.
    <debug> nrf_sdh_ble: BLE event: 0x24.
    <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 27
    <debug> nrf_ble_gatt: max_rx_time: 2120
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <info> app: Data length for connection 0x0 updated to 27.
    <debug> nrf_sdh_ble: BLE event: 0x30.
    <debug> ble_db_disc: Found service UUID 0xABCD.
    <debug> nrf_ble_gq: Adding item to the request queue
    <debug> nrf_ble_gq: GATTC Characteristic Discovery Request
    <debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.
    <debug> nrf_ble_gq: Processing the request queue...
    <debug> nrf_sdh_ble: BLE event: 0x32.
    <debug> nrf_ble_gq: Adding item to the request queue
    <debug> nrf_ble_gq: GATTC Characteristic Discovery Request
    <debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.
    <debug> nrf_ble_gq: Processing the request queue...
    <debug> nrf_sdh_ble: BLE event: 0x32.
    <debug> nrf_ble_gq: Adding item to the request queue
    <debug> nrf_ble_gq: GATTC Characteristic Descriptor Request
    <debug> nrf_ble_gq: SD GATT procedure (4) succeeded on connection handle: 0.
    <debug> nrf_ble_gq: Processing the request queue...

    But still, I can not see the data. Can you suggest what could possibly be the problem?

  • Hi

    Glad you got the connection and service discovery working correctly! So you're still seeing the values read from the peripheral device in hexadecimal values, correct? You still need to process the data received and output it in a readable way.

    Best regards,

    Simon

  • So you're still seeing the values read from the peripheral device in hexadecimal values, correct?

    No, I can not see the value from the peripheral. I have shared the debugger log above. As you can see there are no values in the log.

Related