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

Long write only writes 4 packets

Hello,

I'm implementing long write function to my project.

I managed to get it working, but i can't send more than 68 bytes of data. When i'm sending the data, I slice it into <18bytes chunks and send each chunk with correct offset, using "BLE_GATT_OP_PREP_WRITE_REQ" as sending type. When all the data is through i use this command to execute the write: "BLE_GATT_OP_EXEC_WRITE_REQ".

Now no matter how much i send (if it's more than 68 bytes), only 68 bytes come through. When i looked into what comes through i saw that only FIRST 4 packets are recieved, even thought i execute when all packets are sent.

Why are other packets lost?

Best regards, Nejc

Parents
  • On a receiving side i handle my long write request like that:

    case BLE_GATTS_EVT_WRITE:
      LOG_INFO("BLE_GATTS_EVT_WRITE");
    break;
    case BLE_EVT_USER_MEM_REQUEST:
    LOG_INFO("MEM REQUEST");
    							
    mem_block.len = QUEUED_WRITE_BUFFER_SIZE;
    mem_block.p_mem = &queued_write_buffer[0];
    							
    error_code = sd_ble_user_mem_reply(m_conn_handle, &mem_block);
    if (error_code != NRF_SUCCESS) {
    LOG_INFO("ERROR sd_ble_user_mem_reply: %u\r\n", (unsigned int)error_code);
    } else {
      LOG_INFO("USER_MEM_REQUEST OK\r\n");
    }
    break;
    case BLE_EVT_USER_MEM_RELEASE:
    if ((p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.p_mem == mem_block.p_mem)&&(p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.len == mem_block.len))
    {
    LOG_INFO("USER_MEM_RELEASE\r\n");
    }
    
Reply
  • On a receiving side i handle my long write request like that:

    case BLE_GATTS_EVT_WRITE:
      LOG_INFO("BLE_GATTS_EVT_WRITE");
    break;
    case BLE_EVT_USER_MEM_REQUEST:
    LOG_INFO("MEM REQUEST");
    							
    mem_block.len = QUEUED_WRITE_BUFFER_SIZE;
    mem_block.p_mem = &queued_write_buffer[0];
    							
    error_code = sd_ble_user_mem_reply(m_conn_handle, &mem_block);
    if (error_code != NRF_SUCCESS) {
    LOG_INFO("ERROR sd_ble_user_mem_reply: %u\r\n", (unsigned int)error_code);
    } else {
      LOG_INFO("USER_MEM_REQUEST OK\r\n");
    }
    break;
    case BLE_EVT_USER_MEM_RELEASE:
    if ((p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.p_mem == mem_block.p_mem)&&(p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.len == mem_block.len))
    {
    LOG_INFO("USER_MEM_RELEASE\r\n");
    }
    
Children
No Data
Related