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.

TimeApp on CC2541 not disconnecting from bluetooth settings after disconnecting from App

Other Parts Discussed in Thread: CC2541

Hi,

I am working on ANCS alert notification on CC2541 using TimeApp profile. I am able to first connect and pair and able to receive the alerts. When i try to disconnect it from the app its getting disconnected in the app, but its not getting disconnected from the iphone bluetooth settings. 

Its always showing connected when i try to disconnect from the App. Then i have to forget the device from the iphone bluetooth settings inorder to disconnect it.Can anybody tell why this is happening

Thanks

  • Hi,

    I believe that might be a design feature. App app can request to disconnect but it's up to Core Bluetooth within iOS to actually disconnect. The reason is that other App might be using the connected device.

    You could use the CCS service in the sensor tag project to bypass this. Essentially you open up a characteristic that can be written to in order to ask the CC2541 to disconnect.

     Best Regards

    Joakim

  • Hi Joakim,

    Can you give some idea how to add this service into my Timeapp Profile.At what stage we need to write the characteristics onto the IOS device to Disconnect it  , so that it should  start advertising.Any code samples will be more helpful

    Regards

    Don 

  • Don David said:
    At what stage we need to write the characteristics onto the IOS device to Disconnect it

    When you want to... It's up to you.

    Don David said:
    Any code samples will be more helpful

    It's available in the sensor tag project.

  • If i tap on the disconnect button on the Iphone app it still showing connected state and the device was still in connected until i forget the device.

    I would like to know how the peripheral can know its time to terminate the connection and start advertising again when i press the disconnect button on the Iphone APP.This is were i am stuck.

    Thanks

    Don

  • Hi Don,

    I see. You will need add the CCS service (located at C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\Profiles\SensorProfile) to you ANCS software. 

    The third characteristic (UUID with custom 0xCCC3) will allow you to trigger following code in your embedded application (which you will have to add):

    static void ccChangeCB( uint8 paramID )
    {
    
    // CCSERVICE_CHAR1: read & notify only
    
    // CCSERVICE_CHAR: requested connection parameters
    if( paramID == CCSERVICE_CHAR2 )
    {
    uint8 buf[CCSERVICE_CHAR2_LEN];
    uint16 minConnInterval;
    uint16 maxConnInterval;
    uint16 slaveLatency;
    uint16 timeoutMultiplier;
    
    CcService_GetParameter( CCSERVICE_CHAR2, buf );
    
    minConnInterval = BUILD_UINT16(buf[0],buf[1]);
    maxConnInterval = BUILD_UINT16(buf[2],buf[3]);
    slaveLatency = BUILD_UINT16(buf[4],buf[5]);
    timeoutMultiplier = BUILD_UINT16(buf[6],buf[7]);
    
    // Update connection parameters
    GAPRole_SendUpdateParam( minConnInterval, maxConnInterval, slaveLatency, timeoutMultiplier, GAPROLE_TERMINATE_LINK);
    }
    
    // CCSERVICE_CHAR3: Disconnect request
    if( paramID == CCSERVICE_CHAR3 )
    {
    // Any change in the value will terminate the connection
    GAPRole_TerminateConnection();
    }
    }

    With this callback, you will be able to disconnect by writing for example 0x01 to the Characteristic 3.

    Note that this is a custom workaround since iOS doesn't allow you to disconnect immediately from a phone (as of now)

    Best Regards

    Joakim

  • Hi Joakim,

    Thanks for the reply.

    As you suggested i was able to add the ccservice.c/.h files into my ANCS profile.Now i am facing some problem with the UUID.

    I found these UUIDs in the ccservice.h file

    #define CCSERVICE_SERV_UUID 0xCCC0
    #define CCSERVICE_CHAR1_UUID 0xCCC1 //F000CCC1-0451-4000-B000-00000000-0000
    #define CCSERVICE_CHAR2_UUID 0xCCC2
    #define CCSERVICE_CHAR3_UUID 0xCCC3

    I would like to know what changes i have to make here with respect to ANCS

    The ANCS 128bit UUID is as follows.

    #define ANCS_SVC_UUID                       {0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4E, 0xCE,

    0xB5, 0x31, 0xF4, 0x05, 0x79}; 

    Regards

    Don

  • Hi Don,

    I think I have misunderstood your intention.

    CCService is a proprietary service which means that you must (manually through an app) interact with it. ANCS will not recognize it no matter what you change the UUIDs to, so you can just keep them as they are. ANCS is built in natively into Core Bluetooth on iOS while proprietary services can only be accessed though a custom made app.

    If you do not want to write your own app, you can use the TI MultiTool to send the command to disconnect.

    Best Regards

    Joakim

  • Hi Joakim,

    Thanks for the reply.When we tap on  the disconnect button on the custom made app,then the app should write 0x01 to the characteristic 3 of the ccservice .And after receiving the 0x01 it should immediately execute  

    GAPRole_TerminateConnection();  ,to terminate the connection

    I think this was what you suggested.

    if the user just taps on the disconnect button it will work fine, but if the user forcefully terminate the app then what needs to be done in this case

    Is there any other workaround possible to overcome this disconnection issue while using IOS generated UUIDS

    Regards

    Don

  • Hi Joakim,

    I was facing some problem regarding disconnection from the app.

    I have integrated thekeyfobdemo project and timeapp project  into one

    .After disconnection from the app the device automatically gets connected in the iphone bluetooth settings without initiating the connection from the app.

    So i have  made a possible workaround  inorder to prevent it from getting connected .I am trying to make the bonding FALSE so that it starts a  new connection.When the user presses the disconnect button on the app, it immediately sends an alert code so that the below case executes. After disconnect from the app its giving the pair pop up window which is fine. But when the user goes out of range and comes back in range its still asking the pair pop.My requirement is that while disconnecting from app it should ask for pair pop up and when going out of range and comeback it should connect automatically.Can you suggest what i am doing wrong

    if ( keyfobProximityState == KEYFOB_PROXSTATE_PATH_LOSS )
    {
    switch( keyfobProxIMAlertLevel )
    {

    case TERMINATE_CONN:
    {
    uint8 bonding_data=FALSE;
    GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding_data );
    GAPRole_TerminateConnection();

    }

    KInd Regards

    Don