BondedDeviceList.count!=0 only true after new bonding

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HeKa_1704711
Level 2
Level 2
First like given Welcome!

Hello

I only get BondedDeviceList.count!=0 if I store a new modul in the boundage list. I connact one moule LED turn on. I switch off . I turn on i connact the same modul LED is off. I connact an other modul LED turn on. I turn off i can connact the 2 moduls LED off if I connact a new modul LED turn ON. so the funktion CyBle_StoreBondingData should be correct save the Data. I think I forgot something to call what is updated if i find a new device but I cant find it in the instruktions.

I want to do:

if BondedDeviceList.count==0

in the modus

cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_ANY_CONN_ANY

if i found a the resiver I store it in the bounded List and change to

cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY

so that only this connection can occur.

Thanks...

BLE-4.2

Profile Role: server Gatt Server

GAP role: Peripheral

SW:

CYBLE_GAP_BONDED_DEV_ADDR_LIST_T  BondedDeviceList;

uint8 addPeripheral;

void StackEventHandler(uint32 event,void* eventparam)

{  

    switch(event) {

case CYBLE_EVT_STACK_ON:

                /*Set advertising Time out as Infinite*/

              

                CSD_Write(1);

                CPS_Write(1);

              

                CY_SET_XTND_REG32((void CYFAR *)(CYREG_BLE_BLESS_RF_CONFIG), 0x0331);

                CY_SET_XTND_REG32((void CYFAR *)(CYREG_SRSS_TST_DDFT_CTRL), 0x80000302);

    

      

                cyBle_discoveryModeInfo.advTo=0x00;

                CyBle_GapGetBondedDevicesList(&BondedDeviceList);

                if(BondedDeviceList.count!=0)

                {

                    cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY;

                    addPeripheral=FALSE;

                    cyBle_discoveryModeInfo.advParam->advType=CYBLE_GAPP_CONNECTABLE_LOW_DC_DIRECTED_ADV;

                    /*Set the type of address*/

                    cyBle_discoveryModeInfo.advParam->directAddrType=BondedDeviceList.bdAddrList->type;

                    /*Use bonded address for direct advertising*/

                    cyBle_discoveryModeInfo.advParam->directAddr[5]=BondedDeviceList.bdAddrList->bdAddr[5];

                    cyBle_discoveryModeInfo.advParam->directAddr[4]=BondedDeviceList.bdAddrList->bdAddr[4];

                    cyBle_discoveryModeInfo.advParam->directAddr[3]=BondedDeviceList.bdAddrList->bdAddr[3];

                    cyBle_discoveryModeInfo.advParam->directAddr[2]=BondedDeviceList.bdAddrList->bdAddr[2];

                    cyBle_discoveryModeInfo.advParam->directAddr[1]=BondedDeviceList.bdAddrList->bdAddr[1];

                    cyBle_discoveryModeInfo.advParam->directAddr[0]=BondedDeviceList.bdAddrList->bdAddr[0];

                }

                else

                {

                   //Connection_LED_Write(1);

                    cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_ANY_CONN_ANY;

                    addPeripheral=TRUE;

                    cyBle_discoveryModeInfo.advParam->advType=CYBLE_GAPP_CONNECTABLE_UNDIRECTED_ADV;

                }

                CyBle_GappEnterDiscoveryMode(&cyBle_discoveryModeInfo);

            break;

case CYBLE_EVT_GAP_DEVICE_CONNECTED:

                if(addPeripheral==TRUE)

                {

                    CyBle_GapGetBondedDevicesList(&BondedDeviceList);

                    if(BondedDeviceList.count==0)     

                    {

                        if((cyBle_pendingFlashWrite != 0u))

                        {

                            // Store Bonding informtation to flash

                            //TEST_OUT_Write(!TEST_OUT_Read());

                            if ( CYBLE_ERROR_OK==CyBle_StoreBondingData(0u))

                            {

                                //Bonding data stored

                                cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY;

                                addPeripheral=FALSE;

                            }

                            else

                            {

                                printf ("Bonding data storing pending\r\n");

                            }

                        }     

                    }

                }

}}

int main()

{

  

    aryStNavi[1].Softwareversion=10;

    addPeripheral=TRUE;

     CyGlobalIntEnable;

     CyBle_Start(StackEventHandler);/*Start BLE*/

for(;;)

    {

        CyBle_ProcessEvents();/*Process BLE events*/

      

        CyBle_GapGetBondedDevicesList(&BondedDeviceList);

        if(BondedDeviceList.count!=0)

        {

                  

            Connection_LED_Write(1);

        }

     }

}

