logging: Optimize ble notification size

Reduce the size of the ble notification if the length of
the line output is less than the current mtu size.

Signed-off-by: Victor Chavez <vchavezb@protonmail.com>
This commit is contained in:
Victor Chavez 2024-08-07 00:35:29 +02:00 committed by Carles Cufí
parent 2aa31a3695
commit 3ee6fa8c07

View file

@ -118,13 +118,7 @@ static int line_out(uint8_t *data, size_t length, void *output_ctx)
ARG_UNUSED(output_ctx);
const uint16_t mtu_size = bt_gatt_get_mtu(ble_backend_conn);
const uint16_t attr_data_len = mtu_size - ATT_NOTIFY_SIZE;
uint16_t notify_len;
if (attr_data_len < LOG_BACKEND_BLE_BUF_SIZE) {
notify_len = attr_data_len;
} else {
notify_len = LOG_BACKEND_BLE_BUF_SIZE;
}
const uint16_t notify_len = MIN(length, MIN(attr_data_len, LOG_BACKEND_BLE_BUF_SIZE));
struct bt_gatt_notify_params notify_param = {
.uuid = NULL,