Bluetooth: Add common BT_CONN_INTERVAL_TO_MS macro

The same macro was defined in multiple places.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This commit is contained in:
Herman Berget 2022-02-03 15:35:11 +01:00 committed by Anas Nashif
commit 8b46aaaf69
4 changed files with 15 additions and 15 deletions

View file

@ -299,6 +299,9 @@ struct bt_conn_le_info {
#endif /* defined(CONFIG_BT_USER_DATA_LEN_UPDATE) */ #endif /* defined(CONFIG_BT_USER_DATA_LEN_UPDATE) */
}; };
/* Multiply bt 1.25 to get MS */
#define BT_CONN_INTERVAL_TO_MS(interval) ((interval) * 5 / 4)
/** BR/EDR Connection Info Structure */ /** BR/EDR Connection Info Structure */
struct bt_conn_br_info { struct bt_conn_br_info {
const bt_addr_t *dst; /** Destination (Remote) BR/EDR address */ const bt_addr_t *dst; /** Destination (Remote) BR/EDR address */

View file

@ -6,6 +6,7 @@
#include <ctype.h> #include <ctype.h>
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/iso.h> #include <bluetooth/iso.h>
#include <sys/byteorder.h> #include <sys/byteorder.h>
#include <console/console.h> #include <console/console.h>
@ -16,7 +17,6 @@ LOG_MODULE_REGISTER(iso_broadcast_receiver, LOG_LEVEL_DBG);
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME #define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME)) #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME))
#define BT_INTERVAL_TO_MS(interval) ((interval) * 5 / 4)
#define PA_RETRY_COUNT 6 #define PA_RETRY_COUNT 6
#define ISO_RETRY_COUNT 10 #define ISO_RETRY_COUNT 10
@ -102,7 +102,7 @@ static void scan_recv(const struct bt_le_scan_recv_info *info,
broadcaster_found = true; broadcaster_found = true;
per_sid = info->sid; per_sid = info->sid;
per_interval_ms = BT_INTERVAL_TO_MS(info->interval); per_interval_ms = BT_CONN_INTERVAL_TO_MS(info->interval);
bt_addr_le_copy(&per_addr, info->addr); bt_addr_le_copy(&per_addr, info->addr);
k_sem_give(&sem_per_adv); k_sem_give(&sem_per_adv);
@ -140,13 +140,13 @@ static void biginfo_cb(struct bt_le_per_adv_sync *sync,
"bn %u, pto %u, irc %u, max_pdu %u, sdu_interval %u us, " "bn %u, pto %u, irc %u, max_pdu %u, sdu_interval %u us, "
"max_sdu %u, phy %s, %s framing, %sencrypted", "max_sdu %u, phy %s, %s framing, %sencrypted",
biginfo->num_bis, biginfo->sub_evt_count, biginfo->num_bis, biginfo->sub_evt_count,
BT_INTERVAL_TO_MS((float)biginfo->iso_interval), BT_CONN_INTERVAL_TO_MS((float)biginfo->iso_interval),
biginfo->burst_number, biginfo->offset, biginfo->rep_count, biginfo->burst_number, biginfo->offset, biginfo->rep_count,
biginfo->max_pdu, biginfo->sdu_interval, biginfo->max_sdu, biginfo->max_pdu, biginfo->sdu_interval, biginfo->max_sdu,
phy2str(biginfo->phy), biginfo->framing ? "with" : "without", phy2str(biginfo->phy), biginfo->framing ? "with" : "without",
biginfo->encryption ? "" : "not "); biginfo->encryption ? "" : "not ");
iso_interval_ms = BT_INTERVAL_TO_MS(biginfo->iso_interval); iso_interval_ms = BT_CONN_INTERVAL_TO_MS(biginfo->iso_interval);
bis_count = MIN(biginfo->num_bis, CONFIG_BT_ISO_MAX_CHAN); bis_count = MIN(biginfo->num_bis, CONFIG_BT_ISO_MAX_CHAN);
biginfo_received = true; biginfo_received = true;
k_sem_give(&sem_per_big_info); k_sem_give(&sem_per_big_info);

View file

@ -8,6 +8,7 @@
#include <devicetree.h> #include <devicetree.h>
#include <drivers/gpio.h> #include <drivers/gpio.h>
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/iso.h> #include <bluetooth/iso.h>
#include <sys/byteorder.h> #include <sys/byteorder.h>
@ -19,7 +20,6 @@
BT_GAP_SCAN_FAST_INTERVAL, \ BT_GAP_SCAN_FAST_INTERVAL, \
BT_GAP_SCAN_FAST_WINDOW) BT_GAP_SCAN_FAST_WINDOW)
#define BT_INTERVAL_TO_MS(interval) ((interval) * 5 / 4)
#define PA_RETRY_COUNT 6 #define PA_RETRY_COUNT 6
static bool per_adv_found; static bool per_adv_found;
@ -112,13 +112,13 @@ static void scan_recv(const struct bt_le_scan_recv_info *info,
(info->adv_props & BT_GAP_ADV_PROP_SCAN_RESPONSE) != 0, (info->adv_props & BT_GAP_ADV_PROP_SCAN_RESPONSE) != 0,
(info->adv_props & BT_GAP_ADV_PROP_EXT_ADV) != 0, (info->adv_props & BT_GAP_ADV_PROP_EXT_ADV) != 0,
phy2str(info->primary_phy), phy2str(info->secondary_phy), phy2str(info->primary_phy), phy2str(info->secondary_phy),
info->interval, BT_INTERVAL_TO_MS(info->interval), info->sid); info->interval, BT_CONN_INTERVAL_TO_MS(info->interval), info->sid);
if (!per_adv_found && info->interval) { if (!per_adv_found && info->interval) {
per_adv_found = true; per_adv_found = true;
per_sid = info->sid; per_sid = info->sid;
per_interval_ms = BT_INTERVAL_TO_MS(info->interval); per_interval_ms = BT_CONN_INTERVAL_TO_MS(info->interval);
bt_addr_le_copy(&per_addr, info->addr); bt_addr_le_copy(&per_addr, info->addr);
k_sem_give(&sem_per_adv); k_sem_give(&sem_per_adv);

View file

@ -38,9 +38,6 @@
#include "ll.h" #include "ll.h"
#include "hci.h" #include "hci.h"
/* Multiply bt 1.25 to get MS */
#define BT_INTERVAL_TO_MS(interval) ((interval) * 5 / 4)
static bool no_settings_load; static bool no_settings_load;
uint8_t selected_id = BT_ID_DEFAULT; uint8_t selected_id = BT_ID_DEFAULT;
@ -172,7 +169,7 @@ static void scan_recv(const struct bt_le_scan_recv_info *info,
(info->adv_props & BT_GAP_ADV_PROP_SCAN_RESPONSE) != 0, (info->adv_props & BT_GAP_ADV_PROP_SCAN_RESPONSE) != 0,
(info->adv_props & BT_GAP_ADV_PROP_EXT_ADV) != 0, (info->adv_props & BT_GAP_ADV_PROP_EXT_ADV) != 0,
phy2str(info->primary_phy), phy2str(info->secondary_phy), phy2str(info->primary_phy), phy2str(info->secondary_phy),
info->interval, BT_INTERVAL_TO_MS(info->interval), info->interval, BT_CONN_INTERVAL_TO_MS(info->interval),
info->sid); info->sid);
} }
@ -529,7 +526,7 @@ static void per_adv_sync_sync_cb(struct bt_le_per_adv_sync *sync,
shell_print(ctx_shell, "PER_ADV_SYNC[%u]: [DEVICE]: %s synced, " shell_print(ctx_shell, "PER_ADV_SYNC[%u]: [DEVICE]: %s synced, "
"Interval 0x%04x (%u ms), PHY %s, SD 0x%04X, PAST peer %s", "Interval 0x%04x (%u ms), PHY %s, SD 0x%04X, PAST peer %s",
bt_le_per_adv_sync_get_index(sync), le_addr, bt_le_per_adv_sync_get_index(sync), le_addr,
info->interval, BT_INTERVAL_TO_MS(info->interval), info->interval, BT_CONN_INTERVAL_TO_MS(info->interval),
phy2str(info->phy), info->service_data, past_peer); phy2str(info->phy), info->service_data, past_peer);
if (info->conn) { /* if from PAST */ if (info->conn) { /* if from PAST */
@ -586,7 +583,7 @@ static void per_adv_sync_biginfo_cb(struct bt_le_per_adv_sync *sync,
"%sencrypted", "%sencrypted",
bt_le_per_adv_sync_get_index(sync), le_addr, biginfo->sid, biginfo->num_bis, bt_le_per_adv_sync_get_index(sync), le_addr, biginfo->sid, biginfo->num_bis,
biginfo->sub_evt_count, biginfo->iso_interval, biginfo->sub_evt_count, biginfo->iso_interval,
BT_INTERVAL_TO_MS(biginfo->iso_interval), biginfo->burst_number, BT_CONN_INTERVAL_TO_MS(biginfo->iso_interval), biginfo->burst_number,
biginfo->offset, biginfo->rep_count, biginfo->max_pdu, biginfo->sdu_interval, biginfo->offset, biginfo->rep_count, biginfo->max_pdu, biginfo->sdu_interval,
biginfo->max_sdu, phy2str(biginfo->phy), biginfo->framing, biginfo->max_sdu, phy2str(biginfo->phy), biginfo->framing,
biginfo->encryption ? "" : "not "); biginfo->encryption ? "" : "not ");
@ -2192,10 +2189,10 @@ static int cmd_info(const struct shell *sh, size_t argc, char *argv[])
shell_print(ctx_shell, "Interval: 0x%04x (%u ms)", shell_print(ctx_shell, "Interval: 0x%04x (%u ms)",
info.le.interval, info.le.interval,
BT_INTERVAL_TO_MS(info.le.interval)); BT_CONN_INTERVAL_TO_MS(info.le.interval));
shell_print(ctx_shell, "Latency: 0x%04x (%u ms)", shell_print(ctx_shell, "Latency: 0x%04x (%u ms)",
info.le.latency, info.le.latency,
BT_INTERVAL_TO_MS(info.le.latency)); BT_CONN_INTERVAL_TO_MS(info.le.latency));
shell_print(ctx_shell, "Supervision timeout: 0x%04x (%d ms)", shell_print(ctx_shell, "Supervision timeout: 0x%04x (%d ms)",
info.le.timeout, info.le.timeout * 10); info.le.timeout, info.le.timeout * 10);
#if defined(CONFIG_BT_USER_PHY_UPDATE) #if defined(CONFIG_BT_USER_PHY_UPDATE)