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

How to create a whitelist on the Central device

I want to create a whitelist on the Central device. Because there is a lot of peripheral devices around and I just want to connect one peripheral device. First I register the address of the central device to the peripheral device. When I work with a single peripheral device and a single central device, I can send commands from the central device to the peripheral device. But when I have more than one peripheral device in the vicinity, I can not send commands to the peripheral device registered from the central device. So I decided to create whitelist on the central device to connect the peripheral device which I registered before. But I don't know how. Do you have any example? (except ble_app_hrs)

Function to start scanning code;

// Function to start scanning
void scan_start(void) {
  ble_gap_whitelist_t   whitelist;
  ble_gap_addr_t      * p_whitelist_addr[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
  ble_gap_irk_t       * p_whitelist_irk[BLE_GAP_WHITELIST_IRK_MAX_COUNT];
  uint32_t              err_code;
  uint32_t              count;    

  err_code = pstorage_access_status_get(&count);
  APP_ERROR_CHECK(err_code);

  if (count != 0)
  {
      m_memory_access_in_progress = true;
      return;
  }
	
  // Initialize whitelist parameters.
  whitelist.addr_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
  whitelist.irk_count  = 0;
  whitelist.pp_addrs   = p_whitelist_addr;
  whitelist.pp_irks    = p_whitelist_irk;

  // Request creating of whitelist.
  err_code = dm_whitelist_create(&m_dm_app_id,&whitelist);
  APP_ERROR_CHECK(err_code);
	
  if (((whitelist.addr_count == 0) && (whitelist.irk_count == 0)) ||
      (m_scan_mode != BLE_WHITELIST_SCAN)                        ||
      (m_whitelist_temporarily_disabled))
  {
      APPL_LOG("THERE IS NO WHITELIST\r\n");		//Debug Note
      // No devices in whitelist, hence non selective performed.
      m_scan_param.active       = SCAN_ACTIVE;        // Active scanning set.
      m_scan_param.selective    = SCAN_SELECTIVE;     // Selective scanning not set.
      m_scan_param.interval     = SCAN_INTERVAL;			// Scan interval.
      m_scan_param.window       = SCAN_WINDOW;  			// Scan window.
      m_scan_param.p_whitelist  = NULL;        				// No whitelist provided.
      m_scan_param.timeout      = 0x0000;       			// No timeout.
			
  }
  else
  {
      APPL_LOG("WHITELIST WAS FOUND\r\n");		//Debug Note
      // Selective scanning based on whitelist first.
      m_scan_param.active       = 1;            // Active scanning set.
      m_scan_param.selective    = 1;            // Selective scanning not set.
      m_scan_param.interval     = SCAN_INTERVAL;// Scan interval.
      m_scan_param.window       = SCAN_WINDOW;  // Scan window.
      m_scan_param.p_whitelist  = &whitelist;   // Provide whitelist.
      m_scan_param.timeout      = 0x001E;       // 30 seconds timeout.
		
      m_scan_mode = BLE_WHITELIST_SCAN;
  }

  err_code = sd_ble_gap_scan_start(&m_scan_param);
  APP_ERROR_CHECK(err_code);
}
Parents
  • According to Mr.Ulrich Myhre : If there is a lot of advertisers around, all advertising extremely fast, they might end up transmitting exactly at the same time as a connect request is being sent to another device. That will corrupt the request

    • In my opinion some signal confusion happened as Mr.Ulrich Myhre said.
    • I can not connect another peripheral
    • Central starts scanning and try to connect untill timeout.
    • If there are multiple peripheral devices around, I can not get advertising reports from peripheral. Because the central device can only scanning, it can not do anything else. If there are not many peripheral devices around, it working smoothly.

    So, If I can extract advertising report from earlier connection event and create whitelist as you said, I think All problem will be solved.

Reply
  • According to Mr.Ulrich Myhre : If there is a lot of advertisers around, all advertising extremely fast, they might end up transmitting exactly at the same time as a connect request is being sent to another device. That will corrupt the request

    • In my opinion some signal confusion happened as Mr.Ulrich Myhre said.
    • I can not connect another peripheral
    • Central starts scanning and try to connect untill timeout.
    • If there are multiple peripheral devices around, I can not get advertising reports from peripheral. Because the central device can only scanning, it can not do anything else. If there are not many peripheral devices around, it working smoothly.

    So, If I can extract advertising report from earlier connection event and create whitelist as you said, I think All problem will be solved.

Children
No Data
Related