-
Notifications
You must be signed in to change notification settings - Fork 33
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
Requirements for implementing the Matter BTP protocol on top of trouble-host
#135
Comments
|
Just a real minor nit, but for clarity, indication's have ACKs and notifications do not. It is also possible to have both notifications and indications allowed for a characteristic and the client could enable one or the other (or both). |
I think it's probably worth revisiting whether there are still outstanding requirements from this issue, now that #200 is merged. @ivmarkov would you mind taking another look at this in light of the recent changes which have been made to trouBLE and let us know if there are further features which are needed to fully address it? |
I need a couple of weeks or so to get back to this, as I was completely underwater during the last three months. Is TrouBLE also supporting indications in the meantime? And confirmed writes? |
(This is a follow up on the Embassy Matrix room discussion here.)
Overview
I'm currently researching for a way to layer the Matter BTP protocol (section "4.18. Bluetooth Transport Protocol (BTP)" of the Matter Core Spec V1.3) on top of
trouble-host
.(
rs-matter
codebase too, as it is available online, and has an out-of-the-box implementation on top of BlueZ, as well as an ESP-IDF Bluedroid implementation).
A very short, informal summary of what are the BTP protocol requirements w.r.t. a GATT Server: it boils down to modeling a duplex read/write pipe on top of two characteristics (referred to as
C1
andC2
) in the BTP spec:Write
-Confirmed permission, and serves as the "read" end of the pipe, from the POV of the device which is being commissioned (the GATT server), and as the "write" end of the pipe from the point of view of the Commissioner (your phone)In terms of requirements around these two characteristics:
C1
we need the Matter BTP implementation code to be notified about every single incoming write request, with the following data:C2
:C2
Additionally, we must be able to advertise our own vendor-specific payload, which is described in "5.4.2.5.6. Advertising Data" of the Matter Core Spec.
In terms of how a GATT "peripheral", specific to the purposes of the BTP protocol might look like, you can look here. (Do note that whether the
C1
writes are coming via a blocking callback or are somehow "pulled" usingasync
next external style iteration is not set in stone and we can change that.)Challenges with
trouble-host
One challenge identified so far is that
trouble-host
uses a static storage for each characteristic which is the same across all connections and which gets overwritten each time we get a write on the characteristic.While this is not necessarily a problem per se, Matter BTP simply does not need and cannot make use of such a "single static storage per characteristic" model.
======
One way to completely bypass the static storage is to implement a "give me the read/write data and I'll store it myself somewhere" user-style callback exercised here.
Whether such a callback is preserving the "attribute table" without its data aspect or not is orthogonal to the Matter BTP implementation, because in it, the characteristic are static.
=====
Another way would be to keep the "attribute-table" and the "single, static, fixed-size storage of each characteristic" intact, and then hack our way around it. Also a WIP POC to be implementing an
rs-matter
GATT Peripheral specific to the BTP stack, using this approach/hack.Turns out, it might not be as difficult as I think, by just making use of
GattEvent
s, which - while dispatched "post-factum" after the data was read/written - still would allow us to figure out what data the peer was sending to us, by just reading it "post-factum" from the static characteristic storage, before it gets overwritten with the next characteristic Write request coming from the peer.My next step is to try to prototype this approach, with another PR. Extensions to
trouble-host
would still be necessary:GattEvent
is dispatched).C2
. Not sure if this is in-place, as I only see aGattServer::notify
(i.e. unconfirmed notification) methodC1
, I'm not sure iftrouble-host
supports confirmed writesThe text was updated successfully, but these errors were encountered: