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.

CC2652R: external HCI command to scan fails - unable to replicate BTOOL behaviour with same UART sequence

Part Number: CC2652R
Other Parts Discussed in Thread: LAUNCHXL-CC26X2R1

Hi,

I am trying to use BTOOL to help me prototype an application (on AM335x Linux) which will use LAUNCHXL-CC26X2R1 as a central device controlled by HCI commands over /dev/ttyACM0 . I am running host_test application from SDK 2.30.00.04.

Using BTOOL I can log the UART traffic to configure the CC2652R1 device and then start a scan. This is in the attached file btool-bt5.txt. My Linux application then uses the same sequence of UART commands (attached in app-bt5-uart.txt) and gets the same results back until I issue a scan command (opcode 0xFE51). I get an error 0x12 (18 decimal) back as the status.

Are there any hidden timings/dependencies in BTOOL that my application will need to implement so that I can replicate correct BTOOL behaviour?

Thanks, Iain

UART Tx 0000:01 1D FC 01 00
UART Rx 0000:04 FF 05 1D 04 00 1D FC
UART Tx 0000:01 00 FE 08 08 00 00 00 00 00 00 00
UART Rx 0000:04 FF 06 7F 06 00 00 FE 00
UART Rx 0000:04 FF 2C 00 06 00 68 B7 D2 F2 F8 F0 FF 00 05 00
UART Rx 0010:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94
UART Rx 0020:5B 8A 28 9B 87 0D 07 2C 52 8B F6 EE 23 61 BE
UART Tx 0000:01 61 FE 02 01 02
UART Tx 0000:01 61 FE 02 01 03
UART Tx 0000:01 61 FE 02 01 04
UART Tx 0000:01 61 FE 02 01 05
UART Rx 0000:04 FF 09 7F 06 00 61 FE 03 02 50 00
UART Rx 0000:04 FF 09 7F 06 00 61 FE 03 03 50 00
UART Rx 0000:04 FF 09 7F 06 00 61 FE 03 04 00 00
UART Rx 0000:04 FF 09 7F 06 00 61 FE 03 05 D0 07
UART Tx 0000:01 51 FE 06 00 00 F4 01 28 00
UART Rx 0000:04 FF 06 7F 06 12 51 FE 00
[1] : <Info> - 07:34:47.693
Port opened at 31/10/2018 19:34:47
--------------------------------------------------------------------
[2] : <Tx> - 07:34:47.802
-Type           : 0x01 (Command)
-OpCode         : 0xFC1D (HCIExt_ResetSystemCmd)
-Data Length    : 0x01 (1) byte(s)
 Type           : 0x00 (0) (Chip Reset)
Dump(Tx):
0000:01 1D FC 01 00                                  .....
--------------------------------------------------------------------
[3] : <Rx> - 07:34:47.896
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x05 (5) bytes(s)
 Event          : 0x041D (1053) (HCIExt_ResetSystemCmdDone)
 Status         : 0x00 (0) (SUCCESS)
 CmdOpCode      : 0xFC1D (HCIExt_ResetSystemCmd)
Dump(Rx):
0000:04 FF 05 1D 04 00 1D FC                         ........
--------------------------------------------------------------------
[4] : <Tx> - 07:34:48.412
-Type           : 0x01 (Command)
-OpCode         : 0xFE00 (GAP_DeviceInit)
-Data Length    : 0x08 (8) byte(s)
 ProfileRole    : 0x08 (8) (
                  Central)
 AddrMode       : 0x00 (0) (ADDRMODE_PUBLIC)
 RandomAddr     : 00:00:00:00:00:00
Dump(Tx):
0000:01 00 FE 08 08 00 00 00 00 00 00 00             ............
--------------------------------------------------------------------
[5] : <Rx> - 07:34:48.615
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE00 (GAP_DeviceInit)
 DataLength     : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 00 FE 00                      .........
--------------------------------------------------------------------
[6] : <Rx> - 07:34:48.630
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x2C (44) bytes(s)
 Event          : 0x0600 (1536) (GAP_DeviceInitDone)
 Status         : 0x00 (0) (SUCCESS)
 DevAddr        : F0:F8:F2:D2:B7:68
 DataPktLen     : 0x00FF (255)
 NumDataPkts    : 0x05 (5)
 IRK            : 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
 CSRK           : E8:9E:D7:2E:63:6B:9B:5F:B8:A7:8A:DE:EB:88:AC:66
