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.

Parents
  • Hi,

     

    Do you want to let the light switch model runs autonomously on the serial node or you want to let the model run on the peer device (e.g PC) and the serial still act a just connectivity chip ? 

    If you want to let the model run on the peer device, we already do that in this guide, look for "blinking LEDs"

    But you can add a model in the serial code as well, shouldn't have any problem. 

  • I want to run the client model on the serial node or rather I want to integrate the seril communication abilities  into the client model of the mesh  light switch example. For that :
    in mesh_init(void) I added : nrf_mesh_serial_init(NULL);   
    in the start() I added : nrf_mesh_serial_enable();

    And I added all necessery files for serial communication from the mesh into the Light Switch Client Model to activate the serial communication, but  if I try to send some messages  from Server to Client the application does not work proper and after some "button messages" it seems that the Client Model application crashes.

    My aim is to build a mesh with several servers and client and one node with the serial communication abilities. All nodes should have all the necessary keys. And in the end i want to receive with this serial node all the mesh messages and send them to the host pc


    the problem is:

    1) i dont know how add the same keys to all devices by the "hand"

    2) i dont know how to receive the mesh messages with the serial node or rather i dont know how to implement the receive funktion in serial node (is it implemented allready ?)

     3) I can not use interactive.py script to send comands to the serial device, I can just receive events from serial device. Because of this unsolved problem : devzone.nordicsemi.com/.../mesh-serial-example-problem-timeout-waiting-for-event

    That's why i tried to use the Light-Switch Example and to activate the Serial Communication by the Client. Because in this example I have one provisioner and all nodes get the keys.

  • 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

  • Hi,

     

    Could you post the full log of Provisioner and provisionee ? I assume you should have separate python windows to control them. 

    Make sure you declare the simple on of server on the provisionee as well (This I believe has not been implemented in our python code, you need to implement one). 

  • Ok, ill try to implement the SimpleOnOffServer. Can you say me why do I need this ? I dont see the full puzzle

Reply Children
No Data
Related