以广播者为例,在simpleBLEBroadcaster.c中:
1.设置广告持续时间
//Maximum time to remain advertising, when in Limited Discoverable mode. unit is seconds
#define LIMIT_ADV_TIMEOUT 30
2.广播数组中修改广播模式(设置使用有限可发现模式)
//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_LIMITED| GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
// 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 advertisement data type
1,
2,
3
};
3.使能修改广