Provisioning and Controlling Two Dongles, which run Mesh Light Switch Server example using Mesh Serial Example

I have

nRf52840 DK - 1 - Mesh Serail example
nRF52840 Dongle - 2 - Mesh Light Switch Server example.

I used the steps given in the infocenter to provision and configure Dongles using Mesh Serial Example , using DK.I almost get
similar outputs given in the infocenter for provisioning and connecting One Dongle which rum Server example and later another Dongle
which run Client example.

But , when I try to control the two Dongles which rum Server examples , using DK which rum Mesh Serail example , I get error as INVALID ADDRESS
when try to bind second node to the DK .The code is given as follows:

C:\Nordic_Semi\nrf5sdkformeshv500src\scripts\interactive_pyaci>python interactive_pyaci.py -d COM13 --no-logfile
C:\Nordic_Semi\nrf5sdkformeshv500src\scripts\interactive_pyaci\mesh\provisioning.py:31: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
  from cryptography.hazmat.primitives.asymmetric import ec

    To control your device, use d[x], where x is the device index.
    Devices are indexed based on the order of the COM ports specified by the -d option.
    The first device, d[0], can also be accessed using device.

    Type d[x]. and hit tab to see the available methods.

2022-06-10 14:52:01,993 - ERROR - COM13: Invalid packet: bytearray(b'\x00')
2022-06-10 14:52:01,996 - ERROR - COM13: Invalid packet: bytearray(b'\x00')
2022-06-10 14:52:01,997 - ERROR - COM13: Invalid packet: bytearray(b'\x00')
2022-06-10 14:52:01,999 - INFO - COM13: {event: MeshSeqnumEntrySetNotification, data: {'next_block': 8192}}
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: send(cmd.Echo("123"))

2022-06-10 14:52:04,043 - INFO - COM13: {event: DeviceEchoRsp, data: {'data': '123'}}
In [2]: db = MeshDB("database/example_database.json")

In [3]: db.provisioners
Out[3]: [{'allocated_group_range': [{'high_address': feff, 'low_address': c000}], 'name': 'BT Mesh Provisioner', 'UUID': bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), 'allocated_unicast_range': [{'high_address': 7fff, 'low_address': 0010}]}]

In [4]: p = Provisioner(device, db)

In [5]: 2022-06-10 14:53:27,631 - INFO - COM13: Success
2022-06-10 14:53:27,634 - INFO - COM13: Success
2022-06-10 14:53:27,638 - INFO - COM13: SubnetAdd: {'subnet_handle': 0}
2022-06-10 14:53:27,639 - INFO - COM13: AppkeyAdd: {'appkey_handle': 0}
2022-06-10 14:53:27,643 - INFO - COM13: AppkeyAdd: {'appkey_handle': 1}
In [5]: p.scan_start()

In [6]: 2022-06-10 14:53:37,600 - INFO - COM13: Success
2022-06-10 14:53:40,568 - INFO - COM13: Received UUID 837f06b893b741e2855476a742d516cd with RSSI: -34 dB
In [6]: p.scan_stop()

In [7]: 2022-06-10 14:53:57,664 - INFO - COM13: Success
In [7]: p.provision(name="Light bulb 1")

In [8]: 2022-06-10 14:54:16,267 - INFO - COM13: Provision: {'context': 0}
2022-06-10 14:54:16,320 - INFO - COM13: Link established
2022-06-10 14:54:16,375 - INFO - COM13: Received capabilities
2022-06-10 14:54:16,377 - INFO - COM13: Number of elements: 1
2022-06-10 14:54:16,382 - INFO - COM13: OobUse: {'context': 0}
2022-06-10 14:54:18,709 - INFO - COM13: ECDH request received
2022-06-10 14:54:18,721 - INFO - COM13: EcdhSecret: {'context': 0}
2022-06-10 14:54:21,161 - INFO - COM13: Provisioning complete
2022-06-10 14:54:21,164 - INFO - COM13:         Address(es): 0x10-0x10
2022-06-10 14:54:21,168 - INFO - COM13:         Device key: de8827e7ad09ca9c92a2ddab51bba209
2022-06-10 14:54:21,170 - INFO - COM13:         Network key: 18eed9c2a56add85049ffc3c59ad0e12
2022-06-10 14:54:21,173 - INFO - COM13: Adding device key to subnet 0
2022-06-10 14:54:21,177 - INFO - COM13: Adding publication address of root element
2022-06-10 14:54:21,189 - INFO - COM13: DevkeyAdd: {'devkey_handle': 8}
2022-06-10 14:54:21,195 - INFO - COM13: AddrPublicationAdd: {'address_handle': 0}
2022-06-10 14:54:21,345 - INFO - COM13: Provisioning link closed
In [8]: cc = ConfigurationClient(db)
   ...:

