2020-09-19 01:49 AM
Hello everybody
I'm using a custom board in which there's a STM32F030 that communicate with SPBTLE_RF0 module. With X-CUBE I generate software using X-CUBE-BLE2.2.0.0.
I can reset the chip and read response (vendor specific event), but when I try to configure the chip using pre-compiled software, I've noticed that immediately, at the first HCI command, I can't have response from the module.
The first command after reset and after delay of 2000ms, is HCI_LE_RAND. I send the information on SPI but module doesn't take IRQ line high to tell uC that the response is ready.
I can't understand why module doesn't answer.
I use 1.8Mhz SPI communication, but I've tried 400KHz also.
In my application I can't use SPI directly, and I use a I2C/SPI bridge. I've changed original software to work with this bridge, and as I said previously, I can send hci_reset command and read response, and I see IRQ line go high in this case.
I've checked documentation on ST site, but I did not find that module, maybe, doesn't accept some kind of hci commands. After rest the initialisation process, procedure involves sending some configuration commands as below:
/* Sw reset of the device */
hci_reset();
/**
* To support both the BlueNRG-2 and the BlueNRG-2N a minimum delay of 2000ms is required at device boot
*/
HAL_Delay(2000);
/* Setup the device address */
Setup_DeviceAddress();
/* Set the TX power to -2 dBm */
aci_hal_set_tx_power_level(1, 4);
/* GATT Init */
ret = aci_gatt_init();
if(ret != BLE_STATUS_SUCCESS)
{
PRINT_DBG("GATT_Init failed: 0x%02x\r\n", ret);
return ret;
}
/* GAP Init */
ret = aci_gap_init(GAP_CENTRAL_ROLE|GAP_PERIPHERAL_ROLE,0x0,0x07, &service_handle,
&dev_name_char_handle, &appearance_char_handle);
if(ret != BLE_STATUS_SUCCESS)
{
PRINT_DBG("GAP_Init failed: 0x%02x\r\n", ret);
return ret;
}
/* Add Device Service & Characteristics */
ret = Add_Sample_Service();
if(ret != BLE_STATUS_SUCCESS)
{
PRINT_DBG("Error while adding service: 0x%02x\r\n", ret);
return ret;
}
/* Reset the discovery context */
Reset_DiscoveryContext();
return BLE_STATUS_SUCCESS;
where Setup_DeviceAddress() is as below:
static void Setup_DeviceAddress(void)
{
tBleStatus ret;
uint8_t bdaddr[] = {0x00, 0x00, 0x00, 0xE1, 0x80, 0x02};
uint8_t random_number[8];
/* get a random number from BlueNRG */
ret = hci_le_rand(random_number);
if(ret != BLE_STATUS_SUCCESS)
{
PRINT_DBG("hci_le_rand() call failed: 0x%02x\r\n", ret);
}
discovery_time = 3000; /* at least 3 seconds */
/* setup discovery time with random number */
for (uint8_t i=0; i<8; i++)
{
discovery_time += (2*random_number[i]);
}
/* Setup last 3 bytes of public address with random number */
bdaddr[0] = (uint8_t) (random_number[0]);
bdaddr[1] = (uint8_t) (random_number[3]);
bdaddr[2] = (uint8_t) (random_number[6]);
ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, bdaddr);
if(ret != BLE_STATUS_SUCCESS)
{
PRINT_DBG("Setting BD_ADDR failed 0x%02x\r\n", ret);
}
else
{
PRINT_DBG("Public address: ");
for (uint8_t i=5; i>0; i--)
{
PRINT_DBG("%02X-", bdaddr[i]);
}
PRINT_DBG("%02X\r\n", bdaddr[0]);
}
}
I've tried to bypass hci_le_rand, and to jump directly to aci_hal_write_config_data, but I've obtained the same behaviour, and the module doesn't answer.
I continuosly poll the device and it answer always with header.
Has anybody experienced a similar behaviour?
Thanks in advance.
Roberto
2022-12-21 11:41 PM
hi, @Roberto Giovinetti did you resolved the issue ? if yes then can you please help me out with bnrg2a1. here below is are the errors im attaching.
2022-12-21 11:52 PM
Hi @satyam9896
I can't help you: Unfortunately, this project was abandoned and I no longer pursued the development.
I am sorry I cannot be of any help.
Roberto
2022-12-22 03:34 AM
ok thanks for your time.