This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Write request vs. indications

Hello :)

I have a question about the timing of sending a bluetooth write request.
I am using two nrf52 developement kits, one as master and one as slave.
From my master device I send a write request using sd_ble_gattc_write.
On my slave device this triggers a BLE_GATTS_EVT_WRITE.
Then on my master device I get a BLE_GATTC_EVT_WRITE_RSP.
My connection interval is 10ms. This all works fine.

My question is: why does it take longer than one connection event to trigger the BLE_GATTS_EVT_WRITE on my slave device?
I thought it would take less than one connection interval.

I did it the other way around, from Slave to Master using Indications.
Here the time from sending the packet from my slave device until receiving the packet on my master device was less than one connection interval, like I expected.

Why is it different the other way around?
Sorry for my bad English, I hope you can awnser my question.

Parents
  • Hi Kenneth,

    The timing problem is solved now, it had to do with my own timers I set wrong.

    Unfortunately I have a new problem now.

    When I write to my slave device, I don't get a  BLE_GATTS_EVT_WRITE event anymore, on my slave device.

    I am still writing from my master device with sd_ble_gattc_write and I still get a BLE_GATTC_EVT_WRITE_RSP event, on my master device.

    I tried writing to my slave device with the Master Control Panel. When I do that the BLE_GATTS_EVT_WRITE does occur. So I think it's my master device which has the problem.

    Here is my code from my master device:

    tx_wrs_message_t * p_msg;
    uint16_t       cccd_val = true ? BLE_GATT_HVX_NOTIFICATION : 0;
       
    p_msg              = &m_tx_wrs_buffer[m_tx_wrs_insert_index++];
    m_tx_wrs_insert_index &= TX_WRS_BUFFER_MASK;
         
    uint16_t wrs_write_handle = p_ble_write_request->peer_write_db.wrs_write_handle;
        
        
    p_msg->req.write_req.gattc_params.handle   = wrs_write_handle;
    p_msg->req.write_req.gattc_params.len      = WRITE_WRS_MESSAGE_LENGTH;
    p_msg->req.write_req.gattc_params.p_value  = p_msg->req.write_req.gattc_value;
    p_msg->req.write_req.gattc_params.offset   = 0;
    p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;
    p_msg->req.write_req.gattc_value[0]        = LSB_16(cccd_val);
    p_msg->req.write_req.gattc_value[1]        = MSB_16(cccd_val);
    p_msg->conn_handle                         = p_ble_write_request->conn_handle;
    p_msg->type                                = WRITE_REQ_WRS;
        
       
    if (m_tx_wrs_index != m_tx_wrs_insert_index)
    {
              sd_ble_gattc_write(m_tx_wrs_buffer[m_tx_wrs_index].conn_handle,
                                              &m_tx_wrs_buffer[m_tx_wrs_index].req.write_req.gattc_params);
                       
              m_tx_wrs_index++;
              m_tx_wrs_index &= TX_WRS_BUFFER_MASK;
    }

    What could I be doing wrong?

    Can you please help me?

Reply
  • Hi Kenneth,

    The timing problem is solved now, it had to do with my own timers I set wrong.

    Unfortunately I have a new problem now.

    When I write to my slave device, I don't get a  BLE_GATTS_EVT_WRITE event anymore, on my slave device.

    I am still writing from my master device with sd_ble_gattc_write and I still get a BLE_GATTC_EVT_WRITE_RSP event, on my master device.

    I tried writing to my slave device with the Master Control Panel. When I do that the BLE_GATTS_EVT_WRITE does occur. So I think it's my master device which has the problem.

    Here is my code from my master device:

    tx_wrs_message_t * p_msg;
    uint16_t       cccd_val = true ? BLE_GATT_HVX_NOTIFICATION : 0;
       
    p_msg              = &m_tx_wrs_buffer[m_tx_wrs_insert_index++];
    m_tx_wrs_insert_index &= TX_WRS_BUFFER_MASK;
         
    uint16_t wrs_write_handle = p_ble_write_request->peer_write_db.wrs_write_handle;
        
        
    p_msg->req.write_req.gattc_params.handle   = wrs_write_handle;
    p_msg->req.write_req.gattc_params.len      = WRITE_WRS_MESSAGE_LENGTH;
    p_msg->req.write_req.gattc_params.p_value  = p_msg->req.write_req.gattc_value;
    p_msg->req.write_req.gattc_params.offset   = 0;
    p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;
    p_msg->req.write_req.gattc_value[0]        = LSB_16(cccd_val);
    p_msg->req.write_req.gattc_value[1]        = MSB_16(cccd_val);
    p_msg->conn_handle                         = p_ble_write_request->conn_handle;
    p_msg->type                                = WRITE_REQ_WRS;
        
       
    if (m_tx_wrs_index != m_tx_wrs_insert_index)
    {
              sd_ble_gattc_write(m_tx_wrs_buffer[m_tx_wrs_index].conn_handle,
                                              &m_tx_wrs_buffer[m_tx_wrs_index].req.write_req.gattc_params);
                       
              m_tx_wrs_index++;
              m_tx_wrs_index &= TX_WRS_BUFFER_MASK;
    }

    What could I be doing wrong?

    Can you please help me?

Children
Related