7个帖子/ 0新
Last post
R.Gantner.
Offline
Last seen:6天前1周
加入:2014-01-18 13:57
连接而不扫描?

Device A and Device B advertising some measurement data every 10 Seconds. Every hour Device A has to exchange some data with Device B. So on Device A I change the role to a Master - scan for Device B - connect to Device B - exchange Data - change role back to advertiser.
In average it needs 5 sec for the Scan and 10 sec for the connect.
Is it possible the connect directly (the BD address is always the same) without the scan ?
I have to save battery energy on both devices us much as possible.

设备:
Gongyu_Dialog
Offline
Last seen:5 days 22 hours ago
加入:2016-04-27 07:07
you can call the direct

您可以调用直接广告模式功能。

check in sdk5 , you can set the BD address in

static const struct inction_advertise_configuration user_directed_advertise_target_address_conf = {
/// BD Address of device
.addr = {0x1,0x2,0x3,0x4,0x5,0x6},
///设备的地址类型0 = public / 1 =私有随机
.addr_type = 0.
};

R.Gantner.
Offline
Last seen:6天前1周
加入:2014-01-18 13:57
谢谢,

谢谢,
我仍然需要通过其他主机查看广告数据(测量),直接广告将隐藏给他人(据我所知)。
在范围上,它看起来像扫描期间,第一个广告触发连接和第二广告都是连接。
Perhaps a scanning white list will help to avoid the second delay or is the white list only a filter ?

MT_dialog
Offline
Last seen:2周14小时前
Staff
加入:2015-06-08 11:34
嗨r.ganter,

嗨r.ganter,

The connection sequence doesn't require two advertising messages in order to estalish a connection, after the central gets the first advetising message it responds with a connection request and you should not see any advertising after the connecion request from the central is sent. Regarding the white list on a central, it limits the advertising indications at the application level depending on the db address of the advertiser.

Thanks MT_dialog

R.Gantner.
Offline
Last seen:6天前1周
加入:2014-01-18 13:57
嗨mt_dialog.

嗨mt_dialog.

A test with a minimal modified DSPS v_5.150.2 sps_host project shows that the connection is delayed by one advertisement !
我的从设备80:EA:CA:67:05每4秒广告。
中央80:EA:CA:67:06需要接收第一个广告,以从扫描到连接(只听侦听和没有2.4 GHz TX活动),并且稍后将发送到从站的一个广告。
我用范围,RF功率计和BLE嗅探器测试了几次。

modification in "user_device_host.c" :

void user_on_adv_report_ind(struct gapm_adv_report_ind const * param)
{

// if(!memcmp(¶m->report.data[3], USER_ADVERTISE_DATA, USER_ADVERTISE_DATA_LEN))
if(!memcmp(¶m->report.adv_addr.addr, "\x05\x00\x67\xCA\xEA\x80", 6)) //!RG!
{
ARCH_PRINTF(“连接%02x%02x%02x%02x%02x%02x”,
param->report.adv_addr.addr[5],
param-> eport.addr.addr [4],
param->report.adv_addr.addr[3],
param->report.adv_addr.addr[2],
param->report.adv_addr.addr[1],
param->report.adv_addr.addr[0]);
app_easy_gap_start_connection_to_set(param->report.adv_addr_type, (uint8_t *)¶m->report.adv_addr.addr, MS_TO_DOUBLESLOTS(USER_CON_INTV));
user_gapm_cancel();
}
}

Joacimwe.
Offline
Last seen:1 year 4 months ago
格鲁鲁
加入:2014-01-14 06:45
Hi.

Hi.

Directed advertising does just mean that the advertisement packet includes the target address. Each scanner will filter away advertisement packets that are directed that does not match its own address.

如果您已经设置了第一次扫描的程序,并且在找到外设后,请启动连接,然后将需要两个广告数据包。连接请求只能直接响应广告数据包发送。如果您在CPU中有代码处理广告包,然后切换到启动状态,那么该代码将花费太长,广告商已经回到睡眠状态,因为它没有收到任何东西以响应其广告数据包。

如果你想联系的人,只有一个乱发广告tisement packet you need to skip putting the master into scanning state and instead directly go to the initiating state, i.e. start connect directly and don't start scan. Since you always connect to the same peripheral, this should be the way to go.

Note that scanning and initiating a connection are both energy-consuming states. For both of those, you have to define a scanning window and scanning interval that defines how often and how long the radio will be active listening for incoming advertisement packets. While the radio is active, it consumes 5 mA. If you have an advertisement interval of 4 seconds, the expected time the scanner must have its radio on before it finds the advertisement packet is 2 seconds. If you know that the peripheral will always be nearby, there is no point having the scanning window smaller than the scanning interval in order to trying to save energy. You will rather use the same amount of expected energy but instead waste time.

广告时,无线电必须只有几毫秒才能发送其三个广告数据包,然后它将休息休息时间,因此广告消耗的方式较少的能量而不是扫描。考虑到这一点,根据您的设置,如果您想在掌握上节省能源,则应在外围设备上具有更短的广告间隔。由于您每小时这样做,设备A应该知道一个小时已通过,设备B可能会开始尝试连接到A.当一小时过去时,可以使用更短的广告间隔。但当然,如果你对主人必须拥有它的无线电每次想要连接时必须有其无线电,你可以继续拥有4秒的广告间隔......

R.Gantner.
Offline
Last seen:6天前1周
加入:2014-01-18 13:57
谢谢很多

谢谢很多detailed description.

所以是的,是我初步问题的答案。
After changing the role to master I connect directly without a scan. In average it will take 1/2 the advertisement interval. To balance the average power consumption between device A (advertiser) and B (master) I calculated the optimum advertising interval = 3.8 sec:
Qadv = 10 uAs // Consumption per advertising event
ISCAN = 5000 UA //电流消耗扫描
tadv =?//广告间隔
Tscan = 3600 s // average time between scans = 1 h
Msc = 0.5 // relation = scan-duration / adv-interval

Average advertising current (device A) = Qadv / Tadv
平均扫描电流(设备B)= ISCAN * tadv * MSC / TSCan

Tadv = SQRT ( (Qadv * Tscan) / (Iscan * Msc) ) = SQRT ( (10 * 3600) / (5000 * 0.5) ) = 3.8 sec
因此,设备A具有10uAS / 3.8S = 2.63 UA的额外电流
和设备B 5000UA * 3.8 * 0.5 / 3600 = 2.64 UA

Topic locked