Get Composition Data of new provisioned node using D-Bus Python Bluez Mesh API

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

New contributor

Quang Anh Trần is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Get Composition Data of new provisioned node using D-Bus Python Bluez Mesh API

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

New contributor

Quang Anh Trần is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật