From faf68d7a87ea33ef9cd561462947454d97623efd Mon Sep 17 00:00:00 2001 From: Florian Grandel Date: Fri, 10 May 2024 16:18:10 +0200 Subject: [PATCH] samples: bluetooth: central_iso: remove unnecessary vars Replaces static constant variables by preprocessor definitions for improved readability and (minor) RAM usage improvement. Signed-off-by: Florian Grandel --- samples/bluetooth/central_iso/src/main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/bluetooth/central_iso/src/main.c b/samples/bluetooth/central_iso/src/main.c index 5fe3062a6539cc7..b15edd6f8bb4ed3 100644 --- a/samples/bluetooth/central_iso/src/main.c +++ b/samples/bluetooth/central_iso/src/main.c @@ -19,14 +19,15 @@ #include #include +#define LATENCY_MS 10U /* 10.0 ms */ +#define INTERVAL_US (10U * USEC_PER_MSEC) /* 10.0 ms */ + static void start_scan(void); static struct bt_conn *default_conn; static struct k_work_delayable iso_send_work; static struct bt_iso_chan iso_chan; -static uint16_t seq_num; -static uint16_t latency_ms = 10U; /* 10ms */ -static uint32_t interval_us = 10U * USEC_PER_MSEC; /* 10 ms */ +static uint32_t seq_num; NET_BUF_POOL_FIXED_DEFINE(tx_pool, 1, BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); @@ -71,7 +72,7 @@ static void iso_timer_timeout(struct k_work *work) net_buf_unref(buf); } - k_work_schedule(&iso_send_work, K_USEC(interval_us)); + k_work_schedule(&iso_send_work, K_USEC(INTERVAL_US)); len_to_send++; if (len_to_send > ARRAY_SIZE(buf_data)) { @@ -252,10 +253,10 @@ int main(void) param.sca = BT_GAP_SCA_UNKNOWN; param.packing = BT_ISO_PACKING_SEQUENTIAL; param.framing = BT_ISO_FRAMING_UNFRAMED; - param.c_to_p_latency = latency_ms; /* ms */ - param.p_to_c_latency = latency_ms; /* ms */ - param.c_to_p_interval = interval_us; /* us */ - param.p_to_c_interval = interval_us; /* us */ + param.c_to_p_latency = LATENCY_MS; /* ms */ + param.p_to_c_latency = LATENCY_MS; /* ms */ + param.c_to_p_interval = INTERVAL_US; /* us */ + param.p_to_c_interval = INTERVAL_US; /* us */ err = bt_iso_cig_create(¶m, &cig);