Message ID | 20240129114900.92919-4-verdre@v0yd.nl (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Adjust tests for sequential conn establishing | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | warning | WARNING:LONG_LINE: line length of 86 exceeds 80 columns #102: FILE: emulator/btdev.c:1322: + struct page_timeout_data *pt_data = new0(struct page_timeout_data, 1); WARNING:LINE_SPACING: Missing a blank line after declarations #103: FILE: emulator/btdev.c:1323: + struct page_timeout_data *pt_data = new0(struct page_timeout_data, 1); + pt_data->btdev = dev; /github/workspace/src/src/13535451.patch total: 0 errors, 2 warnings, 42 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. /github/workspace/src/src/13535451.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
Hi Jonas, On Mon, Jan 29, 2024 at 6:49 AM Jonas Dreßler <verdre@v0yd.nl> wrote: > > Real bluetooth adapters wouldn't send the page timeout immediately > when trying to page a device, instead it would take a few seconds. > > Try to behave more realistically in the emulator and send the page > timeout after two seconds. > --- > emulator/btdev.c | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/emulator/btdev.c b/emulator/btdev.c > index da94f29d1..a40117400 100644 > --- a/emulator/btdev.c > +++ b/emulator/btdev.c > @@ -1281,6 +1281,27 @@ static void conn_complete(struct btdev *btdev, > send_event(btdev, BT_HCI_EVT_CONN_COMPLETE, &cc, sizeof(cc)); > } > > +struct page_timeout_data { > + struct btdev *btdev; > + uint8_t bdaddr[6]; > + unsigned int timeout_id; > +}; > + > +static bool page_timeout(void *user_data) > +{ > + struct page_timeout_data *pt_data = user_data; > + struct btdev *btdev = pt_data->btdev; > + const uint8_t *bdaddr = pt_data->bdaddr; > + > + timeout_remove(pt_data->timeout_id); > + pt_data->timeout_id = 0; > + > + conn_complete(btdev, bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); > + > + free(pt_data); > + return false; > +} > + > static int cmd_create_conn_complete(struct btdev *dev, const void *data, > uint8_t len) > { > @@ -1298,7 +1319,14 @@ static int cmd_create_conn_complete(struct btdev *dev, const void *data, > > send_event(remote, BT_HCI_EVT_CONN_REQUEST, &cr, sizeof(cr)); > } else { > - conn_complete(dev, cmd->bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); > + struct page_timeout_data *pt_data = new0(struct page_timeout_data, 1); > + pt_data->btdev = dev; > + memcpy(pt_data->bdaddr, cmd->bdaddr, 6); > + > + /* Send page timeout after 2 seconds to emulate real paging */ > + pt_data->timeout_id = timeout_add(2000, > + page_timeout, > + pt_data, NULL); > } > > return 0; > -- > 2.43.0 We currently don't set a specific page timeout which means we are using the default value which is 5.12 sec, so I'd replace 2000 with 5120, we might have to do something similar to LE Audio scanning though since during this period the remote instance could enable connections which should trigger the connection request event as well.
diff --git a/emulator/btdev.c b/emulator/btdev.c index da94f29d1..a40117400 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -1281,6 +1281,27 @@ static void conn_complete(struct btdev *btdev, send_event(btdev, BT_HCI_EVT_CONN_COMPLETE, &cc, sizeof(cc)); } +struct page_timeout_data { + struct btdev *btdev; + uint8_t bdaddr[6]; + unsigned int timeout_id; +}; + +static bool page_timeout(void *user_data) +{ + struct page_timeout_data *pt_data = user_data; + struct btdev *btdev = pt_data->btdev; + const uint8_t *bdaddr = pt_data->bdaddr; + + timeout_remove(pt_data->timeout_id); + pt_data->timeout_id = 0; + + conn_complete(btdev, bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); + + free(pt_data); + return false; +} + static int cmd_create_conn_complete(struct btdev *dev, const void *data, uint8_t len) { @@ -1298,7 +1319,14 @@ static int cmd_create_conn_complete(struct btdev *dev, const void *data, send_event(remote, BT_HCI_EVT_CONN_REQUEST, &cr, sizeof(cr)); } else { - conn_complete(dev, cmd->bdaddr, BT_HCI_ERR_PAGE_TIMEOUT); + struct page_timeout_data *pt_data = new0(struct page_timeout_data, 1); + pt_data->btdev = dev; + memcpy(pt_data->bdaddr, cmd->bdaddr, 6); + + /* Send page timeout after 2 seconds to emulate real paging */ + pt_data->timeout_id = timeout_add(2000, + page_timeout, + pt_data, NULL); } return 0;