How to send 25 packets of data each second

I am not able to send 25 array packets each second. array size is 244 bytes

I am reading the sensor data continuosly and every 40 ms i am sending the data to bluetooth using gatt_notify

Each second the receiver receiving different number of packets 

1st second 24 packets
2nd second 25 packets 
3rd second 23 packets like wise Receiver receiving the data 

every second 25 packets are not receiving 


Please help on this 

Thank you in advance

Parents
  • The typical MTU for notify is 23 bytes.

    Try setting auto update connection parms to y or set the desired length via 

        struct bt_conn_le_data_len_param data_len = {
            .tx_max_len = 247,
            .tx_max_time = 1000,
        };
    
        err = bt_conn_le_data_len_update(NULL, &data_len);
        if (err) {
            printk("LE Data Length update failed (err %d)\n", err);
        }

  • Hi IvanR,

    By default MTU for notify is 23 but we can update the MTU to 251  right?

    Thank you in advance

  • Devices can agree on what MTU they can use. Im checking it using code bellow. Ive not tried setting it manually as this fits my purpose. I then use that negotiatedMTU as size of the packet sent via notify. 

    void exchange_mtu_result(struct bt_conn* conn, uint8_t err, struct bt_gatt_exchange_params* params) {
      if (err)
        printErr("MTU exchange failed (Error: %d)", err);
      else {
        negotiated_MTU = bt_gatt_get_mtu(conn) - 4; // INFO negotiated MTU is reduced by 4 as 3 bytes are ATT and 1 for null termination
      }
    }
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
      .connected           = connected,
      .disconnected        = disconnected,
      .le_param_req        = param_req,
      .le_param_updated    = param_updated,
      .le_phy_updated      = phy_updated,
      .le_data_len_updated = data_length_updated
    };

    MTU : 494 bytes
Reply
  • Devices can agree on what MTU they can use. Im checking it using code bellow. Ive not tried setting it manually as this fits my purpose. I then use that negotiatedMTU as size of the packet sent via notify. 

    void exchange_mtu_result(struct bt_conn* conn, uint8_t err, struct bt_gatt_exchange_params* params) {
      if (err)
        printErr("MTU exchange failed (Error: %d)", err);
      else {
        negotiated_MTU = bt_gatt_get_mtu(conn) - 4; // INFO negotiated MTU is reduced by 4 as 3 bytes are ATT and 1 for null termination
      }
    }
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
      .connected           = connected,
      .disconnected        = disconnected,
      .le_param_req        = param_req,
      .le_param_updated    = param_updated,
      .le_phy_updated      = phy_updated,
      .le_data_len_updated = data_length_updated
    };

    MTU : 494 bytes
Children
Related