Hello,
we are using the DA14580 with the SDK 5.0.4.
We can connect any Smartphone as Central device with the DA14580 as Peripheral device.
We would like to store the Smartphone Hardware ID ("MAC"-Address) in our module to differentiate between known and unknown Smartphones.
The idea was:
- Pairing mode is "Just works" since there is no possibility for key exchange.
- let the central device do the connection
- check the central device 6-byte-address in the DA14580
- disconnect if central device not known
This works fine for Android phones which send a fixed 6-byte address with the connection request (newer Android versions may change the address, too).
But with iPhones the adress changes over time and the identification fails.
as I have figured out so far, the connection request is processed in the SDK in the following method:
void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) { ... }
which receives a information struct as follows:
struct gapc_connection_req_ind {
uint16_t conhdl; /// Connection handle
uint16_t con_interval; /// Connection interval
uint16_t con_latency; /// Connection latency
uint16_t sup_to; /// Link supervision timeout
uint8_t clk_accuracy; /// Clock accuracy
uint8_t peer_addr_type; /// Peer address type
struct bd_addr peer_addr; /// Peer BT address
};
with the peer address being the 6 byte address sent by the connecting Smartphone.
So this address is the only data we can "work with" in our code.
问题是:
- is it right that the DA14580 gets only the 6-byte peer_addr as information when receiving a connection request? Or is there more to work with?
- Peer address types may be "public" or "private random"?
- what is the recommended way to identify a Central device (Smartphone) which changes the address over time?
Hi Steffen T,
1) Yes, when the connection callback gets invoked the peer address of the other device is available on the callback.
2) The address of the devices accoring to the BLE spec can be either public or random and the random addresses divide to Non-Resolvable and Resolvable.
3) From the android version 5.0 (if i remember correctly) and an on, none of phones are using a standard address and the same applies for the iOS devices, you cant identify a device by its bd address, offcouse there are the resolvable bd addresses but those addresses require the pairing procedure since through that procedure they can obtain the IRK key in order to resolve the address and that applies to the central since first is going to resolve the bd address of the peripheral and then will send a connection command.
Thanks MT_dialog
I'd suggest that you during the pairing process request the master to send its IRK. You don't have to send your own IRK if you intend to simply stick with a public address.
Store the IRK somewhere and once a connection request comes, you use the GAPM_RESOLV_ADDR_CMD command to see if it matches the IRK you have stored.