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.

HCI Command sequence to establish BLE Connection

Other Parts Discussed in Thread: CC2564MODA, CC2650MODA, CC2650

Hi,

I am new to BLE.

I am working on the BLE communication using HCI commands. I am using CC2564MODA over 3 wire UART interface. Currently using the HCITester tool to test the working of CC2564MODA.

I am getting "Command Disallowed" error when executed "HCI_Write_Scan_enable 0x01" command. This indicates some initialization is remaining.

 Is there any HCI command sequence documented anywhere so that I can follow it.

Basically I looking for what commands I need to execute step by step at BLE central side so that BLE peripheral devices will get detected during Inquiry and can connect with them?

Vishal N

  • Hi,
    Your query has been assigned to relevant expert. We will get back to you shortly

    Thanks
    Saurabh
  • I did some research and tried to find the command sequence. But i am not successfully able to discover the peripheral devices around me.

    Bit more information about my problem - I am developing a BLE Central device (IoT gateway) which will discover the peripheral devices around it and will communicate with them using GATT protocol. For this I have to use HCI command sequence only as BLE stack is non portable on my MCU. This is as existing product in which I am adding BLE functionality hence can not use MSP430 or any other MCU in between. We have selected CC2564MODA module as BLE transceiver.

    I am using HCITester application to send HCI commands. I have also initiated the CC2564MODA module using TI init scripts v1.6. Below is the script which I have created. Please have a look and let me know the corrections required in this script.

    Send_HCI_Read_Local_Supported_Commands
    Wait_HCI_Command_Complete_Read_Local_Supported_Commands_Event 5000, any
    Send_HCI_Read_Local_Supported_Features
    Wait_HCI_Command_Complete_Read_Local_Supported_Features_Event 5000, any
    Send_HCI_Set_Event_Mask 0x0000000000001fff, 0x0000000000000000
    Wait_HCI_Command_Complete_Set_Event_Mask_Event 5000, any
    Send_HCI_LE_Set_Event_Mask 0x0000000000000fff, 0x0000000000000fff
    Wait_HCI_Command_Complete_LE_Set_Event_Mask_Event 5000, any
    Send_HCI_LE_Read_Buffer_Size
    Wait_HCI_Command_Complete_LE_Read_Buffer_Size_Event 5000, any, HCI_LE_Read_Buffer_Size, 
    Send_HCI_Read_Buffer_Size
    Wait_HCI_Command_Complete_Read_Buffer_Size_Event 5000, any, HCI_Read_Buffer_Size,
    Send_HCI_Read_BD_ADDR
    Wait_HCI_Command_Complete_Read_BD_ADDR_Event 5000, any
    
    Send_HCI_LE_Set_Random_Address "0C8EB3484FC3"
    Wait_HCI_Command_Complete_Event 5000
    
    Send_HCI_LE_Write_Suggested_Default_Data_Length 0xda9f, 0x0148
    Wait_HCI_Command_Complete_LE_Write_Suggested_Default_Data_Length_Event 5000, any
    Send_HCI_LE_Read_Suggested_Default_Data_Length
    Wait_HCI_Command_Complete_LE_Read_Suggested_Default_Data_Length_Event 5000, any
    
    Send_HCI_EXT_SetBDADDR "0c:8e:b3:48:4f:c3"
    Wait_HCI_Command_Complete_Event 5000, any
    
    Send_HCI_LE_Set_Scan_Parameters 0x01, 0x0010, 0x0010, 0x01, 0x00
    Wait_HCI_Command_Complete_LE_Set_Scan_Parameters_Event 5000, any, HCI_LE_Set_Scan_Parameters, 
    Send_HCI_LE_Set_Scan_Enable 0x01, 0x01
    Wait_HCI_Command_Complete_LE_Set_Scan_Enable_Event 5000, any, HCI_LE_Set_Scan_Enable, 0x00
    
    WaitForAllEvents 50000, True
    

    I am not getting the LE advertising report from the CC2564MODA module.

    Please let me know whether my approach is correct or not?

    Vishal N

  • please mark this post as not answered. I wrongly marked it as answered
  • Hi Vishal,

    I am looking into your question.

    You have multiple other threads open, namely

    e2e.ti.com/.../616598
    e2e.ti.com/.../615758

    Are these still open or have you figured them out?
  • Hey Dale,

    Thanks for responding.

    yes multiple threads are open but problem is only one. I have described the main problem in this thread above.

    I am developing one BLE central device in my existing product using TI's CC2564MODA. I want to use HCI commands to communicate with the module bypassing the BLE stack. As my MCU do not have this much memory to host the BLE stack.

    I am looking for HCI command sequence to configure CC2564MODA as BLE central and communicate with Peripheral devices.

    Awaiting for your reply.

    Vishal N
  • Vishal,

    Ok, thanks for clearing up. I'm going to close those other threads if that's ok, and focus on the current one. I'll get back to you shortly.
  • Hi Dale,

    Waiting for your reply.

    Vishal N

  • Vishal,

    Have you used the BLE add-on service pack? This service pack includes the steps necessary to initialize BLE on the device before doing anything else.
  • Hi dale,

    Yes I have used below mentioned scripts to initialize the module (CC2564MODA)

    initscripts-TIInit_6.7.16_bt_spec_4.1.bts (initscripts-TIInit_6.7.16_bt_spec_4.1.txt)

    initscripts-TIInit_6.7.16_ble_add-on.bts

    My script.txt - This I have created to enable and disable the LE scanning.

    I have attached all these scripts(scripts.zip) to this post as well attached the exported trace log from HCITester.

    The BLE add on scripts contains only two commands

    Send_ATT_ReadByTypeRsp 0xc000, 0x1b, ""

    Send_ATT_ReadByTypeRsp 0xc000, 0x1b, ""

    is this script correct. I got these scripts from TI website, its version is TIInit_6.7.16. Please let me know whether these scripts are correct.

    Vishal N

    4428.Scripts.zip

  • Hi Dale,

    I could progress a bit here. Now I am able to read the advertising packets using my HCI script. Script is give below. I got the correct initialization script and BLE add on scripts.

    Problems facing now - Not able to connect to the peripheral device. i have used below command to connect to the device. I am getting "Command Disallowed" as status in return event from the module.

    Send_HCI_LE_Create_Connection 0x0100, 0x0004, 0x01, 0x02, "1ccae320057d", 0x01, 0x0008, 0x0008, "0x0002", "0x0001", 0x0000, 0x0000, 0x0100, 0x0004, 0x01, 0x00, "1ccae320057d", 0x01, 0x0008, 0x0008, "0x0002", "0x0001", 0x0000, 0x0014
    Wait_HCI_Command_Status_Event 2000, 0x00, Any, 0x200d

    Any idea why it is not able to connect? You can review my complete HCI script below.

    Vishal N


    Send_HCI_Set_Event_Mask 0x28bffffffffb9fff Wait_HCI_Command_Complete_Set_Event_Mask_Event 5000, any Send_HCI_LE_Set_Event_Mask 0x000000000000001f Wait_HCI_Command_Complete_LE_Set_Event_Mask_Event 5000, any Send_HCI_Change_Local_Name "Vishal" Wait_HCI_Command_Complete_Change_Local_Name_Event 5000, any, HCI_Change_Local_Name, 0x00 Send_HCI_Read_Local_Name Wait_HCI_Command_Complete_Read_Local_Name_Event 5000, any, HCI_Read_Local_Name, 0x00, Send_HCI_Write_LE_Host_Support 0x01, 0x00 Wait_HCI_Command_Complete_Write_LE_Host_Support_Event 5000, any, HCI_Write_LE_Host_Support, 0x00 Send_HCI_LE_Read_Buffer_Size Wait_HCI_Command_Complete_LE_Read_Buffer_Size_Event 5000, any, HCI_LE_Read_Buffer_Size, Send_HCI_Read_Buffer_Size Wait_HCI_Command_Complete_Read_Buffer_Size_Event 5000, any, HCI_Read_Buffer_Size, Send_HCI_Read_BD_ADDR Wait_HCI_Command_Complete_Read_BD_ADDR_Event 5000, any Send_HCI_LE_Write_Scan_Parameters 0x01, 0x0010, 0x0010, 0x00, 0x01 Wait_HCI_Command_Complete_LE_Set_Scan_Parameters_Event 5000, any, HCI_LE_Set_Scan_Parameters, Send_HCI_Write_Scan_Enable 0x01 Wait_HCI_Command_Complete_Write_Scan_Enable_Event 5000, any, HCI_Write_Scan_Enable, 0x00, 5000, any, HCI_Write_Scan_Enable, 0x00, 5000, any, HCI_Write_Scan_Enable, 0x00, 5000, any, HCI_Write_Scan_Enable, 0x00 Send_HCI_LE_Clear_White_List Wait_HCI_Command_Complete_LE_Clear_White_List_Event 5000, any, HCI_LE_Clear_White_List, 0x00 Send_HCI_LE_Add_Device_To_White_List 0x00, "1ccae320057d" Wait_HCI_Command_Complete_LE_Add_Device_To_White_List_Event 5000, any, HCI_LE_Add_Device_To_White_List, 0x00 Send_HCI_LE_Write_Scan_Enable 0x01, 0x1 Wait_HCI_Command_Complete_LE_Set_Scan_Enable_Event 5000, Any, HCI_LE_Set_Scan_Enable, 0x00 Wait_HCI_LE_Generic_Report_Event 5000, Any, Send_HCI_LE_Write_Scan_Enable 0x00, 0x0 Wait_HCI_Command_Complete_LE_Set_Scan_Enable_Event 5000, any Send_HCI_LE_Create_Connection 0x0100, 0x0004, 0x01, 0x02, "1ccae320057d", 0x01, 0x0008, 0x0008, "0x0002", "0x0001", 0x0000, 0x0000, 0x0100, 0x0004, 0x01, 0x00, "1ccae320057d", 0x01, 0x0008, 0x0008, "0x0002", "0x0001", 0x0000, 0x0014 Wait_HCI_Command_Status_Event 2000, 0x00, Any, 0x200d WaitForAllEvents 50000, True

  • Looks like Send_HCI_LE_Create_Connection does not have the correct number of parameters being passed to it:

    Send_HCI_LE_Create_Connection 0x0100, 0x0004, 0x01, 0x02, "1ccae320057d", 0x01, 0x0008, 0x0008, "0x0002", "0x0001", 0x0000, 0x0000

  • Hi Dale,

    With respect to post above

    Do we have HCI sequence diagram for LE (Central device)? or is there any document which describes which HCI commands should be sent to CC2564MODA module to enable scanning and connection establishment?

    Awaiting your response.

    Vishal N

  • Vishal,

    You can refer to the Bluetooth spec for all the commands, but we do not recommend implementing it all through HCI. We usually implement it through the stack.

    Additionally, are you only trying to implement LE capability or plan on adding BT classic as well? If so, we have other products that are specialized for BLE that might be better suited for your application.
  • Hi Dale,

    Appreciated your reply.

    In this context I do have few questions.
    1. Our Intention behind to select CC2564MODA is BD/EDR and BLE. If there are difficulties to use this then which is other module which bhas inbuilt MCU and transceiver I can use directly on my board?
    2. If I select only BLE then which is the module (MCU + transceiver)
    3. In separate thread I learn that there is one module CC2650MODA which can be used for BLE. I do have this module with me. How to load Host Test Firmware(Hex file) in it? Which software tool I need to use on Windows machine? I do have XDS110 with me. I have host test firmware hex file with me.

    Awaiting your reply. I am intentionally waiting for reply on #3 as this will give me some direction to try the module.

    Vishal N

  • Regarding (3):

    CC2650 can be programmed with a hex file using SmartRF Flash Programmer. For more information on this device please refer to the Bluetooth Low Energy forums.

  • Hi Dale,

    Thanks for the response.

    I could flash the precompiled hex file HostTest firmware into the module. But could not detect it over UART from my PC (using BTool).

    I have flashed - simplelink\ble_sdk_2_02_01_18\examples\hex\cc2650lp_host_test_rel.hex

    I am NOT using launch pad. i have connected the JTG pins of the module with XDS110 and connected the pin #4 and #5 from the module with the TXD and RXD of the XDS110. Are these connection correct?

    Question -

    1. What version of the HostTest firmware should be used without Launch Pad?

    2. What are the UART pins, once Host Test firmware is running?

    3. How to detect that HostTest firmware is working?

    Please see below image for my connections.

    Vishal N

    P.S. - Please note that only debugger XDS110 is used from the Launch Pad board. All the jumper connecting to Launch pad has been removed.

  • Vishal,

    I do not support BLE only devices. Please direct this question towards the BLE forums.