Skip to content

Conversation

@PavelVPV
Copy link
Contributor

@PavelVPV PavelVPV commented Oct 30, 2024

Instead of checking the enabled flag, check if BT_MESH_SUSPENDED is set in the legacy advertiser thread. BT_MESH_SUSPENDED is set earlier than advertiser is stopped and will prevent the advertiser send anything earlier.

This PR also replaces k_sleep with semaphore before suspending mesh as k_sleep may not be enough to let advertiser send the message. Instead we should rely on the bt_mesh_send_cb.

This PR fixes mesh suspend tests in #79931
Fixes #80910

@PavelVPV
Copy link
Contributor Author

@valeriosetti, this PR should fix suspend tests in your PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why assert here (considering asserts can be disabled), may be better to return -EADV?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ever use asserts if they can be disabled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the main purpose of assertion in assertion post action that is weak in Zephyr and customer is able to implement it on its own purpose. Generally, assertion is changed on hardware reset in final product as the only way for recovering device workability from unknown and unpredictable situation.
https://docs.zephyrproject.org/latest/kernel/services/other/fatal.html

Is this the real place where device requires hardware reset in "fields"?

It seems @omkar3141 suggestion is more suitable. Since functional prototype returns operation status, it is better to return error code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 'ensure' works only when asserts are enabled, otherwise this can cause locking, better to return error code to let higher layer handle it.

@PavelVPV PavelVPV force-pushed the fix_legacy_adv_stop branch from 672d849 to 8706ab0 Compare October 31, 2024 08:25
@PavelVPV PavelVPV requested review from alxelax and omkar3141 October 31, 2024 08:25
alxelax
alxelax previously approved these changes Oct 31, 2024
omkar3141
omkar3141 previously approved these changes Oct 31, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to add an input parameter to this macro (either bt_mesh or bt_mesh.flags). Without it you get the impression that this macro evaluates to a build-time constant, which is not true.

Instead of checking the `enabled` flag, check if BT_MESH_SUSPENDED is
set in the legacy advertiser thread. BT_MESH_SUSPENDED is set earlier
than advertiser is stopped and will prevent the advertiser send anything
earlier.

Signed-off-by: Pavel Vasilyev <[email protected]>
k_sleep may not be enough to let advertiser send the message. Instead we
should rely on the bt_mesh_send_cb.

Signed-off-by: Pavel Vasilyev <[email protected]>
@PavelVPV PavelVPV dismissed stale reviews from omkar3141 and alxelax via 5d9deb6 November 5, 2024 07:01
@PavelVPV PavelVPV force-pushed the fix_legacy_adv_stop branch from 8706ab0 to 5d9deb6 Compare November 5, 2024 07:01
@PavelVPV PavelVPV added this to the v4.0.0 milestone Nov 5, 2024
@mmahadevan108 mmahadevan108 merged commit 457a20c into zephyrproject-rtos:main Nov 5, 2024
28 checks passed
@PavelVPV PavelVPV deleted the fix_legacy_adv_stop branch November 7, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bluetooth: Mesh: Legacy advertiser may advertise after stack is suspended before advertiser is finally stopped

6 participants