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.

iOS connectivity

Other Parts Discussed in Thread: CC2540

Hi all,

I need to get advice about connectivity to iOS based device. I tested LightBlue app, which can switch i-device to peripheral mode with advertising. I tried to do connect from CC2540DK configured as Central with connection parameters according to Apple Bluetooth development guidelines. Problem occurred after successfully link establishment - GATT_CharClientCfgUpdated event message is received and after 10 seconds from connection is link terminated with event GAP_LinkTerminated with error code=0x13 (Peer requiered).

Do you know somebody, why is this happening?

I tried to connect i-device from pc with bluez, but it has same affect. I can discover advertising, but about 10 seconds after link establishment to this device is link terminated with same reason=0x13. 

I attach log-files, where are captured event messages with iOS. Could someone help me or advice? It's very important for me. 

Thank you very much for every help,

Martin Petřík

#hcitool -i hci0 lecc --random 7B:03:8B:F5:4B:CB
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
    bdaddr 7B:03:8B:F5:4B:CB type 1
> HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: LE Meta Event (0x3e) plen 19
    LE Connection Complete
      status 0x00 handle 64, role master
      bdaddr 7B:03:8B:F5:4B:CB (Random)
Connection handle 64
> ACL data: handle 64 flags 0x02 dlen 11
    ATT: Read By Group req (0x10)
      start 0x0001, end 0xffff
      type-uuid 0x2800
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 64 reason 0x13
    Reason: Remote User Terminated Connection

