-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Bluetooth: Mesh: Use IS_ENABLE replace #if #80659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,70 +71,50 @@ | |
|
|
||
| static struct bt_mesh_ext_adv advs[] = { | ||
| [0] = { | ||
| .tags = ( | ||
| #if !defined(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) | ||
| BT_MESH_ADV_TAG_BIT_FRIEND | | ||
| #endif | ||
| #if !defined(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE) | ||
| BT_MESH_ADV_TAG_BIT_PROXY | | ||
| #endif /* !CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */ | ||
| #if defined(CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET) | ||
| BT_MESH_ADV_TAG_BIT_RELAY | | ||
| #endif /* CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET */ | ||
| #if defined(CONFIG_BT_MESH_PB_ADV) | ||
| BT_MESH_ADV_TAG_BIT_PROV | | ||
| #endif /* CONFIG_BT_MESH_PB_ADV */ | ||
| BT_MESH_ADV_TAG_BIT_LOCAL | ||
| ), | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }, | ||
| #if CONFIG_BT_MESH_RELAY_ADV_SETS | ||
| [1 ... CONFIG_BT_MESH_RELAY_ADV_SETS] = { | ||
| .tags = ( | ||
| #if defined(CONFIG_BT_MESH_RELAY) | ||
| BT_MESH_ADV_TAG_BIT_RELAY | | ||
| #endif /* CONFIG_BT_MESH_RELAY */ | ||
| #if defined(CONFIG_BT_MESH_PB_ADV_USE_RELAY_SETS) | ||
| BT_MESH_ADV_TAG_BIT_PROV | | ||
| #endif /* CONFIG_BT_MESH_PB_ADV_USE_RELAY_SETS */ | ||
| 0), | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }, | ||
| #endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */ | ||
| #if defined(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) | ||
| { | ||
| .tags = BT_MESH_ADV_TAG_BIT_FRIEND, | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }, | ||
| #endif /* CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */ | ||
| #if defined(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE) | ||
| { | ||
| .tags = BT_MESH_ADV_TAG_BIT_PROXY, | ||
| .tags = (BT_MESH_ADV_TAG_BIT_LOCAL | | ||
| (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) | ||
| ? 0 : BT_MESH_ADV_TAG_BIT_FRIEND) | | ||
| (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE) | ||
| ? 0 : BT_MESH_ADV_TAG_BIT_PROXY) | | ||
| (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET) | ||
| ? BT_MESH_ADV_TAG_BIT_RELAY : 0) | | ||
| (IS_ENABLED(CONFIG_BT_MESH_PB_ADV) | ||
| ? BT_MESH_ADV_TAG_BIT_PROV : 0)), | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }, | ||
| #endif /* CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */ | ||
| COND_CODE_0(CONFIG_BT_MESH_RELAY_ADV_SETS, | ||
|
Check notice on line 85 in subsys/bluetooth/mesh/adv_ext.c
|
||
| (), ([1 ... CONFIG_BT_MESH_RELAY_ADV_SETS] = { | ||
| .tags = ( | ||
| (IS_ENABLED(CONFIG_BT_MESH_RELAY) ? | ||
| BT_MESH_ADV_TAG_BIT_RELAY : 0) | | ||
| (IS_ENABLED(CONFIG_BT_MESH_PB_ADV_USE_RELAY_SETS) ? | ||
| BT_MESH_ADV_TAG_BIT_PROV : 0) | ||
| ), | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| })) | ||
| COND_CODE_1(IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE), | ||
| ({ .tags = BT_MESH_ADV_TAG_BIT_FRIEND, | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }), ()) | ||
| COND_CODE_1(IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE), | ||
| ({ .tags = BT_MESH_ADV_TAG_BIT_PROXY, | ||
| .work = Z_WORK_INITIALIZER(send_pending_adv), | ||
| }), ()) | ||
| }; | ||
|
|
||
|
Check notice on line 104 in subsys/bluetooth/mesh/adv_ext.c
|
||
| BUILD_ASSERT(ARRAY_SIZE(advs) <= CONFIG_BT_EXT_ADV_MAX_ADV_SET, | ||
| "Insufficient adv instances"); | ||
|
|
||
| static inline struct bt_mesh_ext_adv *relay_adv_get(void) | ||
| { | ||
| if (!!(CONFIG_BT_MESH_RELAY_ADV_SETS)) { | ||
| return &advs[1]; | ||
| } else { | ||
| return &advs[0]; | ||
| } | ||
| return !!(CONFIG_BT_MESH_RELAY_ADV_SETS) ? &advs[1] : &advs[0]; | ||
| } | ||
|
|
||
| static inline struct bt_mesh_ext_adv *gatt_adv_get(void) | ||
| { | ||
| if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE)) { | ||
| return &advs[ARRAY_SIZE(advs) - 1]; | ||
| } else { | ||
| return &advs[0]; | ||
| } | ||
| return IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE) ? | ||
| &advs[ARRAY_SIZE(advs) - 1] : &advs[0]; | ||
|
Comment on lines
-132
to
+116
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know you're a fan of compact code, however I really don't think this improves readability. The C ternary operator is useful in places where you can't use |
||
| } | ||
|
Check notice on line 117 in subsys/bluetooth/mesh/adv_ext.c
|
||
|
|
||
| static int adv_start(struct bt_mesh_ext_adv *ext_adv, | ||
| const struct bt_le_adv_param *param, | ||
|
|
@@ -233,14 +213,6 @@ | |
| return err; | ||
| } | ||
|
|
||
| static const char * const adv_tag_to_str[] = { | ||
| [BT_MESH_ADV_TAG_LOCAL] = "local adv", | ||
| [BT_MESH_ADV_TAG_RELAY] = "relay adv", | ||
| [BT_MESH_ADV_TAG_PROXY] = "proxy adv", | ||
| [BT_MESH_ADV_TAG_FRIEND] = "friend adv", | ||
| [BT_MESH_ADV_TAG_PROV] = "prov adv", | ||
| }; | ||
|
|
||
| static bool schedule_send_with_mask(struct bt_mesh_ext_adv *ext_adv, int ignore_mask) | ||
| { | ||
| if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_PROXY)) { | ||
|
|
@@ -265,6 +237,13 @@ | |
|
|
||
| static void send_pending_adv(struct k_work *work) | ||
| { | ||
| static const char * const adv_tag_to_str[] = { | ||
| [BT_MESH_ADV_TAG_LOCAL] = "local", | ||
| [BT_MESH_ADV_TAG_RELAY] = "relay", | ||
| [BT_MESH_ADV_TAG_PROXY] = "proxy", | ||
| [BT_MESH_ADV_TAG_FRIEND] = "friend", | ||
| [BT_MESH_ADV_TAG_PROV] = "prov", | ||
| }; | ||
|
Check notice on line 246 in subsys/bluetooth/mesh/adv_ext.c
|
||
| struct bt_mesh_ext_adv *ext_adv; | ||
| struct bt_mesh_adv *adv; | ||
| int err; | ||
|
|
@@ -277,7 +256,7 @@ | |
| } | ||
|
|
||
| if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_SENT)) { | ||
| LOG_DBG("Advertising stopped after %u ms for %s", | ||
| LOG_DBG("Advertising stopped after %u ms for %s adv", | ||
| k_uptime_get_32() - ext_adv->timestamp, | ||
| ext_adv->adv ? adv_tag_to_str[ext_adv->adv->ctx.tag] | ||
| : adv_tag_to_str[BT_MESH_ADV_TAG_PROXY]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, and this is also out of scope of the PR, since it's talking about replacing
#ifand notif ()