基本的参数据如下:希望高手解答
/*********************************************************************
* CONSTANTS
*/
// Enable/Disable Unlimited Scanning Feature
#define ENABLE_UNLIMITED_SCAN_RES TRUE
// Maximum number of scan responses
// this can only be set to 15 because that is the maximum
// amount of item actions the menu module supports
#define DEFAULT_MAX_SCAN_RES 15
// Advertising interval when device is discoverable (units of 625us, 160=100ms)
#define DEFAULT_ADVERTISING_INTERVAL 32
// Limited discoverable mode advertises for 30.72s, and then stops
// General discoverable mode advertises indefinitely
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
// Connection parameters
#define DEFAULT_CONN_INT 10 //200 //mod lhj 190905
#define DEFAULT_CONN_TIMEOUT 1000
#define DEFAULT_CONN_LATENCY 0
// Default service discovery timer delay in ms
#define DEFAULT_SVC_DISCOVERY_DELAY 1000
// Scan parameters
#define DEFAULT_SCAN_DURATION 0//0//4000//2000 //mod lhj 190906 // 值越小,则发现的同一设备广播包越多
#define DEFAULT_SCAN_WIND 10 //120 //#define DEFAULT_SCAN_INT 10 //120
// Discovey mode (limited, general, all)
#define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL //mod lhj 190929 @@@ DEVDISC_MODE_GENERAL
// TRUE to use active scan
#define DEFAULT_DISCOVERY_ACTIVE_SCAN FALSE
// Set desired policy to use during discovery (use values from GAP_Disc_Filter_Policies)
#define DEFAULT_DISCOVERY_WHITE_LIST GAP_DISC_FILTER_POLICY_ALL
// TRUE to use high scan duty cycle when creating link
#define DEFAULT_LINK_HIGH_DUTY_CYCLE FALSE
// TRUE to use white list when creating link
#define DEFAULT_LINK_WHITE_LIST FALSE
huijun li:
这种主机听不到从机的广播现象,是哪没有配置正确嘛?
Alvin Chen:
回复 huijun li:
你每次都能扫描完15个设备吗?
试试以下参数:
Scan interval: 150 milliseconds(ms)
Scan window: 150 milliseconds(ms)
Scan duration: 5 seconds(s)
Scan type: Passive
When setting the scan interval equal to the scan window the device will scan continuously. On the other hand, if the scan interval is larger than the scan window the device will duty-cycle scanning.
huijun li:
回复 Alvin Chen:
非常感谢您的回答,还有些疑问
1。现在从机设备没有15个,怎么能看出来扫描完了15个设备啊?我的扫描配置一直是在扫描,当发现没有扫到从机广播时,用串口打印出数据证明主机还在扫描。
2。Scan duration: 5 seconds(s) 此项我配置的是0,处于一直扫描
3。Scan type: Passive 此项具体在哪里配置呢
Alvin Chen:
回复 huijun li:
我在问你有没有这么多设备,如果设备很多扫描不到很正常。
DEFAULT_DISCOVERY_ACTIVE_SCAN TRUE Choose between active and passive scanning
huijun li:
回复 Alvin Chen:
哦哦,我这就4,5个设备。没有那么多。
#define DEFAULT_DISCOVERY_ACTIVE_SCANFALSE这个参数我这边一直设置的是false,主动扫描和被动扫描区别是什么啊?
Alvin Chen:
回复 huijun li:
你这个问题与active scanning 和passive scanning 无关。你主机和从机距离如何 ,RSSI如何?
thinkingiot.blogspot.com/…/bluetooth-low-energy-developers_20.html
huijun li:
回复 Alvin Chen:
距离上挺近的十几二十cm
Alvin Chen:
回复 huijun li:
很奇怪,你都烧录原始central 和peripheral 也不可以吗?
huijun li:
回复 Alvin Chen:
监听时间我加长了,现在感觉可以,后续在测试一下看有没有问题。多谢了。