MKW41z BLE not working after enabling random address and pairing.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MKW41z BLE not working after enabling random address and pairing.

3,314 次查看
rahul_singh
Contributor II

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.

0 项奖励
回复
11 回复数

3,064 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

Please look at the "\KW41_SDK\docs\wireless\Bluetooth\BLE Application Developers Guide.pdf"

4.4 Enhanced privacy feature

Could you please enable the privacy feature?

/*! Enable/disable use of privacy */
#define gAppUsePrivacy_d  1

Regards,

Mario

0 项奖励
回复

3,064 次查看
rahul_singh
Contributor II

Thanks for the reply, Mario.

I have figured the issue, That is the privacy feature is supported by BLE 4.2 but my android device has 4.0.

The code is working on another android device with BLE4.2.

Though I have a different issue now some of my notifications are working, but some notifications throw the code "gDevDbCccdNotFound" on "Gap_CheckNotificationStatus" API despite the fact I have enabled cccd on every characteristic from android.

0 项奖励
回复

3,064 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

Please let me know if you have any further questions.

Ragards,

Mario

0 项奖励
回复

3,064 次查看
rahul_singh
Contributor II

Hi Mario,

I have an issue that my notifications are not working, they are throwing the code "gDevDbCccdNotFound" on the "Gap_CheckNotificationStatus" API despite the fact I have enabled cccd on every characteristic from android.

I cannot find the appropriate solution by myself or from the internet.

0 项奖励
回复

3,064 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

I am not sure how are you implementing the custom profile in your application.

Please look at Chapter 8 Creating a Custom Profile

Look at the 7.1.4 Static GATT database definition examples that are showing an example about the Characteristic, however, you could take as reference the next community post. https://community.nxp.com/docs/DOC-332703 

Regards,

Mario

0 项奖励
回复

3,064 次查看
rahul_singh
Contributor II

Hi Mario,

Here is how I declared the custom UUID and respective gatt_db declarations.

UUID128(uuid_service_ssf_sc_ctrl_stat, 0xE0, 0x1C, 0x4B, 0x5E, 0x1E, 0xEB, 0xA1, 0x5C, 0xEE, 0xF4, 0x5E, 0xBA, 0x05, 0x01, 0xFF, 0x01)
UUID128(uuid_char_stat_lock, 0xE0, 0x1C, 0x4B, 0x5E, 0x1E, 0xEB, 0xA1, 0x5C, 0xEE, 0xF4, 0x5E, 0xBA, 0x06, 0x01, 0xFF, 0x01)
UUID128(uuid_char_stat_pollu, 0xE0, 0x1C, 0x4B, 0x5E, 0x1E, 0xEB, 0xA1, 0x5C, 0xEE, 0xF4, 0x5E, 0xBA, 0x08, 0x01, 0xFF, 0x01)

PRIMARY_SERVICE_UUID128(service_ssf_sc_ctrl_stat, uuid_service_ssf_sc_ctrl_stat)
CHARACTERISTIC_UUID128(char_stat_lock, uuid_char_stat_lock, (gGattCharPropNotify_c))
VALUE_UUID128(value_char_stat_lock, uuid_char_stat_lock, (gPermissionNone_c), 2, 0x22,0x22) // single int
CCCD(cccd_char_stat_lock)

CHARACTERISTIC_UUID128(char_stat_pollu, uuid_char_stat_pollu, (gGattCharPropNotify_c))
VALUE_UUID128(value_char_stat_pollu, uuid_char_stat_pollu, (gPermissionNone_c), 3, 0x00,0x00,0x00) // Int array of 3
CCCD(cccd_char_stat_pollu)

I do not find any issue with this when compared with the document you shared.

Though I do have all the system working fine previously then i accidentally deleted my gatt_db and gatt_uuid128 files. After making them again I'm getting this "gDevDbCccdNotFound" error.

0 项奖励
回复

3,063 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

Please look at the battery service example, see how is implementing the notification 

static void Bas_SendNotifications(  uint16_t handle)

Also please look at the event case gEvtCharacteristicCccdWritten_c that sets the notification timer depending on the profile that you want.

Regards,

Mario

0 项奖励
回复

3,063 次查看
rahul_singh
Contributor II

Hi Mario,

Is there any size limit for the GattDb. I got to a point where if I add one more characteristic is stops working.

0 项奖励
回复

3,063 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

It will depend on the memory that you are working on. But I think that you are not setting a lot of profiles.

Did you look at the Creating a custom profile using NXP BLE stack – Server?

Regards,

Mario

0 项奖励
回复

3,063 次查看
rahul_singh
Contributor II

Hi Mario,

I do get my code working by just changing the sequence of characteristic.

gatt_db.h files show weird behaviour when everything starts working when I deleted the commented code from gatt_db notification again stops working.

Do you know anything about such restrictions?

0 项奖励
回复

3,063 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Rahul,

There is no restriction. I can not be sure if you modified something by mistake, I can recommend to try with a new project and try to add again the requirements that you want.

Regards,

Mario

0 项奖励
回复