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

Setting up the Scan Module for custom UUID's

A little backgroud for my project. The goal of the project is to be able to identify the proximity of beaconing devices in an area to a specific observer which then reports that device data such as name or some other identification back to a multilink central which processes the information and displays it on an LCD screen. Right now I am creating a custom service to do this and at the moment I am on the peripherial service side of things. The service is being tested in the template example for the S132 soft device.

The problem I am running into is with the nrf_ble_scan module. I have been able to implement it to scan and match for a specific device name, which for testing is just the ble blinky example. I want to scan for the UUID of this service (LBS button service)  but I cannot get it to filter match. I have already looked at the ble_app_uart_c example for this and saw how they implimented service scanning. Below is how I have the filter setting for the module

//filter creation of custom UUID's
static ble_uuid_t const m_beacon_uuid = 
{
  .uuid = BLE_BEACON_TRACKER_UUID,
  .type = BLE_UUID_TYPE_VENDOR_BEGIN
};

BLE_BEACON_TRACKER_UUID is set to 0x1523 which is the UUID of the LBS button service for the blinky example.

//function for developing the scanning functionality of the lighthouse
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 = false;
    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);


    // Setting filters for scanning.
    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, &m_beacon_uuid);
    APP_ERROR_CHECK(err_code);
}

Scan event handler

//scanning functionality for the lighthouse
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;
    int rx_rssi;
    switch(p_scan_evt->scan_evt_id)
    {
        case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
            err_code = p_scan_evt->params.connecting_err.err_code;
            APP_ERROR_CHECK(err_code);
            break;
        case NRF_BLE_SCAN_EVT_FILTER_MATCH:
          rx_rssi = p_scan_evt -> params.p_not_found-> rssi;
          NRF_LOG_INFO("device detected, RSSI %d", rx_rssi);
          break;
        default:
          break;
    }
}

I have already been in the sdk config and have set NRF_BLE_SCAN_UUID_CNT to 1. Is this all I should have to do or is there something I am missing something? All of the central examples use the sd_ble_uuid_vs_add() function to add there peripherial's UUID to a reference table? (not really sure what it does). Does this allow the scanning module to pick up those UUID's?

Thank you for any help you can provide. If you need more code please let me know

Sincerely,

Ben

SDK version 17.0.2

IDE: Segger Embedded Studio

Hardware: nrf52 DK with nRF52832 soc

OS: Windows

Soft Device: S132 7.2.0

Related