Skip to content
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

Make smp and sidewalk parallel #643

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RobertGalatNordic
Copy link
Collaborator

CI parameters

Github_actions:
  #(branch, hash, pull/XXX/head)
  NRF_revision: main

  # Do not change after creating PR
  Create_NRF_PR: false
Jenkins:
  test-sdk-sidewalk: master

extends on #603

Description

JIRA ticket:

Self review

  • There is no commented code.
  • There are no TODO/FIXME comments without associated issue ticket.
  • Commits are properly organized.
  • Change has been tested.
  • Tests were updated (if applicable).

konradderda and others added 3 commits November 13, 2024 09:14
This commit prepares PAL to be used alongside other BLE instances.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
update unit tests

Co-authored-by: Robert Gałat <robert.galat@nordicsemi.no>
Co-authored-by: Konrad Derda <konrad.derda@nordicsemi.no>

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
remove id from kconfig, as it should not be concern for the user.
collisions are prevented by using enum.

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
@github-actions github-actions bot added source PR changing src files tests scripts labels Nov 13, 2024
@RobertGalatNordic RobertGalatNordic force-pushed the make_smp_and_sidewalk_parallel branch 4 times, most recently from 1b9529d to 5a55397 Compare November 13, 2024 10:04
Copy link

github-actions bot commented Nov 13, 2024

Sample diff used total
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.hello.ble_only RAM 4.91 KB 96.47 KB 0 B
ROM 9.89 KB 326.23 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.hello.ble_only.release RAM 4.91 KB 91.84 KB 0 B
ROM 7.97 KB 255.96 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.hello.release RAM 4.91 KB 106.9 KB 0 B
ROM 7.97 KB 331.83 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.demo RAM 4.91 KB 122.25 KB 0 B
ROM 9.91 KB 455.65 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.demo.ble_only RAM 4.91 KB 107.21 KB 0 B
ROM 9.91 KB 377.91 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.dut RAM 4.91 KB 146 KB 0 B
ROM 9.9 KB 521.22 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.dut.no_secure RAM 4.91 KB 145.99 KB 0 B
ROM 9.9 KB 513.54 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.hello RAM 4.91 KB 123.7 KB 0 B
ROM 9.88 KB 470.65 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.hello.ble_only RAM 4.91 KB 97.25 KB 0 B
ROM 9.89 KB 376.21 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.hello.ble_only.release RAM 4.91 KB 92.62 KB 0 B
ROM 7.97 KB 304.98 KB 0 B
nrf54l15dk/nrf54l15/cpuapp:sample.sidewalk.hello.release RAM 4.91 KB 107.68 KB 0 B
ROM 7.97 KB 380.86 KB 0 B
thingy53/nrf5340/cpuapp:sample.sidewalk.demo.ble_only RAM 3.16 KB 109.48 KB 0 B
ROM 5.04 KB 356.56 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.demo RAM 6.08 KB 124.36 KB 0 B
ROM 27.24 KB 478.03 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.demo.ble_only RAM 6.08 KB 109.02 KB 0 B
ROM 27.24 KB 395.56 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.dut RAM 6.08 KB 148 KB 0 B
ROM 27.25 KB 543.11 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.dut.no_secure RAM 6.08 KB 147.98 KB 0 B
ROM 27.24 KB 534.56 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.hello RAM 6.08 KB 125.59 KB 0 B
ROM 27.24 KB 493.05 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.hello.ble_only RAM 6.08 KB 98.84 KB 0 B
ROM 27.22 KB 393.88 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.hello.ble_only.release RAM 6.08 KB 94.03 KB 0 B
ROM 25.33 KB 324.73 KB 0 B
nrf52840dk/nrf52840:sample.sidewalk.hello.release RAM 6.08 KB 109.39 KB 0 B
ROM 25.33 KB 403.7 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.demo RAM 3.16 KB 114.92 KB 0 B
ROM 5.04 KB 400.61 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.demo.ble_only RAM 3.16 KB 99.72 KB 0 B
ROM 5.04 KB 317.01 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.dut RAM 3.16 KB 138.68 KB 0 B
ROM 5.04 KB 466.42 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.dut.no_secure RAM 3.16 KB 138.66 KB 0 B
ROM 5.04 KB 458.97 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.hello RAM 3.16 KB 116.41 KB 0 B
ROM 5.02 KB 415.89 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.hello.ble_only RAM 3.16 KB 89.81 KB 0 B
ROM 5.02 KB 315.57 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.hello.ble_only.release RAM 3.16 KB 85.16 KB 0 B
ROM 3.1 KB 244.14 KB 0 B
nrf5340dk/nrf5340/cpuapp:sample.sidewalk.hello.release RAM 3.16 KB 100.35 KB 0 B
ROM 3.1 KB 323.91 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.demo RAM 4.91 KB 121.48 KB 0 B
ROM 9.91 KB 405.67 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.demo.ble_only RAM 4.91 KB 106.43 KB 0 B
ROM 9.91 KB 327.93 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.dut RAM 4.91 KB 145.23 KB 0 B
ROM 9.92 KB 471.48 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.dut.no_secure RAM 4.91 KB 145.23 KB 0 B
ROM 9.9 KB 468.76 KB 0 B
nrf54l15dk/nrf54l15/cpuapp/ns:sample.sidewalk.hello RAM 4.91 KB 122.92 KB 0 B
ROM 9.89 KB 420.67 KB 0 B

