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.

CC2640R2F Peripheral 和 Broadcaster 两种模式的 GAP Role Parameters 问题

Other Parts Discussed in Thread: CC2640R2F

Hi 大神们,请教个问题。

MCU 是 CC2640R2F;

SDK 包是 simplelink_cc2640r2_sdk_4_20_00_04;

对于 simple_peripheral 和 simple_broadcaster 这两个,他们的 advertData[] 这个数组成员不一样,请问为什么成员会不一样?

如果我想把 simple_peripheral  的也改成 simple_broadcaster ,该怎样修改。

simple_peripheral 的 advertData[] 

// Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertising)
static uint8_t advertData[] =
{
// Flags: this field sets the device to use general discoverable
// mode (advertises indefinitely) instead of general
// discoverable mode (advertise for 30 seconds at a time)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// service UUID, to notify central devices what services are included
// in this peripheral
0x03, // length of this data
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
LO_UINT16(SIMPLEPROFILE_SERV_UUID),
HI_UINT16(SIMPLEPROFILE_SERV_UUID)
};

simple_broadcaster 的 advertData[] 
// GAP - Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertisting)
static uint8 advertData[] =
{
// Flags; this sets the device to use limited discoverable
// mode (advertises for 30 seconds at a time) instead of general
// discoverable mode (advertises indefinitely)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

#ifndef BEACON_FEATURE

// three-byte broadcast of the data "1 2 3"
0x04, // length of this data including the data type byte
GAP_ADTYPE_MANUFACTURER_SPECIFIC, // manufacturer specific adv data type
1,
2,
3

#else

// 25 byte beacon advertisement data
// Preamble: Company ID - 0x000D for TI, refer to www.bluetooth.org/.../company-identifiers
// Data type: Beacon (0x02)
// Data length: 0x15
// UUID: 00000000-0000-0000-0000-000000000000 (null beacon)
// Major: 1 (0x0001)
// Minor: 1 (0x0001)
// Measured Power: -59 (0xc5)
0x1A, // length of this data including the data type byte
GAP_ADTYPE_MANUFACTURER_SPECIFIC, // manufacturer specific adv data type
0x0D, // Company ID - Fixed
0x00, // Company ID - Fixed
0x02, // Data Type - Fixed
0x15, // Data Length - Fixed
0x00, // UUID - Variable based on different use cases/applications
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // UUID
0x00, // Major
0x01, // Major
0x00, // Minor
0x01, // Minor
0xc5 // Power - The 2's complement of the calibrated Tx Power

#endif // !BEACON_FEATURE
};

  • 广播内容不一样,这个可以自己改。具体规则如下:

    A、长度 Len ,表示这个 AD Structure 的长度(除去 len本身 1)

    B、类型 AD Type,标记这段广播数据代表什么, 比如设备名, uuid 等。

    C、数据 AD data

    此为有效数据部分,如果有效数据部分不到 31 字节,剩下的就用 0 补全,此为无效数据部分。而广播数据类型有以下这些:

    (1)、FLAGS:

    对于低功耗蓝牙设备, 广播中需要包括的一个 Structure, 包含一个byte 的标记, 标记设备
    Flags used over the LE physical channel are:

    • Limited Discoverable Mode
    • General Discoverable Mode
    • BR/EDR Not Supported
    • Simultaneous LE and BR/EDR to Same Device Capable (Controller)
    • Simultaneous LE and BR/EDR to Same Device Capable (Host)

    更具体及下文内容的详细定义在gap.h

    (2)、Service UUID: 广播数据中一般都会把设备支持的 GATT Service 广播出来,用来告诉外面本设备所支持的 Service。有三种类型的 UUID:16 bit, 32bit, 128 bit。广播中,每种类型类型有有两个类别:完整和非完整的。这样就共有 6 种 AD Type。
    非完整的 16 bit UUID 列表: TYPE = 0x02;
    完整的 16 bit UUID 列表: TYPE = 0x03;
    非完整的 32 bit UUID 列表: TYPE = 0x04;
    完整的 32 bit UUID 列表: TYPE = 0x05;
    非完整的 128 bit UUID 列表: TYPE = 0x06;
    完整的 128 bit UUID 列表: TYPE = 0x07;

    (3)、Local name[设备名称]

    数据部分是名称的字符串, Local Name 可以是设备的全名,也可以是设备名字的缩写,其中缩写必须是全名的前面的若干字符。 设备全名: TYPE = 0x08 设备简称: TYPE = 0x09

    /// Shortened local name

    #define GAP_ADTYPE_LOCAL_NAME_SHORT            0x08

    /// Complete local name

    #define GAP_ADTYPE_LOCAL_NAME_COMPLETE         0x09

    还有TX Power Level,带外安全管理(Security Manager Out of Band),外设(Slave)连接间隔范围等等内容,用户也可自行添加

  • Hi Viki,谢谢了,我先研究下,非常感谢~~
  • Hi Viki:

    那我可不可以直接把 simple_broadcaster 的数据拿到 simple_peripheral 里用?

    谢谢
  • Hi Viki:

    那我可不可以直接把 simple_broadcaster 的数据拿到 simple_peripheral 里用?

    谢谢
  • Dear Viki Shi

    Where could I download the related documents of the Advertising Content Structure?
    Would you please provide me related documents?
  • 那我可不可以直接把 simple_broadcaster 的数据拿到 simple_peripheral 里用?-----可以
  • 这个图我也是网上找的,详细的内容可以去看BLE spec
  • Hi Viki,问题已解决,谢谢~
  • 解决就好,不客气