Skip to content

Conversation

@Blackladder
Copy link
Contributor

@Blackladder Blackladder commented Jul 2, 2019

Make remote features and remote version accesible to the application
through the bt_conn_get_info object.
get_remote_version() is called if the remote version is not stored
in the new fields in struct bt_conn.

@zephyrbot
Copy link

zephyrbot commented Jul 2, 2019

All checks are passing now.

checkpatch (informational only, not a failure)

-:341: WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#341: FILE: subsys/bluetooth/host/conn.c:1955:
+		*  extended features has finished. */

-:341: WARNING:BLOCK_COMMENT_STYLE: Block comments should align the * on each line
#341: FILE: subsys/bluetooth/host/conn.c:1955:
+		/* TODO: Make sure the HCI commands to read br features and
+		*  extended features has finished. */

-:678: WARNING:LONG_LINE: line over 80 characters
#678: FILE: subsys/bluetooth/shell/bt.c:258:
+			    "manufacturer 0x%04x", ver_str(remote_info->version),

- total: 0 errors, 3 warnings, 673 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@Blackladder Blackladder force-pushed the master branch 2 times, most recently from f9b7beb to 73451b9 Compare July 3, 2019 07:23
@Blackladder
Copy link
Contributor Author

Added the changes mentioned by @joerchan

@joerchan joerchan requested a review from Vudentz July 18, 2019 08:42
@Vudentz
Copy link
Contributor

Vudentz commented Jul 18, 2019

If I recall correctly, I suggested having a dedicated API to trigger the remote info, i.e bt_conn_remote_info so we don't cause extra traffic with the likes of bt_conn_info.

@Blackladder Blackladder force-pushed the master branch 2 times, most recently from 3251ca3 to cec8a54 Compare July 18, 2019 10:43
@Blackladder
Copy link
Contributor Author

With the latest commit, I have separated the retrieval of remote version into a new function bt_conn_remote_info like @Vudentz suggested and there no longer is a rv struct in bt_conn_info.

@Blackladder Blackladder force-pushed the master branch 4 times, most recently from 467dba9 to 24d4df9 Compare July 18, 2019 12:14
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove and set

@joerchan joerchan self-requested a review December 12, 2019 20:02
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

Looking much better. I think this solution is the right one, instead of bundling this into con info. Also the callback is much better and optimal than the blocking call.
A couple of loose ends.

Copy link
Member

Choose a reason for hiding this comment

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

Should this be enclosed in #ifdef CONFIG_BT_REMOTE_VERSION ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be static atleast.

I think using IS_ENABLED(CONFIG_BT_REMOTE) { hci_read_remote_version() } is enough to optimize it out. So it should not be included this way.
Checking with nm there is no hci_read_remote_version in the zephyr.elf file.

Copy link
Member

@carlescufi carlescufi Dec 13, 2019

Choose a reason for hiding this comment

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

Are you using BT_CONN_AUTO_VERSION_INFO before defining it or am I seeing the wrong commit order?
I see now, disregard this comment.

@carlescufi carlescufi changed the title Bluetooth: host: Add calling of read_remote_version Bluetooth: host: Add support for retrieving the remote version Dec 13, 2019
Copy link
Member

Choose a reason for hiding this comment

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

Add a comma to the end of this line, in case the struct gets extended in the future

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. 👍

Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

Looks great now.
Also, this PR reduces in 105 bytes the ROM footprint of samples/bluetooth/peripheral in its default config.

Comment on lines +4974 to +4980
Copy link
Member

Choose a reason for hiding this comment

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

The handler should either be in normal_events[] or in prio_events[] but not both. I guess you're "deprioritizing" it along with this PR, so the above chunk should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. That is an oversight. Will remove.

Comment on lines 9 to 10
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the move of this define unnecessary now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I will move it back again.

Copy link
Contributor

@joerchan joerchan left a comment

Choose a reason for hiding this comment

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

Revert prio changes not complete,

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

Looks like doc changes are all in the doxygen comments, LGTM.

Avoid floating point usage when possible. E.g. on qemu_x86 this would
otherwise result in something like the following:

<err> os: Floating point unit not enabled
<err> os: eax: 0x00000024, ebx: 0x00000000, ecx: 0x00248fc8,
          edx: 0x00146120
<err> os: esi: 0x0012b30c, edi: 0x0024c628, ebp: 0x0024c638,
          esp: 0x0024c5b8
<err> os: eflags: 0x00000216 cs: 0x0008 cr3: 0x001465a0
<err> os: call trace:
<err> os: eip: 0x00121c8d
<err> os:      0x0010679c (0x127750)
<err> os:      0x0010693b (0x100f33)
<err> os:      0x001061bc (0x12b800)
<err> os:      0x001074fb (0x0)
<err> os:      0x00101151 (0x12b800)
<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception
<err> os: Current thread: 0x00146120 (shell_uart)
<err> os: Halting system

Signed-off-by: Johan Hedberg <[email protected]>
@joerchan joerchan force-pushed the master branch 2 times, most recently from bd847e8 to b316687 Compare December 19, 2019 16:50
@joerchan joerchan dismissed their stale review December 19, 2019 16:53

Fixed revert of prio changes

@joerchan
Copy link
Contributor

@jhedberg @carlescufi Fixed reverting of the prio changes. I had some trouble with git giving me the wrong commit in blame which ended up silently bringing the changes back.

So please give this a thorough overview :) in case other cases of amending commits went wrong.

