Building tasks and the connection index conidx

3 posts / 0 new
Last post
brian
Offline
Last seen:5 years 11 months ago
Expert Master
Joined:2014-10-16 18:10
Building tasks and the connection index conidx

I am confused by KE_BUILD_ID(TASK_*, conidx) versus using just TASK_* when creating a message. Mainly, when to use it and when not to use it. I think it is a way to create an instance or if we were doing C++ an instance of a class. Obviously I can't use it while invoking a connection because I don't have a conidx yet. This parameter is not defined until one gets a connection indication. I assume that means one cannot try and connect to two devices simultaneously.

我的假设是,一个连接后,所有message creations must tack on the conidx to the destination task using the macro. That would be things like all service discovery and related calls, pairing and bonding procedures, writing and reading characteristics/descriptors, and disconnects (perhaps there are more). Is this a correct assumption?

PY_Dialog
Offline
Last seen:2 years 7 months ago
Staff
Joined:2014-08-25 09:59
Hi Brian,

Hi Brian,

TASK_TASKNAME defines the id for a task, but this is not related to any link. Then macro KE_BUILD_ID will bind a task with specific link.

Regards!
PY

brian
Offline
Last seen:5 years 11 months ago
Expert Master
Joined:2014-10-16 18:10
Okay, then am I correct that

Okay, then am I correct that once connected I should use the KE_BUILD_ID to invoke service discovery, pairing, bonding, reads/writes, disconnects, etc. on a connected device;

For example this
struct gapc_bond_cmd * bond_cmd = KE_MSG_ALLOC(GAPC_BOND_CMD, KE_BUILD_ID(TASK_GAPC, device->conidx), TASK_APP, gapc_bond_cmd);

and not this
struct gapc_bond_cmd * bond_cmd = KE_MSG_ALLOC(GAPC_BOND_CMD, TASK_GAPC, TASK_APP, gapc_bond_cmd);

Both work, but I assume that is because I have only been able to test with a single device and if I had multiple devices connected, the first would work and the second would fail.