Skip to main content
BLiwa.1
Associate II
May 11, 2022 8:52 AM UTC
Question

Connect to beacon from STM32WB

Hello guys,

I want connect to a bluetooth device/beacon from STM32WB.

I've used this function to setup the connection with the device found when scanning but it won't connect to it it always print out "[BLE]   Successfully Connected to Slave" and then directly"[BLE]   Connection To Slave Failed"

static void vConnectionRequest(eAppBleConnectionStatus __e_NewStatus)
{	 tBleStatus result;
 
	 vCNSLCTRL_SendDataToOuput(true,"[BLE] Successfully Connected to Slave\r\n");
 
	 if (_t_BleApplicationContext.e_DeviceConnectionStatus != APP_BLE_CONNECTED_CLIENT)
	 {
result = aci_gap_create_connection(0x4000, 0x4000, PUBLIC_ADDR, _au8_ScannedMacAddress, PUBLIC_ADDR, 40, 40, 0, 60, 2000 , 2000);
	 if (result == BLE_STATUS_SUCCESS)
	 {
	 	_t_BleApplicationContext.e_DeviceConnectionStatus = APP_BLE_LP_CONNECTING;
 
	 }
	 else
	 {
	 	vCNSLCTRL_SendDataToOuput(true,"[BLE] Connection To Slave Failed \r\n");
 
	 }
	 }

Did i do something wrong here?

This topic has been closed for replies.

7 replies

Andrew Neil
Super User
May 11, 2022 10:14 AM UTC

A "Beacon" usually means something that does not accept connections.

Are you sure that your "device" does actually allow connections?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
BLiwa.1
BLiwa.1Author
Associate II
May 11, 2022 10:24 AM UTC

Yes, it is a Bluetooth sensor it advertises data like a beacon it's connectable so that the user can configure it (time of advertisment, data type ...)

this is his scanned data:

[BLE]   MAC : [DD]:[34]:[02]:[07]:[54]:[E0]   RSSI= -89

[BLE]   ADV_FRAME= 2 1 6 3 3 aa fe 12 16 aa fe 21 1 f e 7 1a d 29 e 0 5 ff f2 3 f3 a7 5d 93 6e

[BLE]   Frame_Type= 0x21 : Kbeacon

[BLE]   Vbatt = 3591mV Temp = 26.5 C Hum = 41.5% X:5;Y:-14;Z:1011

Andrew Neil
Super User
May 11, 2022 11:17 AM UTC

Does it need to be in a special "configuration" mode to accept that connection?

Are you sure you have all the connections parameters correct?

Can you connect to it using other devices?

Have you contacted the device manufacturer for support?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Remy ISSALYS
ST Technical Moderator
May 18, 2022 9:53 AM UTC

Hello,

Can you check if your two devices used public address and the mac address of the device used in aci_gap_create_connection command ?

Maybe you can try to use parameters used in BLE_p2pClient for aci_gap_create_connection command.

Best Regards