I have looked over now and it looks ok to me. But I don't think it is right that I approve my own changes so I won't approve this.

@carlescufi carlescufi dismissed cvinayak’s stale review December 19, 2019 16:59

Stale, please re-review

Comment on lines +3817 to +3876
Copy link
Member

@jhedberg jhedberg Dec 19, 2019

Choose a reason for hiding this comment

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

It seems that you haven't introduced the bt_hci_evt_read_remote_version_complete() yet in this patch - it only comes in a later one. Btw, a good way to check that each commit builds on its own is something like git rebase -i --exec="west build" origin/master. That will run the command given to the --exec switch for every commit that's part of the rebase.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, you haven't introduced the CONFIG_BT_REMOTE_VERSION option either here. I know this is a rather pedantic approach but it helps later when doing something like git bisect since every commit that it might land on should be sane and buildable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, good catch. I don't know exactly how it happened but some of my fixup commits ended up in the wrong commits.
The --exec="" was a good tip. Although in this case it wouldn't have caught it as it still compiled due to the CONFIG_BT_REMOTE_VERSION not having been defined.

Moved the change to the right commit.

joerchan and others added 4 commits December 19, 2019 22:49
This commit reverts the change that moved the remote version event from
a priority event to a normal event. This is done because the strategy
for using this event has been changed and will be used with a callback
instead of a semaphore that could be locked from the RX thread.

This commit retains the infrastructure that was added in the controller
so that moving events to priority processing is still possible.

Signed-off-by: Joakim Andersson <[email protected]>
Refactor the handling of the host auto initiated LL procedures.
This makes it easier to add new auto initiated procedures as well as
reduced the maintenance by reducing code duplication.

Signed-off-by: Joakim Andersson <[email protected]>
Make remote features and remote version accesible to the application
through the bt_conn_get_remote_info object. The host will auto initiate
the procedures. If the procedures have not finished with the application
calls bt_conn_get_remote_info then EBUSY will be returned.
The procedures should finish during the first 10 connection intervals.

Signed-off-by: Sverre Storvold <[email protected]>
Signed-off-by: Joakim Andersson <[email protected]>
Add printing of the remote version information whenever the new
CONFIG_BT_REMOTE_VERSION option is enabled.

Signed-off-by: Johan Hedberg <[email protected]>
@jhedberg jhedberg merged commit 4e135d7 into zephyrproject-rtos:master Dec 23, 2019
((conn->role == BT_HCI_ROLE_MASTER) ||
BT_FEAT_LE_SLAVE_FEATURE_XCHG(bt_dev.le.features))) {
err = hci_le_read_remote_features(conn);
if (!err) {
Copy link

@klgsnd klgsnd Apr 3, 2020

Choose a reason for hiding this comment

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

Hi guys, @jhedberg @Blackladder

I wonder whether the condition is correct. Shouldn't it be just if (err) ? It looks like it was borrowed from the commits this PR was based on.

I found this issue when tried to update connection parameters from the app level. They are simply not updated, because of the timer-specifics involved in the call of slave_update_conn_param() which is below in this function. And this slave_update_conn_param() is not called when conditions like I mentioned return from the conn_auto_initiate()..

Copy link
Contributor

@joerchan joerchan Apr 3, 2020

Choose a reason for hiding this comment

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

if (!err) is the correct expression here. It returns on success of sending the command. If not success it moves to the next one. You can see it does that for all of the HCI procedures in this function. Once the procedure completes this function will be called and the next procedure should be initiated.

Copy link

@klgsnd klgsnd Apr 3, 2020

Choose a reason for hiding this comment

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

Thanks for the reply!
Sorry, I still don't get it. Shouldn't the happy-flow mean that all calls should succeed (given that their corresponding if-conditions are true - IS_ENABLED):

  • hci_le_read_remote_features()
  • hci_read_remote_version()
  • hci_le_set_phy()
  • hci_le_set_data_len()
  • slave_update_conn_param()

Why quit conn_auto_initiate() if PHY succeeds for example? Is there a relation between success on remote features and auto PHY negotiation, and DLE and Peripheral Conn Params Update Request?

My issue is that if slave_update_conn_param() is not called at all, then there is no way peripheral can initiate the update of connection parameters after the connection is established. Neither the initial auto update (slave_update_conn_param), nor from 'bt_le_conn_param_update()`. Isn't it a bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dnsglk The intention is to call all of them. But the three first in the list are asynchronous, and only one can be active at a time.
If hci_le_read_remote_features is called, then conn_auto_initiate will be called again from bt_hci_evt_read_remote_version_complete, and this time it will call the next function in your list.
hci_le_set_data_len() and slave_update_conn_param() can be called simultaneously, so they don't have this behavior.

Copy link

Choose a reason for hiding this comment

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

I see now. In my case then, gdb shows that le_phy_update_complete() is not called for whatever reason...

Copy link

Choose a reason for hiding this comment

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

@joerchan thanks for spending time explaining it. Anyway, it still looks like something to improve IMO. Because, if remote doesn't respond to that query (which is my guess on why the phy callback is not triggered), it still means that not all of auto initialization has been completed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dnsglk Can you create an bug-report with the missing le_phy_update_complete and tell us how to reproduce this problem? Please be as detailed as possible

Copy link

Choose a reason for hiding this comment

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

@joerchan I'll post a report if it I have more time to dig deeper into the issue. Thanks for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Bluetooth area: Documentation area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.