2015-10-01 05:45 AM
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 itconnectable.
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?
2015-10-01 06:57 AM
Hi,
when you use the command aci_gap_update_adv_data you have to format the packet correctly. Please for futher details you can see in the Beacon script or IAR project. The data has be formatted in according to the spec: data = [lenData , AD_TYPE ] + data. Anyway, in your code you are defined the variableadv_data
while after you use data. Regards, GM2015-10-01 07:26 AM
I did asin the demo
uint32_t BLUENRG_DataUpdate(void)
{
tBleStatus ret=0;
uint8_t manuf_data[] = {6, AD_TYPE_MANUFACTURER_SPECIFIC_DATA,
0xAA,
0x00,
0x00,
0x00,
0xBB
};
//for debug
manuf_data[4] = idx++;
ret = aci_gap_update_adv_data(7, manuf_data);
if (ret != BLE_STATUS_SUCCESS)
{
return BLE_STATUS_ERROR ;
}
return BLE_STATUS_SUCCESS;
}
I see the same data - no update 06 FF AA 00 01 00 BB
2015-10-01 07:47 AM
have you defined the variable idx ?
2015-10-01 07:52 AM
2015-10-02 02:52 AM
Hi,
in attach you can find a script that should simulate your scenario. To run it, you should: - Launch an instance of GUI DK 1.8.0 - open the COM PORT related to the device - Goto Scripts tab - select the script file and run it Wtih sniffer , you should see that each 4 second the ADV packet is updated. Regards, GM2015-10-03 11:29 PM
I found the problem (I guess). Pin interrupt request has
HCI_Isr()
routine in it. But somehow it doesn’t processed right. So I added in the main routine.
if (BlueNRG_DataPresent())
{
HCI_Isr()
; }2015-10-05 01:07 AM
You could see the IAR project under folder:
C:\Program Files (x86)\STMicroelectronics\BlueNRG DK 1.8.0\Projects\Projects_STD_Library\BLE_Beacon and modify it in according to the script. Regards, GM2015-10-05 02:17 AM
Thank you.