Notifications and GATTC_CMP_EVT

5 posts / 0 new
Last post
Joacimwe
Offline
Last seen:1 year 3 months ago
Guru
加入:2014-01-14 06:45
Notifications and GATTC_CMP_EVT

Inhttp://support.dialog-semiconductor.com/resource/gatt-interface-specific..., I can read the following for notifications:

"Sending Notification: req_type shall be set to GATTC_NOTIFY. GATTC_CMP_EVT message is sent back as soon as notification PDU has been sent over the air."

However, I doubt that is the truth. In my code, I send one notification at a time, and the next notification is sent after the GATTC_CMP_EVT has arrived (which should indicate that the previous notification PDU has been sent over the air). But in SmartSnippets I can see that multiple notifications are sent during a single connection interval and using a sniffer, I also see that the More Data flag is set to true in all notifications except the last one. But that flag can't possibly be set to true if I send the next notification after the previous one has been sent over the air, since it doesn't know at that time that I will send another notification.

My question is, when is the GATTC_CMP_EVT message really sent? Maybe when the notification has been put in some ble tx buffer?

Keywords:
Device:
RvA
Offline
Last seen:5 hours 43 min ago
工作人员
加入:2014-02-07 14:10
Hi Joacimwe,

Hi Joacimwe,

Sorry for the delay. I got the following suggestion. Originally only the last pdu would be stored.

The larger font portions reflect our changes:

/**

****************************************************************************************

* @brief Handles reception of the @ref GATT_WRITE_CMD_IND message.

* @param[in] msgid Id of the message received (probably unused).

* @param[in] param Pointer to the parameters of the message.

* @param[in] dest_id ID of the receiving task instance (probably unused).

* @param[在]rc_id ID of the sending task instance.

* @return If the message was consumed or not.

****************************************************************************************

*/

static uint8_t sample128_1_buffer[200];

static int gattc_write_cmd_ind_handler(ke_msg_id_t const msgid,
struct gattc_write_cmd_ind const *param,

ke_task_id_t const dest_id,

ke_task_id_t const src_id)

{

uint8_t char_code = SAMPLE128_ERR_CHAR;

uint8_t status = PRF_APP_ERROR;

if (KE_IDX_GET(src_id) == sample128_env.con_info.conidx)

{

if (param->handle == sample128_env.sample128_shdl + SAMPLE128_1_IDX_VAL)

{

char_code = SAMPLE128_1_CHAR;

}

if (param->handle == sample128_env.sample128_shdl + SAMPLE128_2_IDX_CFG)

{

char_code = SAMPLE128_2_CFG;

}

if (char_code == SAMPLE128_1_CHAR)

{

//Save value in Buffer

memcpy(&sample128_1_buffer[param->offset], ¶m->value[0],param->length);

if(param->last)

{

sample128_send_val((uint8_t *)&sample128_1_buffer[0],param->offset + param->length);

attmdb_att_set_value(param->handle, param->offset + param->length, (uint8_t *)&sample128_1_buffer[0]);

}

status = PRF_ERR_OK;

}

else if (char_code == SAMPLE128_2_CFG)

{

// Written value

uint16_t ntf_cfg;

// Extract value before check

ntf_cfg = co_read16p(¶m->value[0]);

// Only update configuration if value for stop or notification enable

if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF))

{

//Save value in DB

attmdb_att_set_value(param->handle, sizeof(uint16_t), (uint8_t *)¶m->value[0]);

// Conserve information in environment

if (ntf_cfg == PRF_CLI_START_NTF)

{

// Ntf cfg bit set to 1

sample128_env.feature |= PRF_CLI_START_NTF;

}

else

{

// Ntf cfg bit set to 0

sample128_env.feature &= ~PRF_CLI_START_NTF;

}

status = PRF_ERR_OK;

}

}

}

// Send Write Response

atts_write_rsp_send(sample128_env.con_info.conidx, param->handle, status);

return (KE_MSG_CONSUMED);

}

Joacimwe
Offline
Last seen:1 year 3 months ago
Guru
加入:2014-01-14 06:45
I'm sorry but what has

I'm sorry but what has fragmented writes to do with my question about notifications and GATTC_CMP_EVT?

RvA
Offline
Last seen:5 hours 43 min ago
工作人员
加入:2014-02-07 14:10
Yes you are right. Actually

Yes you are right. Actually in the handling of BLE stack, the GATTC_CMP_EVT will be sent at the time of the PDU getting packed and submitted to L2CC task for sending, not wait until the PDU is really sent out. So before the next communicable connection event is arrived, maybe multiple PDUs are waiting for the transmission, and they will be sent out within one connection event.

Best regards, RvA

Joacimwe
Offline
Last seen:1 year 3 months ago
Guru
加入:2014-01-14 06:45
Thank you

Thank you

Topic locked