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

Scan for estimote beacons

Hi,

I have 3 estimote beacons which I want to scan using nrF52833 and display scan response data on Segger RTT viewer and I don't want to establish the connection between them.

I have referred ble_app_beacon example but it seems that it does not scan for the beacon device instead nrf52 dev kit acts as a transmitter.

Lastly I want to make beacons as a transmitter and nrF52 kit as receiver (scanner).

How can I do it ? is there any specific example for this?

Parents
  • Hello,

    I have referred ble_app_beacon example but it seems that it does not scan for the beacon device instead nrf52 dev kit acts as a transmitter.

    The ble_app_beacon example sets up the device to send non-connectable advertisements, with an empty scan response(see the line m_adv_data.scan_rsps_data.p_data = NULL). Therefore, you will need to modify the beacon example to reflect this change.

    I have referred ble_app_beacon example but it seems that it does not scan for the beacon device instead nrf52 dev kit acts as a transmitter.

    Yes, the ble_app_beacon example does not scan for other beacons, since it is a peripheral device. If you would like each beacon to do scanning as well, I suggest taking a look at the answer provided by my colleague in this ticket. The answer is old - for an older SDK version and different device - but the multirole approach using the timeslot API is still what you would need to do to achieve this.

    To read scan response data as a central device, you will need to implement a scan_evt_handler to process the scan responses you receive.
    To implement this, you will need to use the Scanner Module API. You may also find this ticket useful to have a look at.
    There is not example that particularly demonstrates this, but the configuration and use of scanning in general(without processing of scan response data) is demonstrated in most of the ble central examples, such as the BLE central multilink example or the BLE central uart example.

    Please do not hesitate to ask if things should still be unclear, or if you encounter any more questions!

    Best regards,
    Karl

  • I used BLE central multilink example to scan for beacons using 16bit service UUID.

    I can scan for beacons device without forming any connection between them. But I am not able to differentiate the RSSI values coming from 4 beacons.

    Is there any event in scan_evt_handler that I will give me RSSI values of each beacons? or any other solution would you like to suggest?

    I just want to get RSSI values of each and every beacons present in the room.

    Please refer my code:- 

    #define Target_uuid  0xFE9A ( 16bit service UUID)



    /**@brief Function for initializing the scanning and setting the filters.
     */
    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; // if this true then it connects to device
        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);
    
        ble_uuid_t uuid =
        {
            .uuid = Target_uuid,
            .type = BLE_UUID_TYPE_BLE,
        };
    
    
      if (is_connect_per_uuid)
      {
           err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER,&uuid);
            NRF_LOG_INFO("Connecting as per uuid");
           if (err_code != NRF_SUCCESS) 
           {
              NRF_LOG_INFO("error-%d",err_code); // if prints 7 means NRF_ERROR_INVALID_PARAM
           }
           APP_ERROR_CHECK(err_code);
          
      }
    
     else if  (is_connect_per_name)
      {
            err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER,m_target_periph_name);
            NRF_LOG_INFO("Connecting as per name");
            if (err_code != NRF_SUCCESS) 
             {
                NRF_LOG_INFO("error-%d",err_code); // if prints 7 means NRF_ERROR_INVALID_PARAM
             }
          APP_ERROR_CHECK(err_code);
            
      }
        else if (is_connect_per_addr)
     {
            err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr.addr);
             NRF_LOG_INFO("Connecting as per given address");
            if (err_code != NRF_SUCCESS) 
             {
                NRF_LOG_INFO("error-%d",err_code); // if prints 7 means NRF_ERROR_INVALID_PARAM
             }
           APP_ERROR_CHECK(err_code);
             
     }
    
      err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ALL_FILTER, false);
       if (err_code == NRF_SUCCESS)
       {
          NRF_LOG_INFO("Filtering enabled successfully");
       }
       else
       {
          NRF_LOG_INFO("Filter error- %d",err_code);
    
       }
        APP_ERROR_CHECK(err_code);
    }
    

    and inside My scan_evt handler function, I used NRF_SCAN_EVT_FILTER_MATCH event to get the RSSI values.

    case NRF_BLE_SCAN_EVT_FILTER_MATCH:
            {
              int rssi_value = p_scan_evt->params.filter_match.p_adv_report->rssi;
              
                NRF_LOG_INFO("RSSI: %d", rssi_value);
              
              break;
              }
    
  • Hello,

    Skrillex said:
    But I am not able to differentiate the RSSI values coming from 4 beacons.
    Skrillex said:
    Is there any event in scan_evt_handler that I will give me RSSI values of each beacons? or any other solution would you like to suggest?

    From looking at the code you have provided, your general approach seems correct.
    Could you elaborate on what you are seeing - what happens when you run this code with a nearby beacon? What outputs do you get, and how does it differ from what you had expected?
    For example, are you not seeing the last NRF_LOG_INFO statement, with RSSI value? Could it then be that you are never getting a filter match in the first place? If so, what other scan events are you getting instead?
    To check if your filtering is the problem, you can disable it and see if you are able to receive the RSSI of unfiltered advertisements. Then you may begin to filter the different sources.

    As a side note, you might also want to log the major and minor of the beacon the RSSI came from, to differentiate between the different ones.

    Looking forward to resolving this issue together,

    Best regards,
    Karl 

  • Hi,

    This is what I can see after running the script.

    I just want to differentiate the RSSI values according to each and every beacon.

    Right now, after filtering I am getting the RSSI values but I am not able to differentiate RSSI values.

    I want something like 

    Beacon-1 RSSI- -53dbm

    Beacon - 2 RSSI - 50dbm etc

    Just let me know how we can differentiate the RSSI using minor and major values of beacons.

Reply
  • Hi,

    This is what I can see after running the script.

    I just want to differentiate the RSSI values according to each and every beacon.

    Right now, after filtering I am getting the RSSI values but I am not able to differentiate RSSI values.

    I want something like 

    Beacon-1 RSSI- -53dbm

    Beacon - 2 RSSI - 50dbm etc

    Just let me know how we can differentiate the RSSI using minor and major values of beacons.

Children
  • Hello,

    Skrillex said:
    This is what I can see after running the script.

    Great! I am glad you were able to retrieve the RSSI values.

    Skrillex said:
    Just let me know how we can differentiate the RSSI using minor and major values of beacons.

    You could change the major/minor value of each beacon, and then differentiate by their values.
    Alternatively, you may differentiate their peer address, which is available if you are not broadcasting as anonymous.

    Best regards,
    Karl

Related