同时与两个外围设备连接

16个新帖子/ 0
最后一篇
匿名(未经验证)
同时与两个外围设备连接

Dear all,
你好,
一世want to connect with two peripherals from a central simultaneously. I can connect to one of the peripherals and at the same time scan for other module. However, after detecting the other one I can't connect to that. Any advice is appreciated.
谢谢

设备:
reza.yazdani67(未经验证)
没有人有任何想法!?

没有人有任何想法!?

Lyncxy119
离线
最后一次露面:12个月前1年
加入:2015-05-14 03:23
嗨,也许是BD地址

嗨,也许BD地址不应该是一样的。

reza.yazdani67(未经验证)
谢谢,我使用不同的bd

谢谢,我使用不同的bdaddresses, but still I can't connect to two peripherals simultaneously. I must disconnect from one to connect to the other one.
As Dialog says, I can connect to 6 peripherals at the same time. However, I am unable to connect to even two of them.
有人帮忙吗?如果要发送start_connection命令时,我应该更改任何参数吗?

reza.yazdani67(未经验证)
我设置的参数

I for Start Connection命令设置的参数如下:
msg->nb_peers = 5;
memcpy(&msg->对等体[0] .addr,&connect_bdaddr [device_num],bd_addr_len);
msg-> con_intv_min = 10;
msg-> con_intv_max = 10;
msg->ce_len_min = 32;
msg-> ce_len_max = 32;
msg-> con_latency = 0;
msg-> op.addr_src = gapm_public_addr;
msg->对等体[0] .addr_type = gapm_public_addr;
msg-> superv_to = 100;
msg-> scan_interval = 384;
msg->scan_window = 352;
msg-> op.code = gapm_connection_direct;

reza.yazdani67(未经验证)
对话,

对话,
你好,
你能给我一些建议吗?
是否有任何示例代码,您可能会向我转发?
我的电子邮件地址是资源文件格式a.yazdani1367@gmail.com
谢谢

Joacimwe.
离线
最后一次露面:1 year 5 months ago
Guru
加入:2014-01-14 06:45
nb_peers应该设置为1

NB_PEERS应设置为1(而不是5)以进行直接连接。您确定是否正确地将消息对象正确分配,正确尺寸?

You also have to change a #define in da14580_config.h with the maximum number of simultaneous peripherals you want to support.

reza.yazdani67(未经验证)
谢谢Joacimwe。

谢谢Joacimwe。
我根据我在以下链接中看到的对话人员(名为RVA)中的某些人的一些建议来更改对等体(NB_PEERS)的数量:
http://support.dialog-semicondiondiondum/connection- multiple-peripheral.
我使用的消息分配类似于DSPS应用程序中使用的内容:
msg = (struct gapm_start_connection_cmd *) KE_MSG_ALLOC(GAPM_START_CONNECTION_CMD , TASK_GAPM, TASK_APP, gapm_start_connection_cmd);
它是否足以在da14580_config.h中增加同时外设(ble_connection_max_user)的数量!?或者我应该改变其他参数!?
我会尽快完成您提到的更改,并让您了解结果。我真的很感激你的帮助,谢谢。

reza.yazdani67(未经验证)
我做了我认为的所有变化

我做了我认为的所有变化is needed to have two peripherals connected to one central simultaneously. I also used UM-B-011 DA14580 MemoryMapTool to correct the memory map in da14580_config.h. But nothing works out! I don't know what else I should do.
是正确的,我应该一个接一个地连接到所有外围设备!?
有人可以帮忙吗?
对话,请你给我任何建议吗?

Joacimwe.
离线
最后一次露面:1 year 5 months ago
Guru
加入:2014-01-14 06:45
可变长度的消息

具有可变长度的消息(在这种情况下,对等体的数量)必须与如下所示的ke_msg_alloc_dyn分配:
KE_MSG_ALLOC_DYN(GAPM_START_CONNECTION_CMD,TASK_GAPM,TASK_APP,GAPM_START_CONNECTION_CMD,NB_PEERS * SIZEOF(结构GAP_BDADDR)),其中NB_PEERS应该与MSG-> NB_PEERS相同的数字。

如上所述http://support.dialog-semicondiondiondum/resource/gap-interface-specifica ...,NB_PEERS为GAPM_CONNECTION_DIRECT为1。

