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

Scan advertising Sensor

Hello,

Ive got an question of my Central BLE nRF54280 Dongle. I want to read the advertising packets of Sensors with the Name "RH". Shouldnt be a big problem. But i got problems of the understanding to do it. I have to initialize the scan and filter the devices for the Name "RH". Does this work? Or do i have to filter all advertising packets for the Name "RH"? Then I would start the scan.  In the Scan Event handler I would wait till "NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT". In there i can read the advertising packet via nrf_ble_scan_t Struct and can search the buffer for 0xFF which should be the manufacturer specific data. Am I right?

static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;
    uint16_t position = 0;
    switch(p_scan_evt->scan_evt_id)
    {
        case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:
        {
            NRF_LOG_INFO("Scan timed out.");
            scan_start();
        } break;

        case NRF_BLE_SCAN_EVT_FILTER_MATCH:
            break;
        case NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT:
            break;
        case NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:
          //Searching Advertise Packet for Manufacturer Specific Data
          ble_advdata_search(&m_scan.scan_buffer.p_data, &m_scan.scan_buffer.len, 0, 0xFF);

Do I also have to init a BLE stack or something else? I dont want to connect to devices. I just want to read the advertising packets and therefore the manufacturer specific data from my Sensors with the Name "RH". 

Greetings 

Marcel

Related