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

Configuring a Vendor Model to work with Serial Example

Hardware: 

  • Raspberry Pi Zero W
  • nRF52840 DK running Serial Example and connected to RPi via USB
  • Custom nRF52840 board acting as a Vendor Model Server

Software:

  • nRF SDK for Mesh v5.0.0

I'm trying to implement a vendor model that is a modified SimpleOnOff Server instance on my custom board. I've set up the opcodes and added it to the element using the guide for SimpleOnOff model. I am able to provision and bind an appkey using the interactive_pyaci guide for provisioning and configuration. However, when I get to this step:

In  [16]: gc.set(True)
2020-03-24 14:51:37,274 - INFO - COM27: PacketSend: {'token': 4}
2020-03-24 14:51:37,303 - INFO - COM27: {event: MeshTxComplete, data: {'token': 4}}
2020-03-24 14:51:37,329 - INFO - COM27.GenericOnOffClient: Present OnOff: on

I do not receive my model's equivalent of the status message from the GenericOnOff example ie. the last line of this snippet. I've already created a python script mirroring generic_on_off.py's implementation:

SET_LIGHT_TEST = Opcode(0xc1, manufacturer_id, "Light Functional Test")
STATUS_GET = Opcode(0xc2, manufacturer_id, "Status Request")
STATUS = Opcode(0xc4, manufacturer_id, "Light Status")
TEST_RESULT = Opcode(0xc5, manufacturer_id, "Light Test RESULT")

 def __init__(self):
        self.opcodes = [
            (self.STATUS, self.__light_status_handler),
            (self.TEST_RESULT, self.__light_test_result_handler)
        ]
    .....
    
 def set(self, state):
        message = bytearray()
        #message += struct.pack("<BB", int(state), self._tid)
        message += struct.pack("<BIHI", 1, 0, 0, 0)
        self.send(self.SET_LIGHT_TEST, message)
    
 def ___light_status_handler(self, opcode, message):
        on_off = "on" if message.data[0] > 0 else "off"
        self.logger.info("Present value is %s", on_off)

    def ___light_test_result_handler(self, opcode, message):
        ack_type, code = struct.unpack("<BL", message)
        self.logger.info("Acknowledgement type: %d, code: %d", ack_type, code)
 

I should get both a status message and a test result message when I call the set method. I do see the message go to my custom board, and it executes the light test successfully. On RTT I was able to find that both access_model_publish() and access_model_reply() returned NRF_INVALID_PARAM. My opcodes are valid so I believe that the model is not being bound to the appkey for some reason. 

Perhaps I need to do something specific with the Configuration Client on interactive_pyaci?

  • Arif@Lynxemi said:
    How then do I set the publication address for access_model_publish to work? I suppose I would have to get the publication address of the serial device running interactive_pyaci and use these two commands?

    Yes, you can set the publication address using the two lines you mentioned.

  • Thank you very much Mttrinh, I am able to send multiple messages now. I have another question about how to set up groups and send messages to them using serial. I will make another ticket for that one. Cheers.

  • Hi,

    Can anyone suggest me that why i am getting "Invalid model" while I am binding  "Vendor Model".

    Here is the composition data received from the device when i am requesting it.

    In [10]: cc.composition_data_get()
    bytearray(b'\x08\x00\x01\x00\x00\x00\x08\x00\x00\x00\x80\x08\x00') 171
    
    In [11]: 2022-08-25 09:03:28,160 - INFO - ttyACM13: PacketSend: {'token': 1}
    2022-08-25 09:03:28,182 - INFO - ttyACM13: {event: MeshTxComplete, data: {'token': 1}}
    2022-08-25 09:03:28,471 - INFO - ttyACM13.ConfigurationClient: Received composition data (page 0x00): {
      "cid": "0059",
      "pid": "0000",
      "vid": "0000",
      "crpl": 40,
      "features": {
        "relay": 0,
        "proxy": 0,
        "friend": 2,
        "low_power": 2
      },
      "elements": [
        {
          "index": 0,
          "location": "0000",
          "models": [
            {
              "modelId": "0000"
            },
            {
              "modelId": "0002"
            },
            {
              "modelId": "1004"
            },
            {
              "modelId": "1000"
            },
            {
              "modelId": "1006"
            },
            {
              "modelId": "1007"
            },
            {
              "modelId": "1002"
            },
            {
              "modelId": "1300"
            },
            {
              "modelId": "1301"
            },
            {
              "modelId": "1303"
            },
            {
              "modelId": "1304"
            },
            {
              "modelId": "1203"
            },
            {
              "modelId": "1204"
            }
          ]
        },
        {
          "index": 1,
          "location": "0000",
          "models": [
            {
              "modelId": "1002"
            },
            {
              "modelId": "1306"
            }
          ]
        },
        {
          "index": 2,
          "location": "0000",
          "models": [
            {
              "modelId": "1000"
            },
            {
              "modelId": "130f"
            },
            {
              "modelId": "1310"
            }
          ]
        },
        {
          "index": 3,
          "location": "0000",
          "models": [
            {
              "modelId": "00590001"
            }
          ]
        },
        {
          "index": 4,
          "location": "0000",
          "models": [
            {
              "modelId": "00590002"
            }
          ]
        }
      ]
    }
    
    

  • I also tried the exact method as you did to bind the vendor model but I am getting Invalid model during binding

Related