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

Connecting a peripheral device to a central device

Hi, I am trying to connect a peripheral device which in this case is a BLE device called DELTA and I am trying to connect it to a central device which is the NRF52 board. However, I am not successful because they are not connected to each other somehow, even though I put the correct UUID in the I used the ble_uart_c example that was provided on the Nordic website and changed the default base UUID, BLE_UUID_NUS_SERVICE, and the BLE_UUID_NUS_TX_CHARACTERISTIC from the ble_nus_c. I put 0x2902 because that was the UUID under the longer version of the UUID. Is this how to properly set up the UUID in the code listed below?

The UUID for the peripheral device is c1d0f554-a142-4b56-b02d-2bc23da2df50

This is what I have for the connection. Any help will be appreciated :)

#define NUS_BASE_UUID                  {{0xC1, 0xD0, 0xF5, 0x54, 0xA1, 0x42, 0x4B, 0x56, 0xB0, 0x2D, 0x2B, 0xC2, 0x3D, 0xA2, 0xDF, 0x50}} /**< Used vendor specific UUID. */
#define BLE_UUID_NUS_SERVICE           0x2902                 
#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x2A4B                      /**< The UUID of the TX Characteristic. */
#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0001                     /**< The UUID of the RX Characteristic. */

UPDATE:

I think I got the issue with the UUID. However I am not sure, if I am doing the array in the method static bool is_uuid_present(const ble_uuid_t *p_target_uuid, const ble_gap_evt_adv_report_t *p_adv_report) correctly.

I know it is the 128 bit service that has to be executed,

if ( (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE) || (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE) ) { err_code = sd_ble_uuid_decode(UUID128_SIZE, &p_data[index], &extracted_uuid); if (err_code == NRF_SUCCESS) { if ((extracted_uuid.uuid == p_target_uuid->uuid) && (extracted_uuid.type == p_target_uuid->type)) { return true; } } } index += field_length + 1; }

However, the extracted uuid is different from the target uuid when debugging. Is there a problem with that?

  • I have been trying to debug for a while by following the guide and the while debugging and stepping through it skips through the softdevice part, do you think wrong version of softdevice could cause this?

  • What you mean by "softdevice part"? What SDK version and SoftDevice version are you using?

  • I am using softdevice 132 and the SDK version is nRF5_SDK_12.1.0_0d23e2a. So when I first started debugging, it placed a break point through (is_uuid_present(&m_nus_uuid, p_adv_report)). Then after that when stepping through, it goes to the method, is_uuid_present and successfully matches the UUID. However, I though that it would go through the BLE_GAP_EVT_CONNNECTED which is when the NRF52 board would be solid, but it is just blinking every 4 seconds and displaying the loop.

  • Actually please ignore my last comment. I found the error location, but it does not let me add a breakpoint here?

    // The following variable helps Keil keep the call stack visible, in addition, it can be set to
    // 0 in the debugger to continue executing code after the error check.
    volatile bool loop = true;
    UNUSED_VARIABLE(loop);
    
    m_error_data.fault_id   = id;
    m_error_data.pc         = pc;
    m_error_data.error_info = info;
    
    switch (id)
    {
        case NRF_FAULT_ID_SDK_ASSERT:
            m_error_data.p_assert_info = (assert_info_t *)info;
            m_error_data.line_num      = m_error_data.p_assert_info->line_num;
            m_error_data.p_file_name   = m_error_data.p_assert_info->p_file_name;
            break;
    
        case NRF_FAULT_ID_SDK_ERROR:
            m_error_data.p_error_info = (error_info_t *)info;
            m_error_data.err_code     = m_error_data.p_error_info->err_code;
            m_error_data.line_num     = m_error_data.p_error_info->line_num;
            m_error_data.p_file_name  = m_error_data.p_error_info->p_file_name;
            break;
    }
    
    UNUSED_VARIABLE(m_error_data);
    
    // If printing is disrupted, remove the irq calls, or set the loop variable to 0 in the debugger.
    __disable_irq();
    while (loop);
    
    __enable_irq();
    

    }

Related