AnsweredAssumed Answered

MKW41z BLE  not working after enabling random address and pairing.

Question asked by rahul singh on Mar 28, 2020
Latest reply on May 11, 2020 by Mario Ignacio Castaneda Lopez

I am using MKW41Z with connectivity software.
I created a custom application based on the provided examples and able to run it successfully with a custom android application acting as a client.

But the issue I am facing is that when I set the address type as Random instead of the public and enable pairing my android application instantly disconnects after connecting.

Code snippet for the same:

gapAdvertisingParameters_t gAdvParams = {
/* minInterval */ gGapAdvertisingIntervalRangeMinimum_c,
/* maxInterval */ gGapAdvertisingIntervalRangeMinimum_c,
/* advertisingType */ gAdvConnectableUndirected_c,
/* addressType */ gBleAddrTypeRandom_c,// gBleAddrTypeRandom_c, TODO
/* directedAddressType */ gBleAddrTypeRandom_c,
/* directedAddress */ {0, 0, 0, 0, 0, 0},
/* channelMap */ (gapAdvertisingChannelMapFlags_t) (gGapAdvertisingChannelMapDefault_c),
/* filterPolicy */ gProcessAll_c
};

gapPairingParameters_t gPairingParameters = {
.withBonding = gAppUseBonding_d,
.securityModeAndLevel = gSecurityMode_1_Level_3_c,
.maxEncryptionKeySize = mcEncryptionKeySize_c,
.localIoCapabilities = gIoDisplayOnly_c,
.oobAvailable = FALSE,
.centralKeys = gIrk_c,
.peripheralKeys = (gapSmpKeyFlags_t)(gLtk_c | gIrk_c),
.leSecureConnectionSupported = TRUE,
.useKeypressNotifications = FALSE,
};

I have enabled macros gAppUsePairing_d and gAppUseBonding_d.

The same process works fine when I sat the structure for advertisement like this:

gapAdvertisingParameters_t gAdvParams = {
/* minInterval */ gGapAdvertisingIntervalRangeMinimum_c,
/* maxInterval */ gGapAdvertisingIntervalRangeMinimum_c,
/* advertisingType */ gAdvConnectableUndirected_c,
/* addressType */ gBleAddrTypePublic_c,// gBleAddrTypeRandom_c, TODO
/* directedAddressType */ gBleAddrTypePublic_c,
/* directedAddress */ {0, 0, 0, 0, 0, 0},
/* channelMap */ (gapAdvertisingChannelMapFlags_t) (gGapAdvertisingChannelMapDefault_c),
/* filterPolicy */ gProcessAll_c
};

But I need to generate random mac addresses for different boards.

In short :

Random MAC address + Pairing = Not working

Public address + pairing = working

Can anyone help me to get around this?

Thanks in advance.

Outcomes