-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
samples: bluteooth: CS ranging requestor sample #18921
base: main
Are you sure you want to change the base?
Conversation
CI InformationTo view the history of this post, clich the 'edited' button above Inputs:Sources:more detailsGithub labels
List of changed files detected by CI (0)
Outputs:ToolchainVersion: Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
d6bf442
to
91c14de
Compare
This is a utility function to help extract useful parts of the ranging data provided by the ranging requestor service. Signed-off-by: Sean Madigan <[email protected]>
91c14de
to
9fb1de6
Compare
9fb1de6
to
98d119b
Compare
You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds. Note: This comment is automatically posted by the Documentation Publish GitHub Action. |
98d119b
to
6974806
Compare
This sample can be used to set up a Channel Sounding Initiator with the GATT Ranging Requestor client. It can connect to Channel Sounding Reflector with Ranging Responder sample to request CS Ranging Data from. A simple distance estimation algorithm is included. This uses the same logic as the Zephyr Channel Sounding sample. Signed-off-by: Sean Madigan <[email protected]>
6974806
to
6875b7c
Compare
If possible I think we should use mode 3 here. There's no disadvantage to using it (as long as it's supported on both sides), so I expect it would be more useful to customers than using mode 2 + 1 |
* must be populated with the length of the step data inside the callback. | ||
* @param[in] user_data User data to be passed to the callbacks. | ||
*/ | ||
void bt_ras_rreq_rd_subevent_data_parse( |
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.
did you try having a single function that parses both formats and gives a single callback ? I think it would be easier for users
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.
it would also remove struct ras_rd_cs_subevent_step
(since the mode would be a duplicate)
|
||
struct ras_ranging_header *rd_header = | ||
net_buf_simple_pull_mem(peer_steps, sizeof(struct ras_ranging_header)); | ||
(void)rd_header; |
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.
can just remove the variable?
err = bt_conn_set_security(connection, BT_SECURITY_L2); | ||
if (err) { | ||
printk("Failed to encrypt connection (err %d)\n", err); | ||
return 0; |
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.
We might want to handle these failing more gracefully - perhaps disconnect the peer?
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.
I think it is fine as is
|
||
err = bt_gatt_exchange_mtu(connection, &mtu_exchange_params); | ||
if (err) { | ||
printk("MTU exchange failed (err %d)\n", err); |
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.
I don't think it's worth handling the return code here, the only error code you could get is EALREADY which means the sem_mtu_exchange_done semaphore would have already been given in the MTU exchange callback.
NET_BUF_SIMPLE_DEFINE_STATIC(latest_peer_steps, BT_RAS_PROCEDURE_MEM); | ||
static int32_t most_recent_peer_ranging_counter = PROCEDURE_COUNTER_NONE; | ||
static int32_t most_recent_local_ranging_counter = PROCEDURE_COUNTER_NONE; | ||
static int32_t dropped_ranging_counter = PROCEDURE_COUNTER_NONE; |
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.
I was hoping implementing RAS would make it easier to manage ranging counters in the app by leveraging the notifications you get from the server, wouldn't it make more sense to have something like:
- array of steps storing N counters
- discard array entry X if you get the data overwritten callback
- set a flag in entry X when you get ranging data ready
- app logic requests counters it has stored locally then processes entries where this flag is set ?
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.
I guess what I wrote here doesn't exactly work but you'd think this overwritten notification would be useful somehow
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.
I'm not sure exactly how to improve this currently
static struct bt_conn *connection; | ||
static uint8_t n_ap; | ||
static uint8_t latest_num_steps_reported; | ||
NET_BUF_SIMPLE_DEFINE_STATIC(latest_local_steps, BT_RAS_PROCEDURE_MEM); |
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.
I don't think BT_RAS_PROCEDURE_MEM is the correct estimate here, since the local steps are storing a full bt_le_cs_subevent_step
and no subevent headers
#define CON_STATUS_LED DK_LED1 | ||
|
||
#define CS_CONFIG_ID 0 | ||
#define NUM_MODE_0_STEPS 1 |
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.
it might be more stable to use 2-3 mode 0 steps. Since there's no memory limitations with RAS we don't lose anything by increasing this
printk("MTU exchange failed (err %d)\n", err); | ||
} | ||
|
||
err = k_sem_take(&sem_mtu_exchange_done, K_SECONDS(5)); |
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.
K_FOREVER is probably fine
return 0; | ||
} | ||
|
||
k_sem_take(&sem_remote_capabilities_obtained, K_SECONDS(5)); |
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.
this can also be K_FOREVER I think ? Same for the other control procedures in the setup phase
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.
Shouldn't take 5s? Might as well have the timeout?
.. [#phase_and_amplitude] `Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.2 <https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/architecture,-change-history,-and-conventions/architecture.html#UUID-a8d03618-5fcf-3043-2198-559653272b1b>`_ | ||
.. [#rtt_packets] `Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.3 <https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/architecture,-change-history,-and-conventions/architecture.html#UUID-9d4969af-baa6-b7e4-03ca-70b340877adf>`_ |
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.
Please, place these to the links.txt (docs/nrf). See https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/dev_model_and_contributions/documentation/styleguide.html#linking
} | ||
|
||
dropped_ranging_counter = PROCEDURE_COUNTER_NONE; | ||
latest_num_steps_reported = result->header.num_steps_reported; |
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.
this is limited to 1 subevent per procedure, right?
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.
Realised this variable was unused, but yeah I think currently only one subevent per procedure
Seems like it is still WIP in the controller, I can make a task to update this sample to use mode 3 when there is proper controller support |
Add Channel sounding ranging requestor sample with distance estimation algorithm.