All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Guy Morand <g.morand@scewo.ch>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: Bluetooth disconnect event / Link layer monitoring
Date: Mon, 18 Nov 2019 20:27:42 +0200	[thread overview]
Message-ID: <CABBYNZ+VfyOeWjfdE64bVQM0eAJE789NRBjy+wgKa_Dka2ZZJg@mail.gmail.com> (raw)
In-Reply-To: <CAGssATiS=dpA=WOSfLek385o2g=C5sb0z+z=V7CDswn9_5Eu-g@mail.gmail.com>

Hi Guy,

On Mon, Nov 18, 2019 at 7:19 PM Guy Morand <g.morand@scewo.ch> wrote:
>
> Hello bluetooth developers,
>
> We are developing a wheelchair that we can controle with a bluetooth
> gamepad, the XBOX 360 controller to be more precise. It basically works
> fine but when I remove the battery, I get the disconnect event in the
> user space around 10 seconds later. That is not acceptable since the
> wheelchair will keep rolling to potentially dangerous places!
>
> I tried to implement a ping mechanism on the bluetooth layer, inspired
> from bluez sources somewhere:
>   int _socket_fd = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP);
>   // bind on AF_BLUETOOTH
>   // connect with AF_BLUETOOTH
>
>   send_cmd->ident = PING_IDENT;
>   send_cmd->len = htobs(PING_DATA_SIZE);
>   send_cmd->code = L2CAP_ECHO_REQ;
>   if (send(_socket_fd, send_buffer, PING_PACKET_SIZE, 0) <= 0) {
>     // ...
>   }
>
> It basically works fine except when the signal gets bad. This will get
> printed by the kernel:
> [  859.629431] Bluetooth: hci0 link tx timeout
> [  859.635482] Bluetooth: hci0 killing stalled connection 9c:aa:1b:6b:51:c9
>
> In that case, I don't get event from the /dev/jsX device but the gamepad
> seems to still answer to pings??!!
>
> Since I haven't found any acceptable workaround and always find the same
> pages again and again, I'm asking here:
> * Is it possible to achieve what I want?
> * Does it make sense that the ping work but the HID layer seems dead?
> * Any recommendation, pointers?

Id look into adjusting the link supervision timeout instead of
creating a raw socket, you can use hcitool to do that, neither is
really great since it require root but at least the supervision
timeout is something a lot more reliable for this.

-- 
Luiz Augusto von Dentz

  reply	other threads:[~2019-11-18 18:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18 17:16 Bluetooth disconnect event / Link layer monitoring Guy Morand
2019-11-18 18:27 ` Luiz Augusto von Dentz [this message]
2019-11-19  5:06   ` Marcel Holtmann
2019-11-19  9:09     ` Guy Morand
2019-11-21 17:37       ` Guy Morand
2019-12-02 14:17         ` Guy Morand

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+VfyOeWjfdE64bVQM0eAJE789NRBjy+wgKa_Dka2ZZJg@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=g.morand@scewo.ch \
    --cc=linux-bluetooth@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.