Reputation: 1
I am currently implementing a Provisioner node based on BlueZ v5.54 with example test-mesh using Python D-Bus API on Raspberry Pi 4, and I want to read the Composition Data of nodes in the mesh network. I tested it by using mesh-cfgclient
and it reads ok, so I think it should be possible in my approach.
However, I haven't discovered the solution until now. Do you guys have any method for this? I don't have too much experience with BlueZ D-Bus so any help would be greatly appreciated.
I tried it by using DevKeySend() with Config Composition Data Get message opcode, but it doesn't work and it shows nothing. Here is my code related to it:
def __cmd_feature(self):
if attached != True:
print(set_error('Disallowed: node is not attached'))
return
# create an empty element object to
glo_element = Element(bus, 0x02)
opcode = 0x8008 # Configuration Data Get opcode
page = 0
data = bytearray(struct.pack('<HB', opcode, page))
# send message to read Composition Data, net_idx = 0 (default)
node.DevKeySend(glo_element.get_path(), dst_addr, False, net_idx, data,
reply_handler=generic_reply_cb,
error_handler=generic_error_cb)
class Element(dbus.service.Object):
...
# If successful, this function should be executed
@dbus.service.method(MESH_ELEMENT_IFACE, in_signature="qbqay", out_signature="")
def DevKeyMessageReceived(self, source, remote, net_idx, data):
print('Received data:')
print(source)
print(remote)
print(net_idx)
print(data)
... the rest of code is similar to 'test-mesh' example
I also created some commands and a node menu for configuration like in the example to test. Here is my app console:
pi@raspberrypi:~/Desktop/test $ python btmesh_provisioner.py b3fc4cd44cb2fcec
Register OnOff Server model on element 0
OnOff Server
State is OFF
Register Vendor model on element 0
Register OnOff Client model on element 1
OnOff Client
*** MAIN MENU ***
token - set node ID (token)
create - create mesh network
appkey-index - set AppKey index
appkey-new - create appkey
scan-start - scan for near unprovisioned devs
scan-cancel - cancel scanning
element-index - set Element index
add - add device to mesh network
join - join mesh network
attach - attach mesh node
remove - delete node
dest - set destination address
uuid - set remote uuid
vendor-send - send raw vendor message
config-menu - Node Configuration menu
client-menu - On/Off client menu
help - show list command
quit - exit the test
attach
Attach mesh node to bluetooth-meshd daemon
Mesh app registered: /org/bluez/mesh/node0a0102030405060708090a0b0c0d0e0f
scan-start
Scanning...
Scan procedure started
ScanResult RSSI -69 dddd08a6f7a05fde0000000000000000000000000000
uuid
Enter 32-digit hex remote UUID:
dddd08a6f7a05fde0000000000000000
add
Adding dev UUID dddd08a6f7a05fde0000000000000000
AddNode procedure started
RequestProvData for Ele_Cnt 3
AddNodeComplete of node 02a6 uuid dddd08a6f7a05fde0000000000000000
dest
Enter 4-digit hex destination address:
02a6
Destination address: 02a6
config-menu
*** ON/OFF CLIENT MENU ***
appkey-add - add AppKey index in network
element-props - get Element properites
feature - show node feature
back - back to main menu
quit - exit the test
feature
feature
(Nothing happened, end)
Log of bluetooth-meshd (when trying to execute __cmd_feature):
mesh/node.c:dev_key_send_call() DevKeySend
mesh/model.c:msg_send() (7fff) 0x1d42618
mesh/model.c:msg_send() net_idx 0
mesh/model.c:mesh_model_rx() iv_index 00000000 key_aid = 00
mesh/net.c:send_seg() segN 0 segment 0 seg_off 0
mesh/util.c:print_packet() 48717.451 Clr-Net Tx: 007f000005000102a6007285cbd97716d600000000
TX: Network 0001 -> 02a6 : 053920934cd6cecf313a42ebb7bc7db15c3d0d5488 (21) : TTL 127 : SEQ 000005
mesh/util.c:print_packet() 48717.452 RX: Network [enc] :: 053920934cd6cecf313a42ebb7bc7db15c3d0d5488
mesh/util.c:print_packet() 48717.452 RX: Network [clr] :: 057f000005000102a6007285cbd97716d6
Expected result (when I tested with mesh-cfgclient):
[config: Target = 00aa]# composition-get
Received dev key message (len 32):[config:
Received DeviceCompositionStatus (len 31)
Received composion:
Feature support:
relay: yes
proxy: yes
friend: no
lpn: no
Element 0:
location: 0000
SIG defined models:
Model ID 0000
Model ID 1000
Element 1:
location: 0000
SIG defined models:
Model ID 1000
Element 2:
location: 0000
SIG defined models:
Model ID 1000
Upvotes: 0
Views: 35