@RobertGalatNordic RobertGalatNordic force-pushed the make_smp_and_sidewalk_parallel branch 9 times, most recently from 5e115f6 to 7e16d63 Compare November 14, 2024 12:16
remove disabling of Sidewalk when entering to DFU mode

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
define new name for BLE ADV for Sidewalk services.

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
allow to restart adv when disconnected and log connection

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
Copy link
Contributor

@ktaborowski ktaborowski left a comment

Choose a reason for hiding this comment

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

Just a first-look review. Code looks good in gerenal, but naming and file location is incositent withe the rest of the repo. Plus some question about work.
To be continued.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not a good place dor this file (in this directory there are files to be changed when Sidewalk libraries are updates) - move to sid_pal/include?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not a good place dor this file (in this directory there are files to be changed when Sidewalk libraries are updates) - move to sid_pal/include?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree, this will be moved


static uint32_t bt_enable_count = 0;

int app_bt_enable(bt_ready_cb_t cb)
Copy link
Contributor

Choose a reason for hiding this comment

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

In genreal, I would recommend to keep the naming convention of Sidewalk module. The app_ prefix is used for sample configuration like app_ble_config. For ble code we used sid_ble_ prefixes (sid_ble_advert, sid_ble_connectopn)

if (ret < 0) {
return ret;
}
} while (ret != BT_ID_SIDEWALK);
Copy link
Contributor

Choose a reason for hiding this comment

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

risk of inifinite loop?

Why isn't the id saved in some static struct and compared in callback? I see something like this is done in nrodic_dfu and some sources in ncs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will not get an infinite loop here, because in previous call, we checked if the advertising sets were loaded from settings, if yes, than we do not go into this loop.

If we end up in the loop it means, that there are some ID that we still expect, so we call the function to get them.
We are guaranteed to get them one by one starting from 1.
if we run out of IDs BLE will return negative error, and we break the loop.

I think this can be rewritten to better express the behaviour

@@ -404,8 +438,10 @@ static sid_error_t ble_adapter_deinit(void)
{
LOG_DBG("Sidewalk -> BLE");
sid_ble_conn_deinit();

int err = bt_disable();
sid_ble_advert_deinit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why to add advertisiement deinit here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we can free the advertising from BLE stack. Maybe for now it is not very useful, but I figured out if we asked for some resources, it would be nice to give them back when we are done working with them.

* @brief BT ids used for extended advertising.
* This allows to identify connections from different extended adverticements.
*/
enum BT_id_values{
Copy link
Contributor

Choose a reason for hiding this comment

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

don't use uppercase in type names

Comment on lines +40 to +41
_BT_ID_DEFAULT = BT_ID_DEFAULT,
BT_ID_SIDEWALK,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_BT_ID_DEFAULT = BT_ID_DEFAULT,
BT_ID_SIDEWALK,
BT_ID_SIDEWALK = BT_ID_DEFAULT +1,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do not think it is required, enums automatically build values as previous +1.

The Ids are described in documentation for BLE as just an id in array of advertiser sets, so it is guaranteed by the API documentation, that they will be starting from 0 (default), and any new ID is just last one +1 up to the total defined size of the advertising array

Comment on lines +45 to +48
_BT_ID_MAX
};

BUILD_ASSERT(_BT_ID_MAX <= CONFIG_BT_ID_MAX, "Too many BT Ids! increase CONFIG_BT_ID_MAX, to match _BT_ID_MAX");
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea to get the fast feedback to developer during build, but I think the BLE module should assert when you try to use too many ids.
My recommendation is to remove this, to keep code simple, and easier to maintain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think if we removed this build assert, we would find out we do not have enough BT_ID_MAX in runtime, when we try to get new ID, and IMO that is a little too late.

@@ -41,12 +53,18 @@ static struct bt_gatt_cb gatt_callbacks = { .att_mtu_updated = ble_mtu_cb };
*/
static void ble_connect_cb(struct bt_conn *conn, uint8_t err)
{
const bt_addr_le_t *bt_addr_le;
Copy link
Contributor

Choose a reason for hiding this comment

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

not initlized

static void connected(struct bt_conn *conn, uint8_t err)
{
struct bt_conn_info cinfo;
int ec;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int ec;
int ret;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was copied from mesh sample, as I hope it will solve one of the issues I see in Jenkins, if so, I will refactor this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scripts source PR changing src files tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants