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

Sending consecutive 7 notification on ble characteristic issue

Hi,

I want to send multiple packets on a notify characteristic using ble_blanky app as baseline but only first 4 consecutive notifications are received on android side.

I send 7 notification one after the other and only first 4 are received on other side even peripheral is connected. by the way i am using sdk 16 on nrf52832 development board.

Parents
  • Hi,

    • What application are you using on the android side, is it nRF Connect?
    • Is the BLE_GATTS_EVT_HVN_TX_COMPLETE event generated when the notifications are sent? 
    • Could you share your project?

    regards

    Jared

  • Yes i am using nRF Connect on mobile side.

    I have modified the ble_app_blinky example in sdk 16. on button write characteristic i send consecutive notification on a notify characteristic using the following function

    uint32_t ble_on_tx_frame(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t* p_tx_data)
    {
    ble_gatts_hvx_params_t params;
    uint16_t len = 16;

    memset(&params, 0, sizeof(params));
    params.type = BLE_GATT_HVX_NOTIFICATION;
    params.handle = p_lbs->notify_char_handles.value_handle;
    params.p_data = p_tx_data;
    params.p_len = &len;

    return sd_ble_gatts_hvx(conn_handle, &params);
    }

    // The following function is called in button write handle event of the button characteristic

    void GetEncrypted_text(uint8_t opcode)
    {
    uint32_t err_code;
    uint8_t tx_packet_array[16];
    if(opcode == 0x03)
    {
    (void) memset(g_tx_command,0,200);

    static char m_plain_text[] =
    {
    "Example string to demonstrate AES CBC mode with padding. This text has 85 characters."
    };
    uint16_t len_out = sizeof(g_tx_command);
    uint16_t len_in = sizeof(m_plain_text);
    encrypt_cbc(&m_plain_text[0], len_in, &g_tx_command[0],len_out);


    tx_packet_array[0] = 1<<7;
    tx_packet_array[0] |= opcode;
    tx_packet_array[1] |= 0x07; // no of frames
    tx_packet_array[2] |= 0x55; // crc low
    tx_packet_array[3] |= 0xA5; // crc high

    //(void) memset(&tx_packet_array[4],1,12); // First Chunk

    (void) memcpy(&tx_packet_array[4],&g_tx_command,12); // First Chunk
    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);


    tx_packet_array[0] = 0xFF; // Second Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[12],15);

    err_code = ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);
    nrf_delay_ms(5);




    tx_packet_array[0] = 0xFF; // Third Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[27],15);

    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);
    nrf_delay_ms(5);


    tx_packet_array[0] = 0xFF; // Fourth Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[42],15);

    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);
    nrf_delay_ms(25);

    tx_packet_array[0] = 0xFF; // Fifth Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[57],15);

    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);
    nrf_delay_ms(5);

    tx_packet_array[0] = 0xFF; // Sixth Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[72],15);

    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);
    nrf_delay_ms(5);



    tx_packet_array[0] = 0xFE; // Seventh Chunk
    (void) memcpy(&tx_packet_array[1],&g_tx_command[87],9);

    (void) memset(&tx_packet_array[10],0,6);
    ble_on_tx_frame(m_conn_handle, &m_lbs, &tx_packet_array[0]);

    }

     Only first three or some time four notifications are received in nrf Connect side.

  • Hello,

    I'm very sorry for the late reply. Are you still having problems with this?

    regards

    Jared 

Reply Children
No Data
Related