Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Smart Bluetooth Forum Discussions

Anonymous
Not applicable

Hi,

I have some questions related to starting connections in a central role. Basically I would like to know what the control flow would have to be if I want to initiate a connection. From what I would guess now the following could work:

blecen_Conn(HIGH_CONN, evt->wd_addr, evt->addressType);

bleprofile_sendWriteCmd(0x002a,(uint8_t*)&current_msg , 2);

blecen_Conn(NO_CONN, NULL, 0);

I'm not sure though whether I have to wait for anything after blecen_Conn() or whether I can just assume that a connection exists upon completion.

For a start I would assume I don't have to worry about ConMux if only one connection exists at a time.

0 Likes
1 Solution

Yes, they are the same by registering callback for BLECM_APP_EVT_LINK_UP.

After connection is up, you can utilize emconinfo_getPtr() to know the role playing for current connection.

View solution in original post

3 Replies
JaWa_2142591
Level 5
Level 5
25 likes received 10 likes received First like received

hello_client provides a good example to show how a central scans and connects a peer peripheral.

To scan and connect the peripheral, you need,

  1. use blecen_Scan() to do a scan for the peripheral you want to connect
  2. if the peripheral is correctly sending undirected connectable adv, advertisement callback will be triggered, which can be registered by blecm_RegleAdvReportCb(). You will know addressType and bd addr from the callback
  3. with the bd addr you will know whom to connect by calling blecen_Conn(). Remember to stop scan activity by calling blecen_Scan(NO_SCAN) when you initialize a connect request
  4. after the connection is up (connection_up callback will be triggered), you can issue any att read/write commands

You don't have to care ConMux if you only connect to one peer device.

Anonymous
Not applicable

Regarding point 4 I noticed that it seems to be the same callback that is used if the device is in a peripheral role. Is that correct? I guess if I have to support the two roles I have to use the ConMux anyway. Although emconinfo_getPtr() could be used to decide between MASTER or SLAVE role, when having only one connection of each kind open this would be sufficient to decide what to do in the callback.

Thanks for your help.

Regards,

Kilian

0 Likes

Yes, they are the same by registering callback for BLECM_APP_EVT_LINK_UP.

After connection is up, you can utilize emconinfo_getPtr() to know the role playing for current connection.