This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541 problem with GATT_PERMIT_AUTHEN_WRITE when device is already paired.

Other Parts Discussed in Thread: CC2541

Good morning everyone.

It is my first project with ble and CC2541. Most of features are already implemented, but I have problemwith characteristic which is set as PERMIT_AUTHEN_WRITE:


... // Characteristic1 Value { { ATT_BT_UUID_SIZE, LockeProfileCharacteristic1_UUID }, GATT_PERMIT_AUTHEN_WRITE, 0, &lockeCh1Val }, ...

Bond mgr is set as:

// Setup the GAP Bond Manager
{
uint32 passkey = 1234; // passkey "000000"
uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;
uint8 mitm = TRUE;
uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
uint8 bonding = TRUE;
GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
}


Now I have two scenarios:

Scenario1 is
when my phone is not paired before with CC:

Connect request from Android APP -> Next I have to agree for pairing and enter passcode. After entering valid passcode, I am able to see that CC2541 reaches state GAPBOND_PAIRING_STATE_BOND_SAVED.
From now i am able to write to my secured characteristic [OK]


Scenario 2, every time after scenario 1, when devices are already paired.

When I try to disconnect and connect again device is immediately switching to GAPROLE_CONNECTED and any authorization is not required [expected behavior] In that case I am not able to write to follwoing
characteristic [NOK]


Could You tell me, what I am doing wrong?
Shall I add some conditions in

static void peripheralStateNotificationCB( gaprole_States_t newState ) ... in case
GAPROLE_CONNECTED ?