Configuring BLE Peripheral to Perform Directed Advertisement - KBA218959

Version: **

 

Question:

How do I configure a BLE peripheral to perform directed advertisement? 

 

Answer:

Configuring a BLE peripheral to perform directed advertisement is not straightforward since there is neither an option in the BLE component configuration nor any API to enable directed advertisement. However, directed advertisement can be enabled in applications by modifying the advertisement parameters in the discovery mode information.

  1. Change the advertisement type to either
      CYBLE_GAPP_CONNECTABLE_LOW_DC_DIRECTED_ADV or
      CYBLE_GAPP_CONNECTABLE_HIGH_DC_DIRECTED_ADV.  

    cyBle_discoveryModeInfo.advParam->advType = CYBLE_GAPP_CONNECTABLE_LOW_DC_DIRECTED_ADV;

  2. Set the directed device’s (central) address type and address. Set the address type to either CYBLE_GAP_ADDR_TYPE_PUBLIC or CYBLE_GAP_ADDR_TYPE_RANDOM. The example here shows a central whose public address is 0x00A05000251F, to which the peripheral will perform directed advertisement.  

    cyBle_discoveryModeInfo.advParam->directAddrType = CYBLE_GAP_ADDR_TYPE_PUBLIC;
       cyBle_discoveryModeInfo.advParam->directAddr[5] = 0x00; 
       cyBle_discoveryModeInfo.advParam->directAddr[4] = 0xA0; 
       cyBle_discoveryModeInfo.advParam->directAddr[3] = 0x50; 
       cyBle_discoveryModeInfo.advParam->directAddr[2] = 0x00; 
       cyBle_discoveryModeInfo.advParam->directAddr[1] = 0x25; 
       cyBle_discoveryModeInfo.advParam->directAddr[0] = 0x1F;

  3. Start the advertisement using the CyBle_GappStartAdvertisement() or the CyBle_GappEnterDiscoveryMode() APIs. 

Notes: 

  1. Make the changes to the advertisement parameters before starting the advertisement. It will not be effective if done after the advertisement has started. 
  2. The initial advertising type set in the BLE component configuration does not matter.