cancel
Showing results for 
Search instead for 
Did you mean: 

BLE test with the STM32U5 board

daniellages
Associate II

Hey, I'm just trying to use the BLE STM32UB5x in the board B-U585I-IOT02A. I used the following configurations for the STM32CubeProgrammer like suggested here (https://wiki.st.com/stm32mcu/wiki/Connectivity:STM32WB_BLE_Hardware_Setup)

  • SW4 OFF, SW5 ON, SW3 SYS, SW6 0
  • stm32w5x_FUS_fw.bin @ 0x080EC000
  • stm32w5x_BLE_Stack_full_fw.bin @0x080C7000
  • ble_at_server.hex

 

Then, I switch SW4 ON, SW5 OFF and added this to main.c

/* USER CODE BEGIN 0 */
static HAL_StatusTypeDef BLE_SendCmd(const char *cmd) {
	HAL_StatusTypeDef ret;
	const char crlf[] = "\r\n";
	char response[64] = {0};

	printf("Sending BLE command: %s\r\n", cmd);

	ret = HAL_UART_Transmit(&huart4, (uint8_t *)cmd, strlen(cmd), 100);
	ret |= HAL_UART_Transmit(&huart4, (uint8_t *)crlf, sizeof(crlf)-1, 100);
	if (ret != HAL_OK) {
		printf("UART transmit failed (err: %d)\r\n", ret);
		return ret;
	}

	HAL_Delay(50);
	ret = HAL_UART_Receive(&huart4, (uint8_t *)response, sizeof(response)-1, 100);
	if (ret == HAL_OK) {
		printf("BLE response: %s\r\n", response);
	} else {
		printf("No response or receive error (err: %d)\r\n", ret);
	}
	return ret;
}

static void BLE_StartAdvertising(void) {
	if (BLE_SendCmd("AT") != HAL_OK) {
		printf("BLE check failed. BLE modue may not be responsive.\r\n");
		return;
	}
	if (BLE_SendCmd("AT+BLEADVSTART") != HAL_OK) {
		printf("Failed to start BLE advertising.\r\n");
		return;
	}
	printf("BLE advertising started successfully.\r\n");
}
/* USER CODE END 0 */
/* USER CODE BEGIN 2 */
  BLE_StartAdvertising();
/* USER CODE END 2 */

 

And in the terminal I get this:

Sending BLE command: AT
No response or receive error (err: 3)
BLE check failed. BLE modue may not be responsive.

 

Any help would be appreciated, thank you!

0 REPLIES 0