Dump(Rx):
0000:04 FF 2C 00 06 00 68 B7 D2 F2 F8 F0 FF 00 05 00 ..,...h.........
0010:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E8 ................
0020:9E D7 2E 63 6B 9B 5F B8 A7 8A DE EB 88 AC 66    ...ck._.......f
--------------------------------------------------------------------
[7] : <Tx> - 07:34:48.662
-Type           : 0x01 (Command)
-OpCode         : 0xFE61 (GapInit_getPhyParam)
-Data Length    : 0x02 (2) byte(s)
 PHY            : 0x01 (1) (INIT_PHY_1M)
 ParamId        : 0x02 (2) (INIT_PHYPARAM_CONN_INT_MIN)
Dump(Tx):
0000:01 61 FE 02 01 02                               .a....
--------------------------------------------------------------------
[8] : <Tx> - 07:34:48.693
-Type           : 0x01 (Command)
-OpCode         : 0xFE61 (GapInit_getPhyParam)
-Data Length    : 0x02 (2) byte(s)
 PHY            : 0x01 (1) (INIT_PHY_1M)
 ParamId        : 0x03 (3) (INIT_PHYPARAM_CONN_INT_MAX)
Dump(Tx):
0000:01 61 FE 02 01 03                               .a....
--------------------------------------------------------------------
[9] : <Tx> - 07:34:48.708
-Type           : 0x01 (Command)
-OpCode         : 0xFE61 (GapInit_getPhyParam)
-Data Length    : 0x02 (2) byte(s)
 PHY            : 0x01 (1) (INIT_PHY_1M)
 ParamId        : 0x04 (4) (INIT_PHYPARAM_CONN_LATENCY)
Dump(Tx):
0000:01 61 FE 02 01 04                               .a....
--------------------------------------------------------------------
[10] : <Tx> - 07:34:48.740
-Type           : 0x01 (Command)
-OpCode         : 0xFE61 (GapInit_getPhyParam)
-Data Length    : 0x02 (2) byte(s)
 PHY            : 0x01 (1) (INIT_PHY_1M)
 ParamId        : 0x05 (5) (INIT_PHYPARAM_SUP_TIMEOUT)
Dump(Tx):
0000:01 61 FE 02 01 05                               .a....
--------------------------------------------------------------------
[11] : <Rx> - 07:34:48.771
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x09 (9) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE61 (GapInit_getPhyParam)
 DataLength     : 0x03 (3)
 ParamId        : 0x02 (2) (INIT_PHYPARAM_CONN_INT_MIN)
 MinConnectInter: 0x0050 (80)
Dump(Rx):
0000:04 FF 09 7F 06 00 61 FE 03 02 50 00             ......a...P.
--------------------------------------------------------------------
[12] : <Rx> - 07:34:48.787
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x09 (9) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE61 (GapInit_getPhyParam)
 DataLength     : 0x03 (3)
 ParamId        : 0x03 (3) (INIT_PHYPARAM_CONN_INT_MAX)
 MaxConnectInter: 0x0050 (80)
Dump(Rx):
0000:04 FF 09 7F 06 00 61 FE 03 03 50 00             ......a...P.
--------------------------------------------------------------------
[13] : <Rx> - 07:34:48.818
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x09 (9) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE61 (GapInit_getPhyParam)
 DataLength     : 0x03 (3)
 ParamId        : 0x04 (4) (INIT_PHYPARAM_CONN_LATENCY)
 ConnectLatency : 0x0000 (0)
Dump(Rx):
0000:04 FF 09 7F 06 00 61 FE 03 04 00 00             ......a.....
--------------------------------------------------------------------
[14] : <Rx> - 07:34:48.833
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x09 (9) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE61 (GapInit_getPhyParam)
 DataLength     : 0x03 (3)
 ParamId        : 0x05 (5) (INIT_PHYPARAM_SUP_TIMEOUT)
 SuperTimeout   : 0x07D0 (2000)
Dump(Rx):
0000:04 FF 09 7F 06 00 61 FE 03 05 D0 07             ......a.....
--------------------------------------------------------------------
[15] : <Tx> - 07:34:55.201
-Type           : 0x01 (Command)
-OpCode         : 0xFE51 (GapScan_enable)
-Data Length    : 0x06 (6) byte(s)
 Period         : 0x0000 (0)
 Duration       : 0x01F4 (500)
 MaxNumRecords  : 0x0028 (40)
