cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to a device BLE STM32WB55

BLiwa.1
Associate II

Hello guys,

I want connect to a bluetooth device from STM32WB.

I've used this function inspiered to setup the connection with the device found when scanning but it won't connect to it it always print out Connection To Slave Failed with reason 0x46 which means connection, not allowed, am i missing something here?

for info : the connection works fine when using p2p_client example

static void vConnectionRequest(eAppBleConnectionStatus __e_NewStatus)
{
	uint8_t __au8_MacAddressP2PSrv[6U]={0xE5,0xD7,0x25,0xE1,0x80,0x00};
	tBleStatus result;
 
	if (_t_BleApplicationContext.e_DeviceConnectionStatus != APP_BLE_CONNECTED_CLIENT)
	{
 
		result =  aci_gap_create_connection  (	0x320,
												0x320,
												0x00,
												__au8_MacAddressP2PSrv,
												0x00,
												40U,
												80U,
												0U,
												0x1F4,
												16U,
												16U );
 
		if (result == BLE_STATUS_SUCCESS)
		{
			_t_BleApplicationContext.e_DeviceConnectionStatus = APP_BLE_LP_CONNECTING;
			vCNSLCTRL_SendDataToOuput(true,"[BLE]     Successfully Connected to Slave\r\n");
		}
		else
		{
			vCNSLCTRL_SendDataToOuput(true,"[BLE]     Connection To Slave Failed , result: %d \r\n", result);
 
			_t_BleApplicationContext.e_DeviceConnectionStatus  = APP_BLE_IDLE;
		}
	}
	return;
}

0693W00000NrwPvQAJ.png

4 REPLIES 4
Remy ISSALYS
ST Employee

Hello,

Can you give more information about your device ?

Best Regards

Hello,

Thank you for your response, in fact it is anothr STM32WB flashed with p2p_server example it works fine with the p2p_client example, i've tried to do the sme thing on my project but it did not work the result returns always 0x46, so the connection establishment did not go throught.

Hello,

Thank you for your response, in fact it is anothr STM32WB flashed with p2p_server example it works fine with the p2p_client example, i've tried to do the sme thing on my project but it did not work the result returns always 0x46, so the connection establishment did not go throught.@Remy ISSALYS​ 

Remy ISSALYS
ST Employee

Hello,

Can you check if it's the right BD Address for p2p Server ? Ensure that your p2p server device is in advertising mode when you want to connect to it. Check your configuration in ble_conf.h file, you should have this configuration in client side:

 /**
 * This setting shall be set to '1' if the device needs to support the Peripheral Role
 * In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
 */
#define BLE_CFG_PERIPHERAL          0
 
/**
 * This setting shall be set to '1' if the device needs to support the Central Role
 * In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
 */
#define BLE_CFG_CENTRAL          1
 
/**
 * There is one handler per service enabled
 * Note: There is no handler for the Device Information Service
 *
 * This shall take into account all registered handlers
 * (from either the provided services or the custom services)
 */
#define BLE_CFG_SVC_MAX_NBR_CB          7
 
#define BLE_CFG_CLT_MAX_NBR_CB          1

Best Regards