Mesh send/publish API change
v3 cover Mesh send/publish API change
This patch set modifies Send, DevKeySend and Publish methods on bluez.mesh.Node interface to include additional argument "options".
This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend():
"ForceSegmented" - to force small payloads to be sent as
one-segment messages
Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification.
********* v2 ************
In case of Publish(), and additional keyword is defined
"Vendor" - 16-bit Company ID as defined by the Bluetooth SIG
This allows us to eliminate VendorPublish() method.
********* v3 ************
Added Vendor specific clarity to the Publish() method description in mesh-api.txt, since VendorPublish() is removed.
Inga Stotland (4):
doc/mesh-api: Add "options" dictionary to Send/Publish
mesh: Handle "options" dictionary in Send/Publish methods tools/mesh-cfglient: Add "options" to Send/DevKeySend test/test-mesh: Add "options" to Send/Publish
doc/mesh-api.txt | 60 ++++++++++-------- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 ++++++++++++++++++++--------------------- test/test-mesh | 11 +++- tools/mesh-cfgclient.c | 8 +++ 7 files changed, 127 insertions(+), 109 deletions(-)
Signature · 1 line
2.25.4
PATCH v3 1/4 doc/mesh-api: Add "options" dictionary to Send/Publish
From: Inga Stotland <[email protected]>
This modifies Send, DevKeySend and Publish methods
on mesh.Node interface to include additional argument "options". This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend():
"ForceSegmented" - to force small payloads to be sent as
one-segment messages
In case of Publish(), and additional keyword is defined
"Vendor" - 16-bit Company ID as defined by the Bluetooth SIG
Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification.
Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword).
--- doc/mesh-api.txt | 60 ++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 25 deletions(-)
doc/mesh-api.txt +35 -25
@@ -229,7 +229,7 @@ Object path /org/bluez/mesh/node<uuid> Methods: void Send(object element_path, uint16 destination, uint16 key_index, - array{byte} data) + dict options, array{byte} data) This method is used to send a message originated by a local model.
@@ -248,6 +248,14 @@ Methods: this element. Otherwise, org.bluez.mesh.Error.NotAuthorized will be returned. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the bluetooth-meshd daemon and sent on.
@@ -257,7 +265,7 @@ Methods: org.bluez.mesh.Error.NotFound void DevKeySend(object element_path, uint16 destination, boolean remote, - uint16 net_index, array{byte} data) + uint16 net_index, dict options, array{byte} data) This method is used to send a message originated by a local model encoded with the device key of the remote node.
@@ -279,6 +287,14 @@ Methods: The net_index parameter is the subnet index of the network on which the message is to be sent. + The options parameter is a dictionary with the following keys + defined: + + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". + The data parameter is an outgoing message to be encypted by the meshd daemon and sent on.
@@ -344,7 +360,8 @@ Methods: org.bluez.mesh.Error.InvalidArguments org.bluez.mesh.Error.NotFound - void Publish(object element_path, uint16 model, array{byte} data) + void Publish(object element_path, uint16 model, dict options, + array{byte} data) This method is used to send a publication originated by a local model. If the model does not exist, or it has no publication
@@ -356,32 +373,24 @@ Methods: Hierarchy section). The model parameter contains a model ID, as defined by the - Bluetooth SIG. - - Since only one Publish record may exist per element-model, the - destination and key_index are obtained from the Publication - record cached by the daemon. + Bluetooth SIG. If the options dictionary contains a "Vendor" + key, then this ID is defined by the specified vendor. - Possible errors: - org.bluez.mesh.Error.DoesNotExist - org.bluez.mesh.Error.InvalidArguments - - void VendorPublish(object element_path, uint16 vendor, uint16 model_id, - array{byte} data) - - This method is used to send a publication originated by a local - vendor model. If the model does not exist, or it has no - publication record, the method returns - org.bluez.mesh.Error.DoesNotExist error. + The options parameter is a dictionary with the following keys + defined: - The element_path parameter is the object path of an element from - a collection of the application elements (see Mesh Application - Hierarchy section). + bool ForceSegmented + Specifies whether to force sending of a short + message as one-segment payload. If not present, + the default setting is "false". - The vendor parameter is a 16-bit Bluetooth-assigned Company ID. + uint16 Vendor + A 16-bit Company ID as defined by the + Bluetooth SIG. This key should only exist when + publishing on a Vendor defined model. - The model_id parameter is a 16-bit vendor-assigned Model - Identifier. + The data parameter is an outgoing message to be encypted by the + meshd daemon and sent on. Since only one Publish record may exist per element-model, the destination and key_index are obtained from the Publication
@@ -391,6 +400,7 @@ Methods: org.bluez.mesh.Error.DoesNotExist org.bluez.mesh.Error.InvalidArguments + Properties: dict Features [read-only]
Signature · 1 line
2.25.4
RE: [BlueZ,v3,1/4] doc/mesh-api: Add "options" dictionary to Send/Publish
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning.
Test Result:
checkgitlint Failed
Outputs:
8: B3 Line contains hard tab characters (\t): " one-segment messages"
---
Regards,
Linux Bluetooth
PATCH v3 2/4 mesh: Handle "options" dictionary in Send/Publish methods
In reply to Brian GixFrom: Inga Stotland <[email protected]>
This adds processing of "options" dictionary argument in Send, DevKeySend & Publish methods on mesh.Node interface.
This new argument is a dictionary that currently has only one new key word defined for Send() and DevKeySend():
"ForceSegmented" - to force small payloads to be sent as
one-segment messages
In case of Publish(), and additional keyword is defined
"Vendor" - 16-bit Company ID as defined by the Bluetooth SIG
Other key words may be defined in future to accommodate evolving requirements of Mesh Profile specification.
Also, the addition of "options" dictionary to Publish allows to eliminate VendorPublish() method (taken care by "Vendor" keyword).
--- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 +++++++++++++++++++++---------------------- 4 files changed, 75 insertions(+), 82 deletions(-)
mesh/cfgmod-server.c +1 -1
@@ -1088,7 +1088,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,if (n)mesh_model_send (node, dst, src,APP_IDX_DEV_LOCAL , net_idx, -DEFAULT_TTL , false, msg, n); +DEFAULT_TTL , false, n, msg);return true; }
mesh/model.c +3 -3
@@ -999,7 +999,7 @@ done: }int mesh_model_publish (struct mesh_node *node,uint32_t id,uint16_t src, -const void *msg,uint16_t msg_len) +bool segmented,uint16_t msg_len,const void *msg) {struct mesh_net *net =node_get_net (node);struct mesh_model *mod;
@@ -1041,7 +1041,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src, result =msg_send (node, mod->pub->credential !=0 , src, mod->pub->addr, mod->pub->idx, net_idx, label, mod->pub->ttl, mod->pub->rtx.cnt, mod->pub->rtx.interval, - false, msg, msg_len); + segmented, msg, msg_len);return result ?MESH_ERROR_NONE :MESH_ERROR_FAILED ; }
@@ -1049,7 +1049,7 @@ int mesh_model_publish(struct mesh_node *node, uint32_t id, uint16_t src,bool mesh_model_send (struct mesh_node *node,uint16_t src,uint16_t dst,uint16_t app_idx,uint16_t net_idx,uint8_t ttl,bool segmented, -const void *msg,uint16_t msg_len) +uint16_t msg_len,const void *msg) {struct mesh_net *net =node_get_net (node);uint8_t cnt;
mesh/model.h +3 -6
@@ -112,19 +112,16 @@ int mesh_model_sub_get(struct mesh_node *node, uint16_t ele_addr, uint32_t id, uint8_t *buf, uint16_t buf_size, uint16_t *size);uint16_t mesh_model_cfg_blk (uint8_t *pkt);bool mesh_model_send (struct mesh_node *node,uint16_t src,uint16_t dst, -uint16_t app_idx,uint16_t net_idx, -uint8_t ttl,bool segmented, -const void *msg,uint16_t msg_len); +uint16_t app_idx,uint16_t net_idx,uint8_t ttl, +bool segmented,uint16_t len,const void *data);int mesh_model_publish (struct mesh_node *node,uint32_t id,uint16_t src, -const void *msg,uint16_t msg_len); +bool segmented,uint16_t len,const void *data);bool mesh_model_rx (struct mesh_node *node,bool szmict,uint32_t seq0,uint32_t seq,uint32_t iv_index,uint16_t net_idx,uint16_t src,uint16_t dst,uint8_t key_aid,const uint8_t *data,uint16_t size); -void mesh_model_app_key_generate_new (struct mesh_node *node,uint16_t net_idx);void mesh_model_app_key_delete (struct mesh_node *node,uint16_t ele_idx,struct l_queue *models,uint16_t app_idx); -struct l_queue *mesh_model_get_appkeys (struct mesh_node *node);uint16_t mesh_model_opcode_set (uint32_t opcode,uint8_t *buf);bool mesh_model_opcode_get (const uint8_t *buf,uint16_t size,uint32_t *opcode,uint16_t *n);
mesh/node.c +68 -72
257 lines not on this page · raw message
Signature · 1 line
2.25.4
PATCH v3 3/4 tools/mesh-cfglient: Add "options" to Send/DevKeySend
In reply to Brian GixFrom: Inga Stotland <[email protected]>
This adds a new dictionary paramenter (empty by default) when invoking Send() and DevKeySend() methods.
--- tools/mesh-cfgclient.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/mesh-cfgclient.c +8 -0
@@ -274,6 +274,14 @@ static void send_msg_setup(struct l_dbus_message *msg, void *user_data)l_dbus_message_builder_append_basic (builder,'b' , &req->rmt);l_dbus_message_builder_append_basic (builder,'q' , &req->idx); + +/* Options */ +l_dbus_message_builder_enter_array (builder,"{sv}" ); +l_dbus_message_builder_enter_dict (builder,"sv" ); +l_dbus_message_builder_leave_dict (builder); +l_dbus_message_builder_leave_array (builder); + +/* Data */ append_byte_array (builder, req->data, req->len);l_dbus_message_builder_finalize (builder);l_dbus_message_builder_destroy (builder);
Signature · 1 line
2.25.4
PATCH v3 4/4 test/test-mesh: Add "options" to Send/Publish
In reply to Brian GixFrom: Inga Stotland <[email protected]>
This adds a new dictionary paramenter (empty by default) when invoking Send() or Publish() methods.
--- test/test-mesh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
test/test-mesh +9 -2
@@ -184,6 +184,9 @@ current_menu = None user_input = 0 input_error = False +send_opts = dbus.Dictionary(signature='sv') +send_opts = {'ForceSegmented' : dbus.Boolean(True)} + def raise_error(str_value): global input_error
@@ -538,14 +541,18 @@ class Model(): self.pub_period = period def send_publication(self, data): + pub_opts = dbus.Dictionary(signature='sv') + print('Send publication ', end='') print(data) - node.Publish(self.path, self.model_id, data, + node.Publish(self.path, self.model_id, pub_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb) def send_message(self, dest, key, data): - node.Send(self.path, dest, key, data, + global send_opts + + node.Send(self.path, dest, key, send_opts, data, reply_handler=generic_reply_cb, error_handler=generic_error_cb)
Signature · 1 line
2.25.4
Patchset Applied
Quoted 37 lines · Brian Gix
This patch set modifies Send, DevKeySend and Publish methods on bluez.mesh.Node interface to include additional argument "options".
This new argument is a dictionary that currently has only one new key word defined for
Send()andDevKeySend():
"ForceSegmented" - to force small payloads to be sent as
one-segment messagesOther key words may be defined in future to accommodate evolving requirements of Mesh Profile specification.
********* v2 ************
In case ofPublish(), and additional keyword is defined
"Vendor" - 16-bit Company ID as defined by the Bluetooth SIGThis allows us to eliminate
VendorPublish()method.********* v3 ************
Added Vendor specific clarity to thePublish()method description in mesh-api.txt, sinceVendorPublish()is removed.Inga Stotland (4):
doc/mesh-api: Add "options" dictionary to Send/Publish
mesh: Handle "options" dictionary in Send/Publish methodstools/mesh-cfglient: Add "options" to Send/DevKeySend test/test-mesh: Add "options" to Send/Publishdoc/mesh-api.txt | 60 ++++++++++-------- mesh/cfgmod-server.c | 2 +- mesh/model.c | 6 +- mesh/model.h | 9 +-- mesh/node.c | 140 ++++++++++++++++++++--------------------- test/test-mesh | 11 +++- tools/mesh-cfgclient.c | 8 +++ 7 files changed, 127 insertions(+), 109 deletions(-)