In [9]: device.model_add(cc)

In [10]: cc.publish_set(8, 0)

In [11]: cc.composition_data_get()

In [12]: 2022-06-10 14:55:21,921 - INFO - COM13: PacketSend: {'token': 1}
2022-06-10 14:55:21,938 - INFO - COM13: {event: MeshTxComplete, data: {'token': 1}}
2022-06-10 14:55:22,028 - INFO - COM13.ConfigurationClient: Received composition data (page 0x00): {
  "cid": "0059",
  "elements": [
    {
      "models": [
        {
          "modelId": "0000"
        },
        {
          "modelId": "0002"
        },
        {
          "modelId": "1000"
        },
        {
          "modelId": "1004"
        },
        {
          "modelId": "1203"
        },
        {
          "modelId": "1204"
        }
      ],
      "index": 0,
      "location": "0000"
    }
  ],
  "pid": "0000",
  "vid": "0000",
  "features": {
    "low_power": 2,
    "friend": 0,
    "relay": 0,
    "proxy": 0
  },
  "crpl": 40
}
In [12]: cc.appkey_add(0)

In [13]: 2022-06-10 14:55:41,396 - INFO - COM13: PacketSend: {'token': 2}
2022-06-10 14:55:41,494 - INFO - COM13.ConfigurationClient: Appkey status: AccessStatus.SUCCESS
2022-06-10 14:55:41,513 - INFO - COM13.ConfigurationClient: Appkey add 0 succeded for subnet 0 at node 0010
2022-06-10 14:55:43,249 - INFO - COM13: {event: MeshTxComplete, data: {'token': 2}}
In [13]: cc.model_app_bind(db.nodes[0].unicast_address, 0, mt.ModelId(0x1000))

In [14]: 2022-06-10 14:55:55,563 - INFO - COM13: PacketSend: {'token': 3}
2022-06-10 14:55:55,583 - INFO - COM13: {event: MeshTxComplete, data: {'token': 3}}
In [14]: cc.model_app_bind(db.nodes[0].unicast_address, 0, mt.ModelId(0x1000))

In [15]: 2022-06-10 14:56:00,292 - INFO - COM13: PacketSend: {'token': 4}
2022-06-10 14:56:00,310 - INFO - COM13: {event: MeshTxComplete, data: {'token': 4}}
2022-06-10 14:56:00,348 - INFO - COM13.ConfigurationClient: Model app bind status: AccessStatus.SUCCESS
2022-06-10 14:56:00,358 - INFO - COM13.ConfigurationClient: Appkey bind 0 to model 1000 at 0010
In [15]: gc1 = GenericOnOffClient()

In [16]: device.model_add(gc1)

In [17]: gc1.publish_set(0, 0)

In [18]: gc1.set(True)

In [19]: 2022-06-10 14:56:58,525 - INFO - COM13: PacketSend: {'token': 5}
2022-06-10 14:56:58,542 - INFO - COM13: {event: MeshTxComplete, data: {'token': 5}}
2022-06-10 14:56:58,566 - INFO - COM13.GenericOnOffClient: Present OnOff: on
In [19]: gc1.set(False)

In [20]: 2022-06-10 14:57:08,983 - INFO - COM13: PacketSend: {'token': 6}
2022-06-10 14:57:08,997 - INFO - COM13: {event: MeshTxComplete, data: {'token': 6}}
2022-06-10 14:57:09,029 - INFO - COM13.GenericOnOffClient: off
In [20]: gc1.set(True)

In [21]: 2022-06-10 14:57:59,123 - INFO - COM13: PacketSend: {'token': 7}
2022-06-10 14:57:59,146 - INFO - COM13: {event: MeshTxComplete, data: {'token': 7}}
2022-06-10 14:57:59,180 - INFO - COM13.GenericOnOffClient: Present OnOff: on
In [21]: gc1.set(False)

