cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

hello there i have one psoc ble device.

when i am trying to connect it with application. sometime it connects fine. but sometimes it takes time and if connection fails then i can't scan device. i have to restart device.

is there any API, that even after connection fails, it scans device.

void StackEventHandler(uint32 eventCode, void * eventParam)

{

    static uint8 ledToggle = 0;

   

    CYBLE_GATTS_WRITE_REQ_PARAM_T *wrReqParam;

   

   

    switch(eventCode)

    {

        /* Stack is initialized. Start advertisement. */

        case CYBLE_EVT_STACK_ON:

       

          // UARt_UartPutString("\r\n==========Fixed Passkey Demo========\r\n");

           if(CYBLE_ERROR_OK== CyBle_GapFixAuthPassKey(FIX_PASSKEY,passkey))

                {

                   

                }

                else

                {

                   

                }

            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

            /* Turn OFF all LEDs */

          //  Led_Red_Write(0);

           // Led_Green_Write(0);

           

            break;

           

        /* Advertisement timed out. Restart advertisement. */

        case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

          

              

            if(CyBle_GetState()==CYBLE_STATE_ADVERTISING)

                {

                   // UARt_UartPutString("Started to advertise\r\n");

                }

                else

                {

                  //   UARt_UartPutString("advertisement stopped\r\n");

                    CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST); //Led_Red_Write(0);

                }

            break;

           

        case CYBLE_EVT_GATT_CONNECT_IND:

            //printf("Connection Handle: %d\r\n",cyBle_connHandle.bdHandle);

            break;

           

         case CYBLE_EVT_GAP_DEVICE_CONNECTED:

              

                //UARt_UartPutString("Device Connected\r\n");

                if(CYBLE_ERROR_OK==CyBle_GapAuthReq(cyBle_connHandle.bdHandle,&cyBle_authInfo))

                {

                     //authInProcess=true;

                 //   Led_Red_Write(1);

                }

            break;

               

        /* Device is disconnected. Restart advertisement. */

        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:

                   

            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

            break;

           

        case CYBLE_EVT_GAP_AUTH_REQ:

        case CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO:  

         

            break;

       

        case CYBLE_EVT_GAP_PASSKEY_DISPLAY_REQUEST:

 

     

            break;

      

       

        case CYBLE_EVT_GAP_AUTH_COMPLETE:

         

               

            break;

               

         case CYBLE_EVT_GAP_AUTH_FAILED:

        

           

            break;

               

        case CYBLE_EVT_GATTS_WRITE_REQ:

       

    

            

           

                CyBle_GattsWriteRsp(cyBle_connHandle);

        break;

           

           

       

      

        default:

            break;

    }

}

0 Likes
Reply
1 Reply
Moderator
Moderator

Hello,

Code seems to be ok.

Could you please let us know which CyBLE part number you are using?

What is the issue you are facing? Are you getting BLE disconnected when you tries connection?

Thanks,
Anjana

0 Likes
Reply