Dump(Tx):
0000:01 51 FE 06 00 00 F4 01 28 00                   .Q......(.
--------------------------------------------------------------------
[16] : <Rx> - 07:34:55.233
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE51 (GapScan_enable)
 DataLength     : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 51 FE 00                      ......Q..
--------------------------------------------------------------------
[17] : <Rx> - 07:34:55.248
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x07 (7) bytes(s)
 Event          : 0x0613 (1555) (GAP_AdvertiserScannerEvent)
 Status         : 0x00 (0) (SUCCESS)
 EventId        : 0x00010000 (65536) (
                  GAP_EVT_SCAN_ENABLED)
Dump(Rx):
0000:04 FF 07 13 06 00 00 00 01 00                   ..........
--------------------------------------------------------------------
[18] : <Rx> - 07:34:55.773
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x3B (59) bytes(s)
 Event          : 0x0613 (1555) (GAP_AdvertiserScannerEvent)
 Status         : 0x00 (0) (SUCCESS)
 EventId        : 0x00400000 (4194304) (
                  GAP_EVT_ADV_REPORT)
 AdvRptEventType: 0x10 (16) (Legacy_ADV_NONCONN_or_Data_Complete)
 AddressType    : 0x00 (0) (ADDRTYPE_PUBLIC)
 Address        : 14:BB:6E:00:48:73
 PrimaryPHY     : 0x01 (1) (SCANNED_PHY_1M)
 SecondaryPHY   : 0x00 (0) (SCANNED_PHY_NONE)
 AdvSid         : 0xFF (255)
 TxPower        : 0x7F (127)
 RSSI           : 0xA2 (162)
 DirectAddrType : 0xFF (255) (ADDRTYPE_NONE)
 DirectAddr     : 00:00:00:00:00:00
 PeriodicAdvInt : 0x0000 (0)
 DataLength     : 0x001C (28)
 Data           : 1B:FF:75:00:42:04:01:80:8E:14:BB:6E:00:48:73:16:
                  BB:6E:C6:31:99:01:00:00:00:00:00:00
Dump(Rx):
0000:04 FF 3B 13 06 00 00 00 40 00 10 00 73 48 00 6E ..;.....@...sH.n
0010:BB 14 01 00 FF 7F A2 FF 00 00 00 00 00 00 00 00 ................
0020:1C 00 1B FF 75 00 42 04 01 80 8E 14 BB 6E 00 48 ....u.B......n.H
0030:73 16 BB 6E C6 31 99 01 00 00 00 00 00 00       s..n.1........
--------------------------------------------------------------------
[19] : <Rx> - 07:34:56.148
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x2D (45) bytes(s)
 Event          : 0x0613 (1555) (GAP_AdvertiserScannerEvent)
 Status         : 0x00 (0) (SUCCESS)
 EventId        : 0x00400000 (4194304) (
                  GAP_EVT_ADV_REPORT)
 AdvRptEventType: 0x13 (19) (Legacy_ADV_IND_or_Data_Complete)
 AddressType    : 0x01 (1) (ADDRTYPE_RANDOM)
 Address        : 46:7E:AE:73:37:09
 PrimaryPHY     : 0x01 (1) (SCANNED_PHY_1M)
 SecondaryPHY   : 0x00 (0) (SCANNED_PHY_NONE)
 AdvSid         : 0xFF (255)
 TxPower        : 0x7F (127)
 RSSI           : 0xA7 (167)
 DirectAddrType : 0xFF (255) (ADDRTYPE_NONE)
 DirectAddr     : 00:00:00:00:00:00
 PeriodicAdvInt : 0x0000 (0)
 DataLength     : 0x000E (14)
 Data           : 02:01:1A:0A:FF:4C:00:10:05:03:18:A3:58:26
Dump(Rx):
0000:04 FF 2D 13 06 00 00 00 40 00 13 01 09 37 73 AE ..-.....@....7s.
0010:7E 46 01 00 FF 7F A7 FF 00 00 00 00 00 00 00 00 ~F..............
0020:0E 00 02 01 1A 0A FF 4C 00 10 05 03 18 A3 58 26 .......L......X&
--------------------------------------------------------------------
[20] : <Rx> - 07:34:56.663
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x2D (45) bytes(s)
 Event          : 0x0613 (1555) (GAP_AdvertiserScannerEvent)
 Status         : 0x00 (0) (SUCCESS)
 EventId        : 0x00400000 (4194304) (
                  GAP_EVT_ADV_REPORT)
 AdvRptEventType: 0x13 (19) (Legacy_ADV_IND_or_Data_Complete)
 AddressType    : 0x00 (0) (ADDRTYPE_PUBLIC)
 Address        : B0:91:22:EA:FF:04
 PrimaryPHY     : 0x01 (1) (SCANNED_PHY_1M)
 SecondaryPHY   : 0x00 (0) (SCANNED_PHY_NONE)
 AdvSid         : 0xFF (255)
 TxPower        : 0x7F (127)
 RSSI           : 0xDA (218)
 DirectAddrType : 0xFF (255) (ADDRTYPE_NONE)
 DirectAddr     : 00:00:00:00:00:00
 PeriodicAdvInt : 0x0000 (0)
 DataLength     : 0x000E (14)
 Data           : 02:01:06:03:02:0F:18:06:FF:0D:00:03:00:00
Dump(Rx):
0000:04 FF 2D 13 06 00 00 00 40 00 13 00 04 FF EA 22 ..-.....@......"
0010:91 B0 01 00 FF 7F DA FF 00 00 00 00 00 00 00 00 ................
0020:0E 00 02 01 06 03 02 0F 18 06 FF 0D 00 03 00 00 ................
--------------------------------------------------------------------
[21] : <Rx> - 07:35:00.234
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x09 (9) bytes(s)
 Event          : 0x0613 (1555) (GAP_AdvertiserScannerEvent)
 Status         : 0x00 (0) (SUCCESS)
 EventId        : 0x00020000 (131072) (
                  GAP_EVT_SCAN_DISABLED)
 EndReason      : 0x01 (1) (SCAN_END_REASON_DUR_EXP)
 NumberOfReports: 0x03 (3)
Dump(Rx):
0000:04 FF 09 13 06 00 00 00 02 00 01 03             ............
--------------------------------------------------------------------

  • Hi Iain,

    0x12 is bleIncorrectMode (Not setup properly to perform that task). Can you check the BTool log and double-check that you're sending all the necessary commands? (GAP_DeviceInit() etc).
  • Hi Marie,

    Attached is a screenshot from a comparison of the two log files I attached. It shows that GAP_DeviceInitDone responds with a successful status (0x00), the only difference is that the CSPK is different.

    Are you saying that the only way a scan request would have failed with that error, is if the Init is not done?

    Thanks, Iain

  • Hi Iain,

    CSRK is randomly generated, so this is not surprising. (Connection Signature Resolving Key, see the vendor specific guide.)

    bleIncorrectMode is returned if the device is not setup properly for the task you're asking. Did you build the Host Test project with the central or observer GAPRole? There might be a timing problem, are you waiting for the return before sending every new command?
  • Hi Marie,
    It is the same Launchpad I am using with both BTOOL and the BeagleBoneBlack and so it is the same Host Test image in use in both scenarios.
    The sequence of commands is tightly controlled. The callback from the receive operation is used to trigger the transmission of the next command.
    I have also tested with GND & 5V supplied to P1 on the Launchpad just in case the BeagleBoneBlack was not able to supply enough current for the Launchpad via USB and there had been a brown out/reboot . It was the same behaviour.

    Are there any HCI commands I can use to query the state of the CC2652?
    Iain
  • Hi Iain,

    What you're describing sounds really strange. Can you try sending a second GAP_DeviceInit when the scan_enable command fails?

    Also, can you try without sending all the GapInit_getPhyParam() commands?
  • Does this happen every time?
  • Hi Marie,

    I have been experimenting with adding different delays between the last getPhyParam response and issuing the scan request. The results can be summarised as:

    delay <= 75ms 

    Scan enable responds with success, GAP_ADV_EVENT_SCAN_ENABLED is received. However, no scan events are received and a subsequent Scan_disable returns 0x12

    75ms < delay <100ms

    No response is received to Scan enable request

    delay >= 100ms

    Scan enable responds with 0x12 failure.

    My hypothesis is that between 75ms and 100ms after last getPhyParam value is received the device is rebooting and so is unable to respond to the message. After 100ms it has rebooted but is still in an uninitialised state and so returns 0x12.

    The initial sequence of reset, GAP_Init and getPhyParam commands takes 20ms.

    Iain

  • Hi Marie,
    I found that if I added a 500ms delay between the systemreset event and issuing the GAP init command then all works as expected.

    From a user perspective it would be good if the host_test app issued the systemreset complete event AFTER is has rebooted and is ready to receive commands. This would avoid application having to deal with this.
    Thanks for your help. It's good to see that the LPRF team are still very responsive on the e2e.
    Iain
  • Hi Iain,

    There is actually a 100 ms delay from when the HCIExt_ResetSystemCmd is called and the device resets. I will make sure we document this.