linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: "Jonas Dreßler" <verdre@v0yd.nl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 3/4] emulator/btdev: Send page timeout after 2 secs delay
Date: Mon, 29 Jan 2024 08:58:00 -0500	[thread overview]
Message-ID: <CABBYNZ+ujvMRouSMxPavG+mt3p8M6-otphEEj3U6sos_o=wJKg@mail.gmail.com> (raw)
In-Reply-To: <20240129114900.92919-4-verdre@v0yd.nl>

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.


-- 
Luiz Augusto von Dentz

  reply	other threads:[~2024-01-29 13:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 11:48 [PATCH BlueZ 0/4] Adjust tests for sequential conn establishing Jonas Dreßler
2024-01-29 11:48 ` [PATCH BlueZ 1/4] mgmt-tester: Add a 0-opcode to expect_hci_list lists Jonas Dreßler
2024-01-29 13:40   ` Luiz Augusto von Dentz
2024-02-06 10:26     ` Jonas Dreßler
2024-01-29 13:52   ` Adjust tests for sequential conn establishing bluez.test.bot
2024-01-29 11:48 ` [PATCH BlueZ 2/4] mgmt-tester: Adjust a test for recent kernel changes Jonas Dreßler
2024-01-29 13:41   ` Luiz Augusto von Dentz
2024-01-29 11:48 ` [PATCH BlueZ 3/4] emulator/btdev: Send page timeout after 2 secs delay Jonas Dreßler
2024-01-29 13:58   ` Luiz Augusto von Dentz [this message]
2024-01-29 11:49 ` [PATCH BlueZ 4/4] mgmt-tester: Add a test for connecting sequentially Jonas Dreßler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABBYNZ+ujvMRouSMxPavG+mt3p8M6-otphEEj3U6sos_o=wJKg@mail.gmail.com' \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=verdre@v0yd.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).