Dear all,
Hi,
I have an issue when I am connecting to two modules simultaneously. I can't discover services and characteristics of the second device. Always I find the first device services and characteristics. I don't know how I can search for services separately. Is it possible to search for the second device services and characteristics without discovering the first ones!?
Any help is appreciated so much.
Thank you.
Device:
anybody can help!?
Hi. As specified byhttp://support.dialog-semiconductor.com/system/files/resources/RW-BLE-GA..., a GATTC task is instantiated once a connection is established for each peripheral. You relate to each peripheral by sending GATT messages to the corresponding GATTC task. Each GATTC task has a "connection index", or "conidx". When you receive a message from a GATTC task (or a GAPC task which manages the connection itself), you can get the conidx by writing KE_IDX_GET(src_id) in the message handler. To send a message to the corresponding GATTC task, you build the GATTC task id by the macro KE_BUILD_ID(TASK_GATTC, conidx). It is when you handle the GAPC_CONNECTION_REQ_IND message you get the conidx for a connection the first time.
For example, in prf_disc_svc_send in prf_utils.c, the message that performs discovery by UUID is created by KE_MSG_ALLOC_DYN(GATTC_DISC_CMD, KE_BUILD_ID(TASK_GATTC, con_info->conidx), con_info->prf_id, gattc_disc_cmd, ATT_UUID_16_LEN);
The Dialog-provided client profiles internally keeps track of the conidx so if you use them you should be fine. Otherwise section 4.4 in RW-BLE-GATT-IS_1.pdf pretty much describes everything you need for service discovering and most of these messages have wrappers in prf_utils.c you could also use. Note that if you already know what services and characteristics there are on the remote peer and their ATT handles (for example by caching them), you can use the handles directly without the need to perform a service discovery each time it connects to write or read characteristics.