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.

CC2640R2L: CC2640R2L: play as peripheral mode on BTool

Part Number: CC2640R2L
Other Parts Discussed in Thread: CC2640

Hi ,

environment:

sdk: simplelink_cc2640r2_sdk_5_10_00_02

project: ble5_host_test_cc2640r2lp_app

I want to config cc2640 as a peripheral through BTool.

The following is my steps:

1. HCIExt_ResetSystemCmd

2. GAP_DeviceInit with Peripheral-ADDRMODE_PUBLIC-00:11:22:AA:BB:CC

3. GapAdv_create

4. GapAdv_enable

Q1. I find the device through apps such like LightBlue, but I do not know what is the bdaddr that can be connected by the centrals.

Q2. Can I config the cc2640 as a peripheral with fixed customized bdaddr to be connected with other centrals?

Q3. after GapAdv_enable step and connected with LightBlue, the cc2640 is not advertising automaticllay? Is it possible for auto advertising?

  • Hi Huazhen,

    Q1. I find the device through apps such like LightBlue, but I do not know what is the bdaddr that can be connected by the centrals.

    Q2. Can I config the cc2640 as a peripheral with fixed customized bdaddr to be connected with other centrals?

    The BD_ADDR used is displayed in the lefthand side of Btool, in your case F0:F8:F2:DA:00:1C. Please see this related post by my colleague that describes the different possibilities for addresses when it comes to a Bluetooth LE peripheral. In general, you can simply use the default BD_ADDR/device ID for the device you use, this is fixed and does not change as long as a public address is used. If you use a random address, then the address used to connect with can change.

    Q3. after GapAdv_enable step and connected with LightBlue, the cc2640 is not advertising automaticllay? Is it possible for auto advertising?

    This is expected behavior. To resume advertising, you will have to call GapAdv_enable again explicitly. Is there a specific reason you are using BTOOL at this stage? If you use simple_peripheral, you can add logic to resume advertising automatically (the default example does this already).

  • Hi,

    I have been tried the "random addr" when GAP_DeviceInit, but it show as following:

    If using simple_peripheral, can I customize the bdaddr with any commands?

  • Hi, 

    I would like to add something about this.

    By default, the simple_peripheral will advertise with primary bdaddr if I use the following code at first.

    GAP_DeviceInit(GAP_PROFILE_PERIPHERAL, selfEntity, ADDRMODE_PUBLIC, NULL);

    Can I customize the bdaddr with any commands that the cc2640 is advertising already?

    such like, 

    disable advertising first, and the change the bdaddr , enable advertising finally?

    I try this command, but it is not worked.

    uint8 bdAddress[B_ADDR_LEN] = { 0x00, 0x11, 0x22, 0xAA, 0x55, 0x66 };
    HCI_EXT_SetBDADDRCmd(bdAddress);
    // Set device's Sleep Clock Accuracy
    HCI_EXT_SetSCACmd(40);

    I need to advertise packets with customized bdaddr.

  • Hey Huazhen,

    I have been tried the "random addr" when GAP_DeviceInit

    Based on your description, I don't think using a random address is what you are looking for. Random addresses are customized, but it looks like you need the bd_addr to be static and not random.

    I try this command, but it is not worked

    I was able to get this command working using BTOOL. The SetBDADDRCmd must be called before an advertisement set is created and enabled. If you have enabled an advertisement set, you need to first stop advertising before resetting the BD_ADDR. Here's my BTOOL log that shows the steps I followed.

    19] : <Tx> - 12:49:54.021
    -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                                  .....
    --------------------------------------------------------------------
    [20] : <Rx> - 12:49:54.041
    -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                         ........
    --------------------------------------------------------------------
    [21] : <Tx> - 12:50:04.515
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE00 (GAP_DeviceInit)
    -Data Length    : 0x08 (8) byte(s)
     ProfileRole    : 0x04 (4) (
                      Peripheral)
     AddrMode       : 0x00 (0) (ADDRMODE_PUBLIC)
     RandomAddr     : 00:00:00:00:00:00
    Dump(Tx):
    0000:01 00 FE 08 04 00 00 00 00 00 00 00             ............
    --------------------------------------------------------------------
    [22] : <Rx> - 12:50:04.535
    -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                      .........
    --------------------------------------------------------------------
    [23] : <Rx> - 12:50:04.551
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (HCI_LE_ExtEvent)
    -Data Length    : 0x2C (44) bytes(s)
     Event          : 0x0600 (1536) (GAP_DeviceInitDone)
     Status         : 0x00 (0) (SUCCESS)
     DevAddr        : 0C:61:CF:A2:B3:F4
     DataPktLen     : 0x00FF (255)
     NumDataPkts    : 0x05 (5)
     IRK            : 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
     CSRK           : BD:63:54:13:94:06:C4:E1:92:9D:14:C3:3F:03:F9:27
    Dump(Rx):
    0000:04 FF 2C 00 06 00 F4 B3 A2 CF 61 0C FF 00 05 00 ..,.......a.....
    0010:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BD ................
    0020:63 54 13 94 06 C4 E1 92 9D 14 C3 3F 03 F9 27    cT.........?..'
    --------------------------------------------------------------------
    [24] : <Tx> - 12:51:00.875
    -Type           : 0x01 (Command)
    -OpCode         : 0xFC0C (HCIExt_SetBDADDRCmd)
    -Data Length    : 0x06 (6) byte(s)
     BLEAddress     : 11:33:33:44:55:66
    Dump(Tx):
    0000:01 0C FC 06 66 55 44 33 33 11                   ....fUD33.
    --------------------------------------------------------------------
    [25] : <Rx> - 12:51:00.899
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (HCI_LE_ExtEvent)
    -Data Length    : 0x05 (5) bytes(s)
     Event          : 0x040C (1036) (HCIExt_SetBDADDRCmdDone)
     Status         : 0x00 (0) (SUCCESS)
     CmdOpCode      : 0xFC0C (HCIExt_SetBDADDRCmd)
    Dump(Rx):
    0000:04 FF 05 0C 04 00 0C FC                         ........
    --------------------------------------------------------------------
    [26] : <Tx> - 12:51:06.818
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE3E (GapAdv_create)
    -Data Length    : 0x15 (21) byte(s)
     Properties     : 0x0013 (19) (
                      GAP_ADV_PROP_CONNECTABLE
                      GAP_ADV_PROP_SCANNABLE
                      GAP_ADV_PROP_LEGACY)
     IntervalMin    : 0x0000A0 (160)
     IntervalMax    : 0x0000A0 (160)
     PrimaryChMap   : 0x07 (7) (
                      GAP_ADV_CHAN_37
                      GAP_ADV_CHAN_38
                      GAP_ADV_CHAN_39)
     PeerAddrType   : 0x00 (0) (PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID)
     PeerAddress    : 00:00:00:00:00:00
     FilterPolicy   : 0x00 (0) (
                      AdvFilterPolicy Bit Mask Is Not Set)
     TxPower        : 0x7F (127)
     PrimaryPHY     : 0x01 (1) (GAP_ADV_PRIM_PHY_1_MBPS)
     SecondaryPHY   : 0x01 (1) (GAP_ADV_SEC_PHY_1_MBPS)
     SID            : 0x00 (0)
    Dump(Tx):
    0000:01 3E FE 15 13 00 A0 00 00 A0 00 00 07 00 00 00 .>..............
    0010:00 00 00 00 00 7F 01 01 00                      .........
    --------------------------------------------------------------------
    [27] : <Rx> - 12:51:06.848
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (HCI_LE_ExtEvent)
    -Data Length    : 0x07 (7) bytes(s)
     Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
     Status         : 0x00 (0) (SUCCESS)
     OpCode         : 0xFE3E (GapAdv_create)
     DataLength     : 0x01 (1)
     Handle         : 0x00 (0)
    Dump(Rx):
    0000:04 FF 07 7F 06 00 3E FE 01 00                   ......>...
    --------------------------------------------------------------------
    [28] : <Tx> - 12:51:09.059
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE3F (GapAdv_enable)
    -Data Length    : 0x04 (4) byte(s)
     Handle         : 0x00 (0)
     EnableOptions  : 0x00 (0) (GAP_ADV_ENABLE_OPTIONS_USE_MAX)
     DurationMaxEvnt: 0x0000 (0)
    Dump(Tx):
    0000:01 3F FE 04 00 00 00 00                         .?......
    --------------------------------------------------------------------
    [29] : <Rx> - 12:51:09.077
    -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         : 0xFE3F (GapAdv_enable)
     DataLength     : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 7F 06 00 3F FE 00                      ......?..
    --------------------------------------------------------------------
    [30] : <Tx> - 12:51:20.828
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE41 (GapAdv_destroy)
    -Data Length    : 0x01 (1) byte(s)
     Handle         : 0x00 (0)
    Dump(Tx):
    0000:01 41 FE 01 00                                  .A...
    --------------------------------------------------------------------
    [31] : <Rx> - 12:51:20.849
    -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         : 0xFE41 (GapAdv_destroy)
     DataLength     : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 7F 06 00 41 FE 00                      ......A..
    --------------------------------------------------------------------
    [32] : <Tx> - 12:51:38.544
    -Type           : 0x01 (Command)
    -OpCode         : 0xFC0C (HCIExt_SetBDADDRCmd)
    -Data Length    : 0x06 (6) byte(s)
     BLEAddress     : 11:55:33:44:55:66
    Dump(Tx):
    0000:01 0C FC 06 66 55 44 33 55 11                   ....fUD3U.
    --------------------------------------------------------------------
    [33] : <Rx> - 12:51:38.570
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (HCI_LE_ExtEvent)
    -Data Length    : 0x05 (5) bytes(s)
     Event          : 0x040C (1036) (HCIExt_SetBDADDRCmdDone)
     Status         : 0x00 (0) (SUCCESS)
     CmdOpCode      : 0xFC0C (HCIExt_SetBDADDRCmd)
    Dump(Rx):
    0000:04 FF 05 0C 04 00 0C FC                         ........
    --------------------------------------------------------------------
    [34] : <Tx> - 12:51:45.584
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE3E (GapAdv_create)
    -Data Length    : 0x15 (21) byte(s)
     Properties     : 0x0013 (19) (
                      GAP_ADV_PROP_CONNECTABLE
                      GAP_ADV_PROP_SCANNABLE
                      GAP_ADV_PROP_LEGACY)
     IntervalMin    : 0x0000A0 (160)
     IntervalMax    : 0x0000A0 (160)
     PrimaryChMap   : 0x07 (7) (
                      GAP_ADV_CHAN_37
                      GAP_ADV_CHAN_38
                      GAP_ADV_CHAN_39)
     PeerAddrType   : 0x00 (0) (PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID)
     PeerAddress    : 00:00:00:00:00:00
     FilterPolicy   : 0x00 (0) (
                      AdvFilterPolicy Bit Mask Is Not Set)
     TxPower        : 0x7F (127)
     PrimaryPHY     : 0x01 (1) (GAP_ADV_PRIM_PHY_1_MBPS)
     SecondaryPHY   : 0x01 (1) (GAP_ADV_SEC_PHY_1_MBPS)
     SID            : 0x00 (0)
    Dump(Tx):
    0000:01 3E FE 15 13 00 A0 00 00 A0 00 00 07 00 00 00 .>..............
    0010:00 00 00 00 00 7F 01 01 00                      .........
    --------------------------------------------------------------------
    [35] : <Rx> - 12:51:45.610
    -Type           : 0x04 (Event)
    -EventCode      : 0x00FF (HCI_LE_ExtEvent)
    -Data Length    : 0x07 (7) bytes(s)
     Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
     Status         : 0x00 (0) (SUCCESS)
     OpCode         : 0xFE3E (GapAdv_create)
     DataLength     : 0x01 (1)
     Handle         : 0x00 (0)
    Dump(Rx):
    0000:04 FF 07 7F 06 00 3E FE 01 00                   ......>...
    --------------------------------------------------------------------
    [36] : <Tx> - 12:51:48.304
    -Type           : 0x01 (Command)
    -OpCode         : 0xFE3F (GapAdv_enable)
    -Data Length    : 0x04 (4) byte(s)
     Handle         : 0x00 (0)
     EnableOptions  : 0x00 (0) (GAP_ADV_ENABLE_OPTIONS_USE_MAX)
     DurationMaxEvnt: 0x0000 (0)
    Dump(Tx):
    0000:01 3F FE 04 00 00 00 00                         .?......
    --------------------------------------------------------------------
    [37] : <Rx> - 12:51:48.325
    -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         : 0xFE3F (GapAdv_enable)
     DataLength     : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 7F 06 00 3F FE 00                      ......?..
    

  • Hi,

    Thanks for your reply.

    If I want to advertise with 'another' specific bdaddr during the device is advertising with simple_peripheral (ble5), what should I do?

    do the following function correct ? Is the 'GapAdv_destroy' function necessary or not ? 

    int changeAdvBDaddress(){
        uint8 bdAddress[6] = { 0x00, 0x11, 0x22, 0xAA, 0x55, 0x66 };
        bStatus_t status = FAILURE;
        
        GapAdv_destroy(advHandleLegacy,GAP_ADV_FREE_OPTION_ALL_DATA);
        GapAdv_destroy(advHandleLongRange,GAP_ADV_FREE_OPTION_ALL_DATA);
        HCI_EXT_SetBDADDRCmd(bdAddress);
        // Create Advertisement set #1 and assign handle
        status = GapAdv_create(&SimpleSerialSocketServer_advCB, &advParamLegacy,
                               &advHandleLegacy);
        // Create Advertisement set #2 and assign handle
        status = GapAdv_create(&SimpleSerialSocketServer_advCB, &advParamLongRange,
                               &advHandleLongRange);
        //enable advertising
        GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
        GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
        return 0;
    }

  • To be clear, I don't think you can advertise simultaneous advertisements with different BD_ADDR's.

    That being said, I don't see an issue with the logic above. I would encourage you to try it out on your end and see if your central can discover the updated advertisement with the new BD_ADDR.