Connecting with two peripherals at the same time

16个帖子/ 0新
Last post
Anonymous (not verified)
Connecting with two peripherals at the same time

各位,
Hi,
我想同时从中央的两个外设连接。我可以连接到一个外围设备,同时扫描其他模块。但是,在检测到另一个后,我无法连接到该。任何建议都受到赞赏。
Thanks you

设备:
reza.yazdani67 (not verified)
No body has any idea!?

No body has any idea!?

lyncxy119
Offline
Last seen:1 year 12 months ago
Joined:2015-05-14 03:23
Hi, maybe the BD address

Hi, maybe the BD address should not be all the same.

reza.yazdani67 (not verified)
Thank you, I use different BD

谢谢,我使用不同的BD地址,但仍然我无法同时连接到两个外围设备。我必须断开与一个连接到另一个连接。
正如对话框所说,我可以同时连接到6个外围设备。但是,我无法连接到其中两个。
Can anybody help? should I change any parameter when want to send a start_connection command?

reza.yazdani67 (not verified)
The parameters I set for the

The parameters I set for the start connection command is as follows:
msg-> nb_peers = 5;
memcpy(&msg->peers[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->peers[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 (not verified)
Dialog,

Dialog,
Hi,
Could you please give me some advice?
是否有任何示例代码,您可能会向我转发?
My email isreza.yazdani1367@gmail.com..
Thank you

Joacimwe.
Offline
Last seen:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
nb_peers should be set to 1

nb_peers should be set to 1 (not 5) for direct connection. Are you sure you are allocating the message object correctly with the correct size?

您还必须在DA14580_CONFIG中更改#define,其中包含您要支持的最大同时外设数。

reza.yazdani67 (not verified)
Thanks Joacimwe.

Thanks Joacimwe.
I changed number of peers (nb_peers) based on some advice from a person in dialog staff (named RvA) that I saw in the following link:
http://support.dialog-semiconductor.com/connection-multiple-peripherals
The message allocation I used is like what is used in dsps application:
msg =(struct gapm_start_connection_cmd *)ke_msg_alloc(gapm_start_connection_cmd,task_gapm,task_app,gapm_start_connection_cmd);
Is it enough that I increase the number of simultaneous peripherals (BLE_CONNECTION_MAX_USER) in da14580_config.h!? Or should I change other parameters too!?
I will do the changes you mentioned and let you know of the result soon. I really appreciate your help, thank you.

reza.yazdani67 (not verified)
I did all the changes I think

我做了所有的改变,所以需要两个外围设备同时连接到一个中心。我还使用了UM-B-011 DA14580 MemoryMaptool来纠正DA14580_CONFIG中的内存映射。但没有什么能解决!我不知道我还应该怎么做。
Is it right that I should connect to all the peripherals one by one!?
Can somebody help?
Dialog, can you give me any advice on this, please?

Joacimwe.
Offline
Last seen:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
Messages with variable length

Messages with variable length (in this case the number of peers) must be allocated with KE_MSG_ALLOC_DYN like this:
KE_MSG_ALLOC_DYN(GAPM_START_CONNECTION_CMD , TASK_GAPM, TASK_APP, gapm_start_connection_cmd, nb_peers * sizeof(struct gap_bdaddr)) where nb_peers should be the same number you put into msg->nb_peers.

As stated inhttp://support.dialog-semiconductor.com/resource/gap-interface-specifica...1、nb_peers GAPM_CONNECTION_DIRECT。

如果您与设置BLE_CONNECTION_MAX_USER一起执行此操作,那应该足够。只需确保启动直接连接两次,首先为第一个外设(其MAC地址投入MSG-> GAP_BDADDR [0]),然后到第二个外围设备(其MAC地址投入MSG-> GAP_BDADDR [0])。请注意,您必须等到第一个已连接,直到您可以启动第二个连接。(等到GAPM_CMP_EVT)。其他BLE芯片支持多个同时挂起的连接,但DA14580似乎似乎没有那样。相反,您可以在出现的一个感兴趣之外扫描多个外围设备并启动直接连接(但是,如果您无法在发音30秒内无法连接,则可能希望对此直接连接进行超时,请返回扫描。

reza.yazdani67 (not verified)
谢谢你的帮助。

谢谢你的帮助。
At last, I connected two modules to a central.
I think the problem was that I didn't wait until a connection is completed and started next connection after receiving GAPC_CONNECTION_REQ_IN. However, as you said, I should start next connection after receiving GAPM_CMP_EVT. I really appreciate your advice.
I also have another question about the time that I must wait until BLE central can connect to the second peripheral module. As I have tested several times, I couldn't measure a predictable timing. So, I am concerned how I can set this timing. If I am connecting to two modules from a central, should I define two separate profiles handling each of them!?
I appreciate your consideration in advance.

Joacimwe.
Offline
Last seen:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
You should be able to

您应该能够在收到GapM_CMP_EVT(使用“操作参数设置为GAPM_CONNECTION_DIRECT)”后立即连接到第二个外围设备,以便在连接到下一个外设之前,您不必添加一些延迟。GAPC_CONNECTION_REQ_IND之后,通常会立即发送GAPM_CMP_EVT消息。
请注意,Task_App的“状态”在模板项目(空闲,广告,连接,...)中完成的“状态”在中央模式下有多个外设时,并不真正有意义。而是应以某种方式跟踪以某种方式连接的每个外设。

reza.yazdani67 (not verified)
Thanks for the advice.

Thanks for the advice.
I am doing just as you said, but I can't connect to the second device immediately after connecting to the first one.
I thought that it might be because of enabling sps profile and receiving notification events from the first connected device that I can't have second connection instantly. So, I changed the program in a way that the profile is enabled after second connection. However, I can't connect to the second device without an UNPREDICTABLE delay!!!
你知道如何减少延迟或至少有可预测的延迟!?

Joacimwe.
Offline
Last seen:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
我以前没见过这个。I

我以前没见过这个。在GAPM_CMP_EVT之后,我可以直接连接到第二个...
What happens instead? Are you getting an GAPM_CMP_EVT with a non-zero status code or does nothing happen at all?
Can you see using Smart Snippets current measurement to see what's happening?

尝试增加连接间隔并减少扫描窗口/间隔,因此DA14580不忙于第一个外设的连接事件,而第二个外围设备扫描。

reza.yazdani67 (not verified)
Thanks, I will check this

谢谢,我也会检查这个解决方案。
我觉得没有任何事情发生,因为我使用串行监控程序来查看应用程序何时何种以及为什么要将App _Cmp_evt的处理程序。但是我会再次检查,看看我是否错过了某些东西!
I really appreciate your help.

reza.yazdani67 (not verified)
最后,我找到了什么

最后,我找到了什么problem that I can't connect to the second device right after connecting to the first one.
它只是关于App_Connect函数中设置的一些参数!如果我如下更改参数设置并将其他参数设置为默认值,则所有内容都正常工作,根本不会发生不可预测的延迟!

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->peers[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->peers[0].addr_type = GAPM_PUBLIC_ADDR;
msg->superv_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;

Topic locked