8 Replies Latest reply on Mar 21, 2016 1:14 AM by simon.wimbles

    PRoC BLE Disconnect Error

    simon.wimbles

      I'm having some trouble at the moment with a design I'm working on. I have one central device and two peripherals which take it in turn to connect to the central. The problem I'm having is that one of the peripherals is not disconnecting when a disconnection request is sent from the central. When the central then tries to reconnect to this peripheral it can't as the peripheral still believes it is connected and is therefore not advertising. I have debugged the peripheral in question and when the central calls CyBle_GapDisconnect the peripheral does not jump in to the stack handler; it's as though it never received the request. This is only intermittent, however, and it does work 90% of the time. 
      This is the code which calls the disconnection api at the central end:

         


                          apiResult = CyBle_GapDisconnect(connectionHandle.bdHandle);
                          while (bleConnected == TRUE)
                          {
                              ServiceWDT ();
                              CyBle_ProcessEvents();
                          }
                          if (apiResult != CYBLE_ERROR_OK)
                          {
      #                       ifdef SERIALDEBUG
                                  UART_UartPutString("+Disconnection error");
                                  UART_UartPutString("\r\n");
      #                       endif
                          }
                          else if (apiResult == CYBLE_ERROR_OK)
                          {
      #                       ifdef SERIALDEBUG
                                  UART_UartPutString("Disconnected from device with handle: ");
                                  sprintf (valueString, "%i", connectionHandle.bdHandle);
                                  UART_UartPutString(valueString);
                                  UART_UartPutString("\r\n");
      #                       endif
                          }

         


      The disconnection api never returns an error when this fault occurs so I'm at a bit of a loss as to what the issue is. Plus, the connection handle is always correct/same value. Also, the fact the peripheral connection does not time out is just as curious. 
      Has anyone come across this, or a similar problem before?