This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

include Mesh Serial device into the Light Switch Mesh

Hello, I want to include Mesh Serial Example into the Mesh Light Switch example.

The aim is to allow the serial device to listen to the mesh messages.

What is the best way to do this ? Do i need to write a new Model ?

My idea was just to extend the Client Model by the Serial features but I'm not sure if it will work and before i spend a lot of time on it i better ask.

  • after provisioning of the light switch server+serial_enable and light switch client with the pyACI script,

    I connect to the server serial and can see this if I press the button on the client site:

    {event: MeshMessageReceivedUnicast, data: {'src': 18, 'dst': 16, 'appkey_handle': 0, 'subnet_handle': 0, 'ttl': 1, 'adv_addr_type': 1, 'adv_addr': bytearray(b'\x16\xfc\xb4\xb0\xd7\xea'), 'rssi': -30, 'actual_length': 5, 'data': bytearray(b'\xc1\x00Y\x00\x13')}}

    the problem is in this code line.

    element_index = event._data["dst"] - self.elements[0].address
    assert(element_index < len(self.elements) and element_index >= 0)

    the element_index=15 in this case but the number of the elements is 1 in this case.

  • Hi,

     It's just an update. We found a bug in the python code that we didn't update the element addresses database. 

    You can just add this code: 

          for i, e in enumerate(self.iaci.access.elements):

                    e.address = event._data["address"] + i

    At the end of Provisionee() in provisioning.py right before "else:"
    This will update the iaci database of the address.

    Please let us know if this workaround works. 

  • Hey, no did not work

    2018-07-26 14:18:50,659 - ERROR - COM11: Exception in pkt handler <bound method Access.__event_handler of <mesh.access.Access object at 0x03AC64F0>>
    2018-07-26 14:18:50,661 - ERROR - COM11: traceback: Traceback (most recent call last):
      File "C:\Users\Lab\nRF\mesh_2.1.1\scripts\interactive_pyaci\aci\aci_uart.py", line 94, in process_packet
        fun(packet)
      File "C:\Users\Lab\nRF\mesh_2.1.1\scripts\interactive_pyaci\mesh\access.py", line 209, in __event_handler
        assert(element_index < len(self.elements) and element_index >= 0)
    AssertionError

    I want to point this out to you: I use two pyACI instances one instance i run with the pure serial device to provide the provisioning process for server with serial feature enable and client. After the provisioning i use another instance of pyACI and connect to the another port to the server with serial feature enable and try to get messages send to this server.

    But this fixed partly another problem I had: to communicate from Several Clients to one Server

    devzone.nordicsemi.com/.../interactive-mesh-provisioning-and-configuration-provisioning-several-clients-problem

  • This customer has almost the same set up like your and with the fix it worked for him. Could you have a look here

    Note that you need to start the provisionee() in python on the PC when you do provisioning of the node, so that the python app can update the address of the node. 

  • What I did is fallow: i ues the pure serial device as Provisioner on COM10 and use the Server Device with serial enable on COM11 as Provisionee, start the Provisionee(device) and start to listen.

    the provisioning process works but after that i get no response from the device and I can not control anything.

    In [1]: db = MeshDB("database/example_database.json")

    In [2]: p = Provisioner(d[0], db)
    add packet recipient
    <bound method Provisioner.__event_handler of <mesh.provisioning.Provisioner object at 0x04

    In [3]: 2018-07-27 10:36:15,036 - INFO - COM10: Success
    2018-07-27 10:36:15,038 - INFO - COM10: Success
    2018-07-27 10:36:15,042 - INFO - COM10: SubnetAdd: {'subnet_handle': 0}
    2018-07-27 10:36:15,046 - INFO - COM10: AppkeyAdd: {'appkey_handle': 0}
    2018-07-27 10:36:15,050 - INFO - COM10: AppkeyAdd: {'appkey_handle': 1}



    In [4]: pe=Provisionee(d[1])
    add packet recipient
    <bound method Provisionee.__event_handler of <mesh.provisioning.Provisionee object at 0x04

    2018-07-27 10:36:50,910 - INFO - COM11: Success
                                                           2018-07-27 10:36:50,920 - INFO - CO
    In [5]: pe.listen()

    2018-07-27 10:37:04,388 - INFO - COM11: SuccessIn
    In [6]: p.scan_start()

    2018-07-27 10:37:12,056 - INFO - COM10: SuccessIn
     [7]:   2018-07-27 10:37:13,242 - INFO - COM10: Received UUID 0059ffff00000000c4e0725be36e
    In [7]: p.scan_stop()

    I2018-07-27 10:37:32,578 - INFO - COM10: Successn
    In [8]: p.provision(name="Light bulb")

    In [2018-07-27 10:37:40,290 - INFO - COM10: Provision: {'context': 0}9
    ]:      2018-07-27 10:37:40,303 - INFO - COM11: Link established
    2018-07-27 10:37:40,318 - INFO - COM10: Link established
    2018-07-27 10:37:40,372 - INFO - COM10: Received capabilities
    2018-07-27 10:37:40,374 - INFO - COM10: Number of elements: 1
    2018-07-27 10:37:40,378 - INFO - COM10: OobUse: {'context': 0}
    2018-07-27 10:37:40,571 - INFO - COM10: ECDH request received
    2018-07-27 10:37:40,581 - INFO - COM10: EcdhSecret: {'context': 0}
    2018-07-27 10:37:40,959 - INFO - COM10: Provisioning complete
    2018-07-27 10:37:40,962 - INFO - COM10:         Address(es): 0x10-0x10
    2018-07-27 10:37:40,964 - INFO - COM10:         Device key: c58ef2bd05d6876e372d719eac1972
    2018-07-27 10:37:40,967 - INFO - COM10:         Network key: 18eed9c2a56add85049ffc3c59ad0
    2018-07-27 10:37:40,969 - INFO - COM10: Adding device key to subnet 0
    2018-07-27 10:37:40,972 - INFO - COM10: Adding publication address of root element
    2018-07-27 10:37:40,984 - INFO - COM10: DevkeyAdd: {'devkey_handle': 8}
    2018-07-27 10:37:40,989 - INFO - COM10: AddrPublicationAdd: {'address_handle': 0}
    2018-07-27 10:37:40,992 - INFO - COM11: Provisioning complete
    2018-07-27 10:37:40,993 - INFO - COM11:         Address(es): 0x10-0x10
    2018-07-27 10:37:40,994 - INFO - COM11:         Device key: c58ef2bd05d6876e372d719eac1972
    2018-07-27 10:37:40,995 - INFO - COM11:         Network key: 18eed9c2a56add85049ffc3c59ad0
    2018-07-27 10:37:40,996 - INFO - COM11: Adding network key (subnet)
    2018-07-27 10:37:40,997 - INFO - COM11: Adding device key to subnet 0
    2018-07-27 10:37:40,998 - INFO - COM11: Setting the local unicast address range
    2018-07-27 10:37:41,003 - INFO - COM11: SubnetAdd: {'subnet_handle': 0}
    2018-07-27 10:37:41,005 - INFO - COM11: Provisioning link closed
    2018-07-27 10:37:41,007 - INFO - COM11: DevkeyAdd: {'devkey_handle': 1}
    2018-07-27 10:37:41,008 - INFO - COM11: Success
    2018-07-27 10:37:41,079 - INFO - COM10: Provisioning link closed
    In [9]: cc = ConfigurationClient(db)

    In [10]: d[0].model_add(cc)

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

    In [12]: cc.composition_data_get()

    2018-07-27 10:38:38,336 - INFO - COM10: SuccessIn
    In [13]: cc.appkey_add(0)

    In 2018-07-27 10:38:52,380 - INFO - COM10: Success[
    In [14]: cc.model_app_bind(db.nodes[0].unicast_address, 0, mt.ModelId(0, 0x59))

    2018-07-27 10:39:03,965 - INFO - COM10: Success
    In [15]: sc = SimpleOnOffClient()

    In [16]: d[0].model_add(sc)

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

    In [18]: sc.set(True)

    2018-07-27 10:39:44,809 - INFO - COM10: SuccessI

Related