In [22]: 2022-06-10 14:58:01,383 - INFO - COM13: PacketSend: {'token': 8}
2022-06-10 14:58:01,404 - INFO - COM13: {event: MeshTxComplete, data: {'token': 8}}
2022-06-10 14:58:01,436 - INFO - COM13.GenericOnOffClient: off
In [22]: gc1.set(True)

In [23]: 2022-06-10 14:58:03,101 - INFO - COM13: PacketSend: {'token': 9}
2022-06-10 14:58:03,121 - INFO - COM13: {event: MeshTxComplete, data: {'token': 9}}
2022-06-10 14:58:03,148 - INFO - COM13.GenericOnOffClient: Present OnOff: on
In [23]: gc1.set(False)

In [24]: 2022-06-10 14:58:04,780 - INFO - COM13: PacketSend: {'token': 10}
2022-06-10 14:58:04,802 - INFO - COM13: {event: MeshTxComplete, data: {'token': 10}}
2022-06-10 14:58:04,834 - INFO - COM13.GenericOnOffClient: off
In [24]: p.scan_start()

2022-06-10 14:58:23,588 - INFO - COM13: Success
In [25]: 2022-06-10 14:58:23,918 - INFO - COM13: Received UUID 6e3b906982b9462ab2a3f84e282b43b6 with RSSI: -28 dB
In [25]: p.scan_stop()

In [26]: 2022-06-10 14:58:28,935 - INFO - COM13: Success
In [26]: p.provision(name="Light Bulb 2")

In [27]: 2022-06-10 14:58:55,745 - INFO - COM13: Provision: {'context': 0}
2022-06-10 14:58:55,803 - INFO - COM13: Link established
2022-06-10 14:58:55,888 - INFO - COM13: Received capabilities
2022-06-10 14:58:55,891 - INFO - COM13: Number of elements: 1
2022-06-10 14:58:55,898 - INFO - COM13: OobUse: {'context': 0}
2022-06-10 14:58:58,205 - INFO - COM13: ECDH request received
2022-06-10 14:58:58,218 - INFO - COM13: EcdhSecret: {'context': 0}
2022-06-10 14:58:58,644 - INFO - COM13: Provisioning complete
2022-06-10 14:58:58,647 - INFO - COM13:         Address(es): 0x11-0x11
2022-06-10 14:58:58,651 - INFO - COM13:         Device key: 50327bc9916b6f17c12cb9865aa6bf41
2022-06-10 14:58:58,655 - INFO - COM13:         Network key: 18eed9c2a56add85049ffc3c59ad0e12
2022-06-10 14:58:58,658 - INFO - COM13: Adding device key to subnet 0
2022-06-10 14:58:58,662 - INFO - COM13: Adding publication address of root element
2022-06-10 14:58:58,678 - INFO - COM13: DevkeyAdd: {'devkey_handle': 9}
2022-06-10 14:58:58,682 - INFO - COM13: AddrPublicationAdd: {'address_handle': 1}
2022-06-10 14:58:58,798 - INFO - COM13: Provisioning link closed
In [27]: bb=ConfigurationClient(db)

In [28]: device.model_add(bb)

In [29]: bb.publish_set(9,1)

In [30]: bb.composition_data_get()

In [31]: 2022-06-10 15:01:07,228 - INFO - COM13: PacketSend: {'token': 11}
2022-06-10 15:01:07,245 - INFO - COM13: {event: MeshTxComplete, data: {'token': 11}}
2022-06-10 15:01:07,365 - INFO - COM13.ConfigurationClient: Received composition data (page 0x00): {
  "cid": "0059",
  "elements": [
    {
      "models": [
        {
          "modelId": "0000"
        },
        {
          "modelId": "0002"
        },
        {
          "modelId": "1000"
        },
        {
          "modelId": "1004"
        },
        {
          "modelId": "1203"
        },
        {
          "modelId": "1204"
        }
      ],
      "index": 0,
      "location": "0000"
    }
  ],
  "pid": "0000",
  "vid": "0000",
  "features": {
    "low_power": 2,
    "friend": 0,
    "relay": 0,
    "proxy": 0
  },
  "crpl": 40
}
2022-06-10 15:01:07,388 - INFO - COM13.ConfigurationClient: Received composition data (page 0x00): {
  "cid": "0059",
  "elements": [
    {
      "models": [
        {
          "modelId": "0000"
        },
        {
          "modelId": "0002"
        },
        {
          "modelId": "1000"
        },
        {
          "modelId": "1004"
        },
        {
          "modelId": "1203"
        },
        {
          "modelId": "1204"
        }
      ],
      "index": 0,
      "location": "0000"
    }
  ],
  "pid": "0000",
  "vid": "0000",
  "features": {
    "low_power": 2,
    "friend": 0,
    "relay": 0,
    "proxy": 0
  },
  "crpl": 40
}
In [31]: bb.appkey_add(0)