0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

Please ensure that you are calling the following API in the main loop instead of inside event handler. Please note that the API CyBle_StoreBondingData(0u) should be called until the apiresult is CYBLE_ERROR_OK

apiresult = CyBle_StoreBondingData(0u);

        if ( apiresult == CYBLE_ERROR_OK)

        {

        printf("Bonding data stored\r\n");

        printf("\r\n");

}

Please find the attached project which prints the number of devices bonded after boot-up process. Please check if this is working at your side.

Thanks

Ganesh

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Ganesh,

I tried but the problem persists. Project also attached.

 

.

SW:

        if(addPeripheral==TRUE&&firstconn==1)

        {

            CyBle_GapGetBondedDevicesList(&BondedDeviceList);

            if(BondedDeviceList.count==0)      

            {

                //if((cyBle_pendingFlashWrite != 0u))

                //{

                   

                    // Store Bonding informtation to flash

                    //TEST_OUT_Write(!TEST_OUT_Read());

                    CYBLE_API_RESULT_T bleApiResult;

                    bleApiResult = CyBle_StoreBondingData(0u);

                    if ( bleApiResult == CYBLE_ERROR_OK)

                    {

                        //Bonding data stored

                        cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY;

                        addPeripheral=FALSE;

                        firstconn=0;

                        Connection_LED_Write(1);

                        //Advertising_LED_Write(1);

                    }

                    else

                    {

                        //printf ("Bonding data storing pending\r\n");

                    }

                //}      

            }

        }

0 Likes
lock attach
Attachments are accessible only for community members.

ok it work if I CyBle_StoreBondingData after i get  (BondedDeviceList.count==1)  not if it is 0. I thought count is change after CyBle_StoreBondingData. OK

So next step is to CyBle_GapRemoveBondedDevice() if a button woudl be pressed.

should be easy now but I can not do it

that's how I wanted to do it

I get an interrupt on input high.

Set RemoveBondedDevice=TRUE;

if modul connected i Disconnect with CyBle_GapDisconnect

if in main RemoveBondedDevice=TRUE und state!=CONNECTED

I call CyBle_GapGetBondedDevicesList(&BondedDeviceList);

and if count=0

I StoreBondingData with CyBle_StoreBondingData

I guess I haven't understood it yet

0 Likes

Hi,

Please try the following code once:

CYBLE_GAP_BD_ADDR_T bdAddress;

bdAddress = BondedDeviceList.bdAddrList[0];

bdAddress.type = 0x00;

if(CYBLE_ERROR_OK == CyBle_GapRemoveBondedDevice (&bdAddress))

    {

        printf("removing bonded device success \r\n");

    }

   

        if(CYBLE_ERROR_INVALID_PARAMETER  == CyBle_GapRemoveBondedDevice (&bdAddress))

    {

        printf("removing bonded device invalid parameter\r\n");

    }

   

        if(CYBLE_ERROR_INVALID_OPERATION  == CyBle_GapRemoveBondedDevice (&bdAddress))

    {

        printf("removing bonded device invalid operation \r\n");

    }

   

        if(CYBLE_ERROR_NO_DEVICE_ENTITY == CyBle_GapRemoveBondedDevice (&bdAddress))

    {

        printf("removing bonded device no device entity \r\n");

    }

Please check this and let us know the result.

Thanks

Ganesh

0 Likes

ok i tried it and i always get error removing bonded device invalid operation.

in the data sheed is the discription for this erro:

On specifying NULL as input parameter for

'bdAddr'.

So I think that is ok because that is what i do

for bdAddr is written in Datasheed:

Pointer to peer device address, of type CYBLE_GAP_BD_ADDR_T. If

device address is set to 0, then all devices shall be removed from

trusted list and white list.

I printf also BondedDeviceList.count and it is 0 after the CyBle_GapRemoveBondedDevice (&bdAddress).

so I do in the next step:

.

if(BondedDeviceList.count==0)

{

                    CYBLE_API_RESULT_T bleApiResult;

                    bleApiResult = CyBle_StoreBondingData(0u);

                    if ( bleApiResult == CYBLE_ERROR_OK)

                    {

                        printf("Save ok");

                    }

}

else

{

     your code

}

and I get

CYBLE_ERROR_INVALID_OPERATION

count=0

Save ok

Save ok......

but after switching off the power, cout is 1 again.

0 Likes

Hi

I haven't been able to solve it until now.

0 Likes