v2:
Changes constaned to patch 0002:
- Fixed returned status in config pub/sub model calls
- Consistent use of pub_enabled & sub_enabled in the code
************
If a model does not support either subscription mechanism,
Config Server is supposed to return "Not a Subscribe Model" if a Config Client sends
a subscription add/overwrite message.
Similarly, if a model does not support publication, "Invalid Publish Parameters"
should be returned in response to Publication Set message.
Since config server is running even when an app is not attached, the only way to collect
these model capabilities is on Attach, Join, Create, Import methods when the
object manager collects app info.
To address this issue, signatures for properties "Models" and "VendorModels" on Element
interface change to include "options" dictionary:
Models: signature change "aq" -> "a(qa{sv})"
VendorModels: signature change "a(qq)" -> "a(qqa{sv})"
The defined keywords for the options dictionary are:
"Publish" - indicates whether the model supports publication mechanism.
If not present, publication is enabled.
"Subscribe" - indicates whether the model supports subscription mechanism.
If not present, subscriptions are enabled.
Inga Stotland (4):
doc/mesh-api: Add dictionary to model properties
mesh: Check app model settings of pub/sub support
tools/mesh-cfgclient: Add options to "Models" property
test/test-mesh: Add options to "Models" property
doc/mesh-api.txt | 40 ++++++++--
mesh/mesh-config-json.c | 76 +++++++++++++++++-
mesh/mesh-config.h | 8 ++
mesh/model.c | 98 +++++++++++++++++++----
mesh/model.h | 6 ++
mesh/node.c | 168 ++++++++++++++++++++++++++++++++--------
test/test-mesh | 21 ++---
tools/mesh-cfgclient.c | 25 ++++--
8 files changed, 374 insertions(+), 68 deletions(-)
--
2.26.2
This adds options dictionary to "Models" property to stay
in sync with mesh-api changes.
---
tools/mesh-cfgclient.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c
index 0dd02fad8..59f079213 100644
--- a/tools/mesh-cfgclient.c
+++ b/tools/mesh-cfgclient.c
@@ -1448,14 +1448,26 @@ static void proxy_removed(struct l_dbus_proxy *proxy, void *user_data)
}
}
+static void build_model(struct l_dbus_message_builder *builder, uint16_t mod_id,
+ bool pub_enable, bool sub_enable)
+{
+ l_dbus_message_builder_enter_struct(builder, "qa{sv}");
+ l_dbus_message_builder_append_basic(builder, 'q', &mod_id);
+ l_dbus_message_builder_enter_array(builder, "{sv}");
+ append_dict_entry_basic(builder, "Subscribe", "b", &sub_enable);
+ append_dict_entry_basic(builder, "Publish", "b", &pub_enable);
+ l_dbus_message_builder_leave_array(builder);
+ l_dbus_message_builder_leave_struct(builder);
+}
+
static bool mod_getter(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
void *user_data)
{
- l_dbus_message_builder_enter_array(builder, "q");
- l_dbus_message_builder_append_basic(builder, 'q', &app.ele.mods[0]);
- l_dbus_message_builder_append_basic(builder, 'q', &app.ele.mods[1]);
+ l_dbus_message_builder_enter_array(builder, "(qa{sv})");
+ build_model(builder, app.ele.mods[0], false, false);
+ build_model(builder, app.ele.mods[1], false, false);
l_dbus_message_builder_leave_array(builder);
return true;
@@ -1466,7 +1478,7 @@ static bool vmod_getter(struct l_dbus *dbus,
struct l_dbus_message_builder *builder,
void *user_data)
{
- l_dbus_message_builder_enter_array(builder, "(qq)");
+ l_dbus_message_builder_enter_array(builder, "(qqa{sv})");
l_dbus_message_builder_leave_array(builder);
return true;
@@ -1517,9 +1529,10 @@ static void setup_ele_iface(struct l_dbus_interface *iface)
/* Properties */
l_dbus_interface_property(iface, "Index", 0, "y", ele_idx_getter,
NULL);
- l_dbus_interface_property(iface, "VendorModels", 0, "a(qq)",
+ l_dbus_interface_property(iface, "VendorModels", 0, "a(qqa{sv})",
vmod_getter, NULL);
- l_dbus_interface_property(iface, "Models", 0, "aq", mod_getter, NULL);
+ l_dbus_interface_property(iface, "Models", 0, "a(qa{sv})", mod_getter,
+ NULL);
/* Methods */
l_dbus_interface_method(iface, "DevKeyMessageReceived", 0,
--
2.26.2
This adds options dictionary to "Models" property to stay
in sync with mesh-api changes.
---
test/test-mesh | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/test/test-mesh b/test/test-mesh
index 7c8a25482..5da0278d6 100755
--- a/test/test-mesh
+++ b/test/test-mesh
@@ -430,32 +430,35 @@ class Element(dbus.service.Object):
dbus.service.Object.__init__(self, bus, self.path)
def _get_sig_models(self):
- ids = []
+ mods = []
for model in self.models:
+ opts = []
id = model.get_id()
vendor = model.get_vendor()
if vendor == VENDOR_ID_NONE:
- ids.append(id)
- return ids
+ mod = (id, opts)
+ mods.append(mod)
+ return mods
def _get_v_models(self):
- ids = []
+ mods = []
for model in self.models:
+ opts = []
id = model.get_id()
v = model.get_vendor()
if v != VENDOR_ID_NONE:
- vendor_id = (v, id)
- ids.append(vendor_id)
- return ids
+ mod = (v, id, opts)
+ mods.append(mod)
+ return mods
def get_properties(self):
vendor_models = self._get_v_models()
sig_models = self._get_sig_models()
props = {'Index' : dbus.Byte(self.index)}
- props['Models'] = dbus.Array(sig_models, signature='q')
+ props['Models'] = dbus.Array(sig_models, signature='(qa{sv})')
props['VendorModels'] = dbus.Array(vendor_models,
- signature='(qq)')
+ signature='(qqa{sv})')
#print(props)
return { MESH_ELEMENT_IFACE: props }
--
2.26.2
This changes the signature of "Models" and "VendorModels" properties
on org.bluez.mesh.Element1 interface to contain a dictionary with
model options.
Models: signature change "aq" -> "a(qa{sv})"
VendorModels: signature change "a(qq)" -> "a(qqa{sv})"
Currently, the defined keywords for the options dictionary are
"Publish" - indicates whether the model supports publication mechanism.
If not present, publication is enabled.
"Subscribe" - indicates whether the model supports subscription mechanism.
If not present, subscriptions are enabled.
The dictionary allowed to be empty.
---
doc/mesh-api.txt | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt
index 3be11e342..495f95b0b 100644
--- a/doc/mesh-api.txt
+++ b/doc/mesh-api.txt
@@ -888,15 +888,43 @@ Properties:
Element index. It is required that the application follows
sequential numbering scheme for the elements, starting with 0.
- array{uint16} Models [read-only]
+ array{(uint16 id, dict caps)} Models [read-only]
- An array of SIG Model Identifiers. The array may be empty.
+ An array of SIG Models:
- array{(uint16, uint16)} VendorModels [read-only]
+ id - SIG Model Identifier
- An array of pairs (vendor, model ID): vendor is a 16-bit
- Bluetooth-assigned Company ID as defined by Bluetooth SIG.
- model ID is a 16-bit vendor-assigned Model Identifier
+ options - a dictionary that may contain additional model
+ info. The following keys are defined:
+
+ boolean Publish - indicates whether the model
+ supports publication mechanism. If not
+ present, publication is enabled.
+
+ boolean Subscribe - indicates whether the model
+ supports subscription mechanism. If not
+ present, subscriptons are enabled.
+
+ The array may be empty.
+
+
+ array{(uint16 vendor, uint16 id, dict options)} VendorModels [read-only]
+
+ An array of Vendor Models:
+
+ vendor - a 16-bit Bluetooth-assigned Company ID as
+ defined by Bluetooth SIG.
+
+ id - a 16-bit vendor-assigned Model Identifier
+
+ options - a dictionary that may contain additional model
+ info. The following keys are defined:
+
+ boolean Publish - indicates whether the model
+ supports publication mechanism
+
+ boolean Subscribe - indicates whether the model
+ supports subscription mechanism
The array may be empty.
--
2.26.2
Patchset Applied
On Tue, 2020-06-30 at 11:56 -0700, Inga Stotland wrote:
> v2:
>
> Changes constaned to patch 0002:
>
> - Fixed returned status in config pub/sub model calls
> - Consistent use of pub_enabled & sub_enabled in the code
>
> ************
> If a model does not support either subscription mechanism,
> Config Server is supposed to return "Not a Subscribe Model" if a Config Client sends
> a subscription add/overwrite message.
>
> Similarly, if a model does not support publication, "Invalid Publish Parameters"
> should be returned in response to Publication Set message.
>
> Since config server is running even when an app is not attached, the only way to collect
> these model capabilities is on Attach, Join, Create, Import methods when the
> object manager collects app info.
>
> To address this issue, signatures for properties "Models" and "VendorModels" on Element
> interface change to include "options" dictionary:
> Models: signature change "aq" -> "a(qa{sv})"
> VendorModels: signature change "a(qq)" -> "a(qqa{sv})"
>
> The defined keywords for the options dictionary are:
> "Publish" - indicates whether the model supports publication mechanism.
> If not present, publication is enabled.
> "Subscribe" - indicates whether the model supports subscription mechanism.
> If not present, subscriptions are enabled.
>
> Inga Stotland (4):
> doc/mesh-api: Add dictionary to model properties
> mesh: Check app model settings of pub/sub support
> tools/mesh-cfgclient: Add options to "Models" property
> test/test-mesh: Add options to "Models" property
>
> doc/mesh-api.txt | 40 ++++++++--
> mesh/mesh-config-json.c | 76 +++++++++++++++++-
> mesh/mesh-config.h | 8 ++
> mesh/model.c | 98 +++++++++++++++++++----
> mesh/model.h | 6 ++
> mesh/node.c | 168 ++++++++++++++++++++++++++++++++--------
> test/test-mesh | 21 ++---
> tools/mesh-cfgclient.c | 25 ++++--
> 8 files changed, 374 insertions(+), 68 deletions(-)
>