一世f you do this together with setting BLE_CONNECTION_MAX_USER, that should be enough. Just make sure you initiate a direct connect two times, first for the first peripheral (with its mac address put into msg->gap_bdaddr[0]), and then to the second peripheral (with its mac address put into msg->gap_bdaddr[0]). Note that you must wait until the first one has connected until you can start the connection of the second one. (Wait until GAPM_CMP_EVT). Other BLE chips support multiple simultaneous pending connections, but the DA14580 doesn't seem to do that. Instead you can scan for multiple peripherals and initiate a direct connection as soon as one of interest appears (but then you might want to have a timeout for this direct connection and go back to scan if you can't connect in say 30 seconds).

reza.yazdani67(未经验证)
Thanks for your help.

Thanks for your help.
最后,我将两个模块连接到一个中心。
我认为问题是我没有等到连接完成并在接收到GAPC_CONNECTION_REQ_IN后启动下一个连接。但是,正如您所说,我应该在收到GAPM_CMP_EVT后开始下一次连接。我非常感谢你的建议。
我还有另一个问题关于我必须等到的时间,直到BLE Central可以连接到第二个外围模块。正如我多次测试的那样,我无法衡量可预测的时间。所以,我关心我如何设置这个时序。如果我从一个中央连接到两个模块,我应该定义两个单独的配置文件处理它们!?
我非常感谢您提前考虑。

Joacimwe.
离线
最后一次露面:1 year 5 months ago
Guru
加入:2014-01-14 06:45
你应该能够

你应该能够immediately connect to the second peripheral once you receive GAPM_CMP_EVT (with the operation parameter set to GAPM_CONNECTION_DIRECT) so you don't have to add some delay before you connect to the next peripheral. The GAPM_CMP_EVT message is normally sent immediately after GAPC_CONNECTION_REQ_IND.
Note that the "state" of the TASK_APP as it is done in the template project (idle, advertising, connected, ...) doesn't really make sense when you have multiple peripherals in central mode. You should instead keep track somehow for each peripheral that is connected in some other way.

reza.yazdani67(未经验证)
谢谢你的建议。

谢谢你的建议。
我正如你所说的那样,但在连接到第一个后,我无法立即连接到第二个设备。
我认为可能是因为能够从第一连接设备从我不能立即有第二连接的第一连接设备接收通知事件。因此,我以第二个连接后启用了配置文件的方式更改了程序。但是,我无法连接到第二个设备而无需不可预测的延迟!
Do you have any idea how I can reduce the delay or at least have a predictable delay!?

Joacimwe.
离线
最后一次露面:1 year 5 months ago
Guru
加入:2014-01-14 06:45
我以前没见过这个。一世

我以前没见过这个。一世can connect directly to the second one after GAPM_CMP_EVT...
相反会发生什么?您是否以非零状态代码获得GAPM_CMP_EVT,或者根本没有发生任何事情?
你能看到使用智能片段电流测量来看看发生了什么吗?

Try to increase your connection interval and reduce the scan window/interval so the da14580 is not busy with connection events of the first peripheral while it scans for the second one.

reza.yazdani67(未经验证)
谢谢,我会检查一下这个

谢谢,我会检查一下这个solution too.
一世think nothing happens at all because I use a serial monitoring program to see when and why the app is going to the handler of GAPM_CMP_EVT. However I will check that again to see if I am missing something or not!
我真的很感激你的帮助。

reza.yazdani67(未经验证)
Finally, I found what is

最后,我发现在连接到第一个后,我无法在第二个设备上连接到第二个设备是什么问题。
一世t is just about some parameters that was set in the app_connect function! If I change the parameter setting as follows and leave the other parameters to be set to their default value, all the things work correctly and no unpredictable delay happens at all!

msg =(struct gapm_start_connection_cmd *)ke_msg_alloc_dyn(gapm_start_connection_cmd,task_gapm,task_app,
gapm_start_connection_cmd,sizeof(struct gap_bdaddr));
msg-> nb_peers = 1;
memcpy(&msg->对等体[0] .addr,connect_bdaddr [index] .addr,bd_addr_len);
msg->con_intv_min = APP_CON_INTV_MIN;
msg->con_intv_max = APP_CON_INTV_MAX;
msg-> op.addr_src = gapm_public_addr;
msg->对等体[0] .addr_type = gapm_public_addr;
msg-> supmen_to = app_con_superv_to;
msg->scan_interval = APP_CON_SCAN_INTERVAL;
msg->scan_window = APP_CON_SCAN_WINDOW;
msg-> op.code = gapm_connection_direct;

主题锁定