Skip to content

Commit

Permalink
samples: bluetooth: central_iso: remove unnecessary vars
Browse files Browse the repository at this point in the history
Replaces static constant variables by preprocessor definitions for
improved readability and (minor) RAM usage improvement.

Signed-off-by: Florian Grandel <[email protected]>
  • Loading branch information
Florian Grandel committed May 11, 2024
1 parent 446abf2 commit faf68d7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions samples/bluetooth/central_iso/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
#include <zephyr/settings/settings.h>
#include <zephyr/sys/byteorder.h>

#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);

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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(&param, &cig);

Expand Down

0 comments on commit faf68d7

Please sign in to comment.