In [32]: 2022-06-10 15:02:05,994 - INFO - COM13: PacketSend: {'token': 12}
2022-06-10 15:02:06,065 - INFO - COM13: {event: MeshTxComplete, data: {'token': 12}}
2022-06-10 15:02:06,094 - INFO - COM13.ConfigurationClient: Appkey status: AccessStatus.SUCCESS
2022-06-10 15:02:06,106 - INFO - COM13.ConfigurationClient: Appkey bind 0 succeded for subnet 0 at node 0011
2022-06-10 15:02:06,114 - INFO - COM13.ConfigurationClient: Appkey status: AccessStatus.SUCCESS
2022-06-10 15:02:06,133 - INFO - COM13.ConfigurationClient: Appkey add 0 succeded for subnet 0 at node 0011
In [32]: bb.model_app_bind(db.nodes[1].unicast_address + 1, 0, mt.ModelId(0x1000))

2022-06-10 15:03:49,251 - INFO - COM13: PacketSend: {'token': 13}
In [33]: 2022-06-10 15:03:49,273 - INFO - COM13: {event: MeshTxComplete, data: {'token': 13}}
2022-06-10 15:03:49,302 - INFO - COM13.ConfigurationClient: Model app bind status: AccessStatus.INVALID_ADDRESS
2022-06-10 15:03:49,305 - INFO - COM13.ConfigurationClient: Model app bind status: AccessStatus.INVALID_ADDRESS
In [33]: bb.model_app_bind(db.nodes[1].unicast_address + 1, 0, mt.ModelId(0x1000))

In [34]: 2022-06-10 15:04:01,448 - INFO - COM13: PacketSend: {'token': 14}
2022-06-10 15:04:01,472 - INFO - COM13: {event: MeshTxComplete, data: {'token': 14}}
In [34]: bb.model_app_bind(db.nodes[1].unicast_address + 1, 0, mt.ModelId(0x1000))

In [35]: 2022-06-10 15:04:05,134 - INFO - COM13: PacketSend: {'token': 15}
2022-06-10 15:04:05,157 - INFO - COM13: {event: MeshTxComplete, data: {'token': 15}}
2022-06-10 15:04:05,187 - INFO - COM13.ConfigurationClient: Model app bind status: AccessStatus.INVALID_ADDRESS
2022-06-10 15:04:05,192 - INFO - COM13.ConfigurationClient: Model app bind status: AccessStatus.INVALID_ADDRESS


My ultimate goal is to send different messages to different Dongles from DK using Mesh Serial example .There is no clear documentation
for using PyACI .Please provide me steps to do the required things.

Thankyou .

-Vicky

  • Hi,

    I have looked further into the PyACI. Based on the descriptions of your setup, this is what seems to be the issues:

    When you use db.nodes[0].unicast_address, this is the unicast_address registered in the database file for node 0. This may or may not be the case (it is hard to tell from the log, but you can check the database file at <mesh SDK folder>/scripts/interactive_pyaci/database/example_database.json in order to figure out). This is most likely OK as is, but checking the json database file does not hurt. Alternatively, you should be able to use the unicast address manually.

    When configuring the (local, PyACI side) Generic On Off Client, setting the publish address, you should set app key handle 0 and the address handle for the node. It is such: "publish_set(<appkey_handle>, <address_handle>)" For your example, where you use the app key with index 0 for both nodes, it should be "gc1.publish_set(0, 0)" and "gc2.publish_set(0, 1)".

    Finally I must correct a previous statement, in that it actually is the unicast address of the element that should be used as address argument to model_app_bind(), since the addressing of the message itself is handled by the previous publish_set() on the configuration client. For your example, though, with two nodes having one element each, using the unicast address of the node (as you corrected your code to) is correct. Adding to the primary unicast address is only correct when there are multiple elements on the node.

    Regards,
    Terje

Related