13:14:32.666 --
13:14:32.666 Packet "GAP_DeviceInit", Opcode 0xfe00
13:14:32.666 Parameters:
13:14:32.666 | profileRole      : 8 (GAP_PROFILE_CENTRAL)
13:14:32.666 | maxScanResponses : 3
13:14:32.666 | IRK              : "0"
13:14:32.666 | CSRK             : "0"
13:14:32.666 | signCounter      : 1
13:14:32.666 --
13:14:32.666 Outgoing Dump:
13:14:32.666     0000: 01 00 fe 26 08 03 00 00 00 00 00 00 00 00 00 00 ...&............
13:14:32.666     0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
13:14:32.666     0020: 00 00 00 00 00 00 01 00 00 00                   ..........
13:14:32.670 Incoming Dump:
13:14:32.670     0000: 04 ff 06 7f 06 00 00 fe 00                      .........
13:14:32.695 --
13:14:32.695 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.711 Parameters:
13:14:32.711 | Event Opcode : 0x067f (CommandStatus)
13:14:32.711 | Status       : 0x00 (SUCCESS)
13:14:32.711 | opCode       : 0xfe00 (GAP_DeviceInit)
13:14:32.711 | dataLen      : 0x00
13:14:32.711 --
13:14:32.712 Incoming Dump:
13:14:32.712     0000: 04 ff 2c 00 06 00 ca e0 09 af 59 90 1b 00 0c 1e ..,.......Y.....
13:14:32.712     0010: 29 96 c9 de 2f 2a 99 89 1e ab 66 71 bd d8 24 eb ).../*....fq..$.
13:14:32.712     0020: 63 65 8d 3d ab 6c 91 8d ee db 25 9a d9 9e 2a    ce.=.l....%...*
13:14:32.726 --
13:14:32.726 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.738 Parameters:
13:14:32.738 | Event Opcode : 0x0600 (GAP_DeviceInitDone)
13:14:32.738 | Status       : 0x00 (SUCCESS)
13:14:32.738 | devAddr      : "90:59:AF:09:E0:CA"
13:14:32.738 | dataPktLen   : 0x001b
13:14:32.738 | numDataPkts  : 0x0c
13:14:32.738 | IRK          : "1E:29:96:C9:DE:2F:2A:99:89:1E:AB:66:71:BD:D8:24"
13:14:32.738 | CSRK         : "EB:63:65:8D:3D:AB:6C:91:8D:EE:DB:25:9A:D9:9E:2A"
13:14:32.738 --
13:14:32.749 --
13:14:32.749 Packet "GAP_EstablishLinkReq", Opcode 0xfe09
13:14:32.749 Parameters:
13:14:32.749 | highDutyCycle : 0 (Disabled)
13:14:32.749 | whiteList     : 0 (Disabled)
13:14:32.749 | addrTypePeer  : 0x03 (ADDRTYPE_PRIVATE_RESOLVE)
13:14:32.749 | peerAddr      : "40:9B:D2:72:E3:41"
13:14:32.749 --
13:14:32.749 Outgoing Dump:
13:14:32.749     0000: 01 09 fe 09 00 00 03 41 e3 72 d2 9b 40          .......A.r..@
13:14:32.756 Incoming Dump:
13:14:32.756     0000: 04 ff 06 7f 06 00 09 fe 00                      .........
13:14:32.768 --
13:14:32.768 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.779 Parameters:
13:14:32.779 | Event Opcode : 0x067f (CommandStatus)
13:14:32.779 | Status       : 0x00 (SUCCESS)
13:14:32.779 | opCode       : 0xfe09 (GAP_EstablishLinkReq)
13:14:32.779 | dataLen      : 0x00
13:14:32.779 --
13:14:32.876 Incoming Dump:
13:14:32.877     0000: 04 ff 13 05 06 00 03 41 e3 72 d2 9b 40 00 00 50 .......A.r..@..P
13:14:32.877     0010: 00 00 00 d0 07 00                               ......
13:14:32.904 --
13:14:32.904 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.919 Parameters:
13:14:32.919 | Event Opcode        : 0x0605 (GAP_LinkEstablished)
13:14:32.919 | Status              : 0x00 (SUCCESS)
13:14:32.919 | Device Address Type : 0x03 (ADDRTYPE_PRIVATE_RESOLVE)
13:14:32.919 | Device Address      : "40:9B:D2:72:E3:41"
13:14:32.919 | connectionHandle    : 0x0000
13:14:32.919 | connInterval        : 0x0050
13:14:32.919 | connLatency         : 0x0000
13:14:32.919 | connTimeout         : 0x07d0
13:14:32.919 | clockAccuracy       : 0x00
13:14:32.919 --
13:14:32.933 --
13:14:32.933 Packet "GAP_SetParam", Opcode 0xfe30
13:14:32.933 Parameters:
13:14:32.933 | paramID    : 21 (TGAP_CONN_EST_INT_MIN)
13:14:32.933 | paramValue : 24
13:14:32.933 --
13:14:32.933 Outgoing Dump:
13:14:32.933     0000: 01 30 fe 03 15 18 00                            .0.....
13:14:32.935 Incoming Dump:
13:14:32.935     0000: 04 ff 06 7f 06 00 30 fe 00                      ......0..
13:14:32.947 --
13:14:32.947 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.959 Parameters:
13:14:32.959 | Event Opcode : 0x067f (CommandStatus)
13:14:32.959 | Status       : 0x00 (SUCCESS)
13:14:32.959 | opCode       : 0xfe30 (GAP_SetParam)
13:14:32.959 | dataLen      : 0x00
13:14:32.959 --
13:14:32.970 --
13:14:32.970 Packet "GAP_SetParam", Opcode 0xfe30
13:14:32.970 Parameters:
13:14:32.970 | paramID    : 22 (TGAP_CONN_EST_INT_MAX)
13:14:32.970 | paramValue : 312
13:14:32.970 --
13:14:32.970 Outgoing Dump:
13:14:32.970     0000: 01 30 fe 03 16 38 01                            .0...8.
13:14:32.972 Incoming Dump:
13:14:32.972     0000: 04 ff 06 7f 06 00 30 fe 00                      ......0..
13:14:32.984 --
13:14:32.984 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:32.996 Parameters:
13:14:32.996 | Event Opcode : 0x067f (CommandStatus)
13:14:32.996 | Status       : 0x00 (SUCCESS)
13:14:32.996 | opCode       : 0xfe30 (GAP_SetParam)
13:14:32.996 | dataLen      : 0x00
13:14:32.996 --
13:14:33.008 --
13:14:33.008 Packet "GAP_SetParam", Opcode 0xfe30
13:14:33.008 Parameters:
13:14:33.008 | paramID    : 26 (TGAP_CONN_EST_LATENCY)
13:14:33.008 | paramValue : 4
13:14:33.008 --
13:14:33.008 Outgoing Dump:
13:14:33.008     0000: 01 30 fe 03 1a 04 00                            .0.....
13:14:33.010 Incoming Dump:
13:14:33.010     0000: 04 ff 06 7f 06 00 30 fe 00                      ......0..
13:14:33.022 --
13:14:33.022 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:33.033 Parameters:
13:14:33.033 | Event Opcode : 0x067f (CommandStatus)
13:14:33.033 | Status       : 0x00 (SUCCESS)
13:14:33.033 | opCode       : 0xfe30 (GAP_SetParam)
13:14:33.033 | dataLen      : 0x00
13:14:33.033 --
13:14:33.045 --
13:14:33.045 Packet "GAP_SetParam", Opcode 0xfe30
13:14:33.045 Parameters:
13:14:33.045 | paramID    : 25 (TGAP_CONN_EST_SUPERV_TIMEOUT)
13:14:33.045 | paramValue : 600
13:14:33.045 --
13:14:33.045 Outgoing Dump:
13:14:33.045     0000: 01 30 fe 03 19 58 02                            .0...X.
13:14:33.047 Incoming Dump:
13:14:33.047     0000: 04 ff 06 7f 06 00 30 fe 00                      ......0..
13:14:33.059 --
13:14:33.059 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:33.071 Parameters:
13:14:33.071 | Event Opcode : 0x067f (CommandStatus)
13:14:33.071 | Status       : 0x00 (SUCCESS)
13:14:33.071 | opCode       : 0xfe30 (GAP_SetParam)
13:14:33.071 | dataLen      : 0x00
13:14:33.071 --
13:14:33.085 --
13:14:33.085 *** Script End ***
13:14:33.085 --
13:14:33.388 Incoming Dump:
13:14:33.388     0000: 04 ff 0a 80 05 00 00 00 04 0f 00 02 00          .............
13:14:33.413 --
13:14:33.413 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:33.428 Parameters:
13:14:33.428 | Event Opcode     : 0x0580 (GATT_ClientCharCfgUpdated)
13:14:33.428 | Status           : 0x00 (SUCCESS)
13:14:33.428 | connectionHandle : 0x0000
13:14:33.428 | pduLen           : 0x04
13:14:33.428 | attributeHandle  : 0x000f
13:14:33.428 | value            : 0x0002
13:14:33.428 --
13:14:43.085 Incoming Dump:
13:14:43.085     0000: 04 ff 06 06 06 00 00 00 13                      .........
13:14:43.114 --
13:14:43.114 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff
13:14:43.134 Parameters:
13:14:43.134 | Event Opcode     : 0x0606 (GAP_LinkTerminated)
13:14:43.134 | Status           : 0x00 (SUCCESS)
13:14:43.134 | connectionHandle : 0x0000
13:14:43.134 | reason           : 0x13 (Remote User Terminated Connection)
13:14:43.134 --

  • It sounds like the peripheral i-device is requesting and update to the connection parameters. Your central device then rejects or ignores the changes and the peripheral terminates the connection because of the rejection.

    Are you seeing these messages in simpleBLECentralEventCB?

  • Hi Peter,

    Thank you for your advice. Your opinion is probably, but I checked HCI_EXT_App_ProcessEvent callback function and there is no ignored event message. The only requested event from iOS is GATT_ClientCharCfgUpdated, which is not related to GAP layer and it could be information about setup indication of some characteristic in GATT profile.

    Peripheral could request new connection parameters by L2CAP_ConnParamUpdateReq (0xFC92) event, how I found in TI's HCI guideline. After link establishment I set these parameters by GAP_SetParam function:

    Min. Connection interval = 24 (30ms)

    Max. Connection interval = 312 (390ms)

    Slave latency = 4

    Supervision timeout = 600 (6s)

    These parameters are determinated by Apple Bluetooth Guideline, so iDevice should not require param update.

    Do you know some other reason why this is happening?

    I am grateful for your help,

    Martin Petřík

  • I got my messages mixed up. GATT_ClientCharCfgUpdated has nothing to do with connection parameters, it probably means you subscribed or unsubscribed form a notification enabled characteristic.

    I think the connection timeout has to be less than 6 seconds, not equal to.

  • Connection timeout should be equal to 6 seconds, but I tried to change this value, but it is without affect. 

    Connection parameters must meet this following conditions according to Apple Bluetooth guideline:

    Interval Max * (Slave Latency + 1) ≤ 2 seconds
    Interval Min ≥ 20 ms
    Interval Min + 20 ms ≤ Interval Max
    Slave Latency ≤ 4
    connSupervisionTimeout ≤ 6 seconds
    Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout
    Advertising interval from {20, 645, 768, 961, 1065, 1294} ms

    So I think, it should be set correctly. It occurs to me, if it could be caused by LightBlue app. Nothing more.

    Thank you for your help,

    Martin Petřík

  • Hi
    This post is quite old, but I'm facing a similar issue with CC2540 as a central and iPhone as a peripheral.
    Connection is ok, pairing is ok, but after few seconds, the disconnection occurs, GAP_LINK_TERMINATED_EVENT is received with the reason code 0x13.

    I was wondering if you solved that issue and if you have some tips to provide me.
    Any help would be greatly appreciated.
    Thanks
    Jerome
  • GAP_LINK_TERMINATED_EVENT is an open ended problem. Many things could cause it.

    Tasks that take too long can drop a connection. This was a common problem for me.

    You can find evidence of long tasks by looking at the power consumption. The chip should sleep when not executing a task. If you see the chip in wake for more than ~10ms, a long task may be causing the chip to drop connections.
  • Thanks for your answer Peter.

    This issue occurs only when connecting to an iOS device acting as a peripheral, (my cc2540 is a central).
    When I connect to any other device, there is no problem.

    I suspect a problem with the BLE address which is private on iOS, and public from other devices.

    This issue also occurs when I connect to iOS from btool through the TI dongle running host test release, so I guess this does not come from my firmware nor hardware.
    I tried to setup the connection internal, supervision timeout and so on, no luck so far.

    I'm using 128 bits UDIDs, and the iOS peripheral is a BLE MIDI device.

    Thanks for any other tip you may suggest.
    Jerome

  • I also observe a warning when connecting to the iPhone through Btool :
    I'm using BLE lib 1.4.1

    Below the btool log that shows the warning.

    Device Connected
    Handle = 0x0000
    Addr Type = 0x03 (PrivateResolve)
    BDAddr = 60:7D:85:F9:7B:D6

    --------------------------------------------------------------------

    [4] : <Rx> - 11:24:22.201
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (Event)
    -Data Length    : 0x14 (20) bytes(s)
    Event          : 0x0605 (1541) (GAP_EstablishLink)
    Status         : 0x00 (0) (Success)
    DevAddrType    : 0x03 (3) (PrivateResolve)
    DevAddr        : 60:7D:85:F9:7B:D6
    ConnHandle     : 0x0000 (0)
    ConnRole       : 0x08 (8) (Central)
    ConnInterval   : 0x0018 (24)
    ConnLatency    : 0x0004 (4)
    ConnTimeout    : 0x0258 (600)
    ClockAccuracy  : 0x00 (0)

    Dump(Rx):

    0000:04 FF 14 05 06 00 03 D6 7B F9 85 7D 60 00 00 08 ........{..}`...

    0010:18 00 04 00 58 02 00                            ....X..

    --------------------------------------------------------------------

    [5] : <Warning> - 11:24:22.264
    The Last 1 Bytes In The Following Message Were Not Decoded
    (Message Has More Than The Expected Number Of Data Bytes)

    --------------------------------------------------------------------

    [6] : <Rx> - 11:24:22.264
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (Event)
    -Data Length    : 0x0A (10) bytes(s)
    Event          : 0x0580 (1408) (GATT_ClientCharCfgUpdated)
    Status         : 0x00 (0) (Success)
    ConnHandle     : 0x0000 (0)
    PduLen         : 0x04 (4)
    AttrHandle     : 0x000F (15)
    Value          : 0x02 (2)

    Dump(Rx):

    0000:04 FF 0A 80 05 00 00 00 04 0F 00 02 00          .............

    --------------------------------------------------------------------

    [7] : <Info> - 11:24:27.786

    Device Disconnected
    Handle = 0x0000
    Addr Type = 0x03 (PrivateResolve)
    BDAddr = 60:7D:85:F9:7B:D6

    --------------------------------------------------------------------

    [8] : <Rx> - 11:24:27.786
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (Event)
    -Data Length    : 0x06 (6) bytes(s)
    Event          : 0x0606 (1542) (GAP_TerminateLink)
    Status         : 0x00 (0) (Success)
    ConnHandle     : 0x0000 (0)
    Reason         : 0x13 (19) (Peer Requested)

    Dump(Rx):

    0000:04 FF 06 06 06 00 00 00 13                      .........

    --------------------------------------------------------------------