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

Scan UUID increase after each scanning periods

Hi everyone,

I am using board PCA10040 v1.1.0, softdevice 13.0.0, Eclipse Oxygen. I am trying to scan my phone and communicate with it but the scaned UUID is increasing as you can see in the image below.

image description

Here is the ble_evt_handler function:

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            PrintInfo("BLE GAP event: Connected");
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            PrintInfo("BLE GAP event: Disconnected");
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            break;

        case BLE_GAP_EVT_ADV_REPORT:
        {
            // The advertisement report
            ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
            if(is_uuid_present(m_scan_uuids, p_adv_report))
            {

            }
        }
            break;

        default:
            // No implementation needed.
            break;
    }
}

The is_uuid_presentfunction is as same as the code in the "ble_app_uart_c" example, I just add below code to that:

else if (field_type == BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA)
{
    err_code = sd_ble_uuid_decode(UUID128_SIZE, &p_data[index + 2], &extracted_uuid);
    PrintDebug("err_code: %X", err_code);
    PrintInfo("Scan UUID: %X", extracted_uuid.uuid);
    if (err_code == NRF_SUCCESS)
    {
        if (   (extracted_uuid.uuid == p_target_uuid->uuid)
            && (extracted_uuid.type == p_target_uuid->type))
        {
            return true;
        }
    }
}

Could you help me please? Thanks

Parents
  • Hi,

    You are getting error code 5(NRF_ERROR_NOT_FOUND) from the function sd_ble_uuid_decode(),so that is probably what is causing this. You are not actually getting a valid UUID.

    Take a look at this post where this issue was solved.

  • It's in the ble_gap_evt_adv_report_t->peer_addr->addr.

    If we take a look at the original ble_app_uart_c code, we are first looking for the Nordic UART Service UUID, and if the UUID is found we connect. If the connect request is successful, we print the Bluetooth address of the peer device.

    Code snippet:

    case BLE_GAP_EVT_ADV_REPORT:
        {
            const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
    
            if (is_uuid_present(&m_nus_uuid, p_adv_report))
            {
    
                err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
                                              &m_scan_params,
                                              &m_connection_param,
                                              CONN_CFG_TAG);
    
                if (err_code == NRF_SUCCESS)
                {
                    // scan is automatically stopped by the connect
                    err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                    APP_ERROR_CHECK(err_code);
                    NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x\r\n",
                             p_adv_report->peer_addr.addr[0],
                             p_adv_report->peer_addr.addr[1],
                             p_adv_report->peer_addr.addr[2],
                             p_adv_report->peer_addr.addr[3],
                             p_adv_report->peer_addr.addr[4],
                             p_adv_report->peer_addr.addr[5]
                             );
                }
            }
    
Reply
  • It's in the ble_gap_evt_adv_report_t->peer_addr->addr.

    If we take a look at the original ble_app_uart_c code, we are first looking for the Nordic UART Service UUID, and if the UUID is found we connect. If the connect request is successful, we print the Bluetooth address of the peer device.

    Code snippet:

    case BLE_GAP_EVT_ADV_REPORT:
        {
            const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
    
            if (is_uuid_present(&m_nus_uuid, p_adv_report))
            {
    
                err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
                                              &m_scan_params,
                                              &m_connection_param,
                                              CONN_CFG_TAG);
    
                if (err_code == NRF_SUCCESS)
                {
                    // scan is automatically stopped by the connect
                    err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                    APP_ERROR_CHECK(err_code);
                    NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x\r\n",
                             p_adv_report->peer_addr.addr[0],
                             p_adv_report->peer_addr.addr[1],
                             p_adv_report->peer_addr.addr[2],
                             p_adv_report->peer_addr.addr[3],
                             p_adv_report->peer_addr.addr[4],
                             p_adv_report->peer_addr.addr[5]
                             );
                }
            }
    
Children
No Data
Related