Connect 3 devices successively

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

cross mob
Anonymous
Not applicable

Hello,

   

 

   

we try to connect from cyble-022001-00  to 3 or 4  cyble-022001-00 successively.

   

First : we build a array ( TONOFFC [][] ) with the mac addresses we want to connect to.       

   

Second : we read the address in the array and setup the peer address after that we connect.

   

Third  : We disconnect the ble . This code is managed in other condition because that doesn't work if it is in the previous condition.

   

See below a part of our code :

   

Main ()

   

{

   

......

   

while (1)

   

....

   

{
            peerAddr.bdAddr[0]=TONOFFC[intTest][5];
            peerAddr.bdAddr[1]=TONOFFC[intTest][4];
            peerAddr.bdAddr[2]=TONOFFC[intTest][3];  
            peerAddr.bdAddr[3]=TONOFFC[intTest][2];  
            peerAddr.bdAddr[4]=TONOFFC[intTest][1];   
            peerAddr.bdAddr[5]=TONOFFC[intTest][0];
            peerAddr.type  = 0;
            CyBle_GapcConnectDevice(&peerAddr);
            CyBle_ProcessEvents();          
            }

   

     if(state==CONNECTED )
    {
        CyBle_GapDisconnect(cyBle_connHandle.bdHandle);  
        state=DISCONNECTED;
        CyDelay(200u);
        CyBle_ProcessEvents();  

   

    }

   

}

   

Result :

   

For the moment only the first device of the array is working. the while loop works correctly because each variable change.

   

But there is no connection to the second , third ... devices.

   

 

   

If somebody have any idea , please help us.

   

 

   

Nota : We already use this code for connect one cyble-022001-00 to another one and it works fine.

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

   

Are you not increamenting intTest variable in the code to select the necxt device.

   

Also please debug this by monitoring the return codes of the CyBle_GapcConnectDevice and CyBle_GapDisconnect APIs.

   

Also, keep looking for the CONNECT and DISCONNECT events in the callback handler

   

Regards,

   

-Madhu Sudhan

View solution in original post

0 Likes
1 Reply
Anonymous
Not applicable

Hi,

   

Are you not increamenting intTest variable in the code to select the necxt device.

   

Also please debug this by monitoring the return codes of the CyBle_GapcConnectDevice and CyBle_GapDisconnect APIs.

   

Also, keep looking for the CONNECT and DISCONNECT events in the callback handler

   

Regards,

   

-Madhu Sudhan

0 Likes