cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB BLE - On 2 master connections, how can I distinguish between them?

DS.4
Senior II

My device is the slave, that is being connected (not always in the same order) by 2 masters.

I would like to create two different connection ways/points to distinguish between the masters.

MASTER1 will always connect through "way1."

MASTER 2 will always connect through "way2."

And I could map the connection handles according to the way they connected.

What could "way1" and "way2" be?

I was thinking about changing the MAC address/Name I am advertising periodically, by that creating 2 connection points.

First master will always connect through MAC1/NAME1.

Second master will always connect via MAC2/NAME2.

Is it possible? Could I know upon connection through what MAC#/NAME# they've connected?

Is there another way?

Thanks.

2 REPLIES 2
Remi QUINTIN
ST Employee

Each device you are connected with is identified by a connection handle.

This connection handle is returned in the connection_complete_event once the connection is established.

The peer device address is part of the connection_complete_event.

Its structure is the following:

typedef PACKED(struct)

{

 uint8_t Status;

 uint16_t Connection_Handle;

 uint8_t Role;

 uint8_t Peer_Address_Type;

 uint8_t Peer_Address[6];

 uint16_t Conn_Interval;

 uint16_t Conn_Latency;

 uint16_t Supervision_Timeout;

 uint8_t Master_Clock_Accuracy;

} hci_le_connection_complete_event_rp0;

Then it is up to you to create your own structure associating the name of the device, its address and its connection handle.

DS.4
Senior II

Thanks.

Does hci_le_connection_complete_event_rp0 or some other packet hold the initial connection request of the master?

I want to know more on how the master is trying to connect.

e.g. Through which MAC address/NAME of device.

Or when a master reads/writes, where can I find the destination MAC address/NAME .

I looked at all the HCI events. ( https://lisha.ufsc.br/teaching/shi/ine5346-2003-1/work/bluetooth/hci_commands.html )

I saw that Connection_Request_Event might hold the data I need.

Can you tell me more on this event? I can't find it or its packet in code.