AnsweredAssumed Answered

BLUENRG - Beacon mode.

Question asked by erenburg.evgeny.002 on Oct 1, 2015
Latest reply on Oct 5, 2015 by erenburg.evgeny.002

First I configure the module.


void BLUENRG_Setup(void)
{
    HCI_Init();
    BlueNRG_RST();
  
      
    Osal_MemCpy(bdaddr, SERVER_BDADDR, sizeof(SERVER_BDADDR));
      
  
    /* Configure BlueNRG address as public (its public address is used) - MAC address of the device */
    ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, bdaddr);
  
    if(ret){ /*PRINTF("Setting BD_ADDR failed.\n"); */ }
  
    /* Init BlueNRG GATT layer */
    ret = aci_gatt_init();
    if(ret){ }
  
    /* Init BlueNRG GAP layer as peripheral */ 
        ret = aci_gap_init(GAP_PERIPHERAL_ROLE, &service_handle, &dev_name_char_handle, &appearance_char_handle);
  
     if(ret != BLE_STATUS_SUCCESS){  }
  
     ret = aci_gatt_update_char_value(service_handle, dev_name_char_handle, 0,
                                        strlen(name), (uint8_t *)name);
  
       if(ret){ }
       
      ret = aci_gap_set_auth_requirement(MITM_PROTECTION_REQUIRED,
                                         OOB_AUTH_DATA_ABSENT,
                                         NULL,
                                         7,
                                         16,
                                         USE_FIXED_PIN_FOR_PAIRING,
                                         123456,
                                         BONDING);
       
  
      if (ret == BLE_STATUS_SUCCESS) { }
  
      // Set output power level
      ret = aci_hal_set_tx_power_level(1,4);
  
 }

Then I set it connectable.

 

tBleStatus ret;
  
   const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
  
   /* disable scan response */
   hci_le_set_scan_resp_data(0,NULL);
  
   ret = aci_gap_set_discoverable(ADV_NONCONN_IND, 160, 160, PUBLIC_ADDR, NO_WHITE_LIST_USE,   sizeof(local_name), local_name, 0, NULL, 0, 0);
  
   if (ret != BLE_STATUS_SUCCESS) {  }
  
   //Remove this AD type otherwise  beaconPayload exceed the maximum size
    ret = aci_gap_delete_ad_type(AD_TYPE_TX_POWER_LEVEL);
 }

And periodically change the data.

uint32_t BLUENRG_DataUpdate(void)
 {
   tBleStatus ret=0;
  
   adv_data[0] = 0xAA; //start packet
   adv_data[1] = idx++; //global variable – for debug
   adv_data[2] = 0xBB; //end packet
  
   ret = aci_gap_update_adv_data(sizeof(data), data);
  
  
   if (ret != BLE_STATUS_SUCCESS)
   {
       return BLE_STATUS_ERROR ;
   }
  
   return BLE_STATUS_SUCCESS;
 }

The problem that the Packet Sniffer sees always the same data AA 00 BB.

Why the beacon data is not updated?

Outcomes