Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

In Mesh SDK 2.0.1 interactive_pyaci example database read error - unexpected keyword argument 'interval'

Hi Folks,

             I'm having trouble running the demo second time followed the steps mentioned  http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v2.0.1%2Fmd_scripts_interactive_pyaci_doc_demo_configuration.html&cp=4_1_0_2_0_2

I have below setup,

Hardware Setup:

1. nRF52832-DK1 Programmed with serial_nrf52832_xxAA_s132_6_0_0.emProject

2. nRF52832-DK2 Programmed with light_switch_server_nrf52832_xxAA_s132_6_0_0.emProject

3. nRF52832-DK3 Programmed with light_switch_client_nrf52832_xxAA_s132_6_0_0.emProject

I followed the steps mentioned for demo project. The very first time nodes were successfully provisioned and able to get the demo working and stopped the interactive_pyaci (exit()). When i start the second time and  started the interactive_pyaci again  and entered the following command to read the database, while reading the database i'm getting following errors command:  db = MeshDB("database/mesh_database.json")

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci>python interactive_pyaci.py -d COM8 --no-logfile

    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.

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: db = MeshDB("database/mesh_database.json")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\interactive_pyaci.py in <module>()
----> 1 db = MeshDB("database/mesh_database.json")

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\database.py in __init__(self, path)
     67         self.iv_index = 0
     68         self.iv_update = 0
---> 69         self.load()
     70
     71     @property

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\database.py in load(self, path)
     86         self.provisioners = [mt.Provisioner(**p) for p in data["provisioners"]]
     87         if "nodes" in data:
---> 88             self.nodes = [mt.Node(**n) for n in data["nodes"]]
     89         if "groups" in data:
     90             self.groups = [mt.Group(**g) for g in data["groups"]]

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\database.py in <listcomp>(.0)
     86         self.provisioners = [mt.Provisioner(**p) for p in data["provisioners"]]
     87         if "nodes" in data:
---> 88             self.nodes = [mt.Node(**n) for n in data["nodes"]]
     89         if "groups" in data:
     90             self.groups = [mt.Group(**g) for g in data["groups"]]

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in __init__(self, UUID, device_key, unicast_address, net_keys, config_complete, security, name, cid, vid, pid, crpl, network_transmit, relay_retransmit, features, elements, app_keys, secure_network_beacon, default_TTL)
    645         self.crpl = unpack(Identifier, crpl)
    646         self.features = unpack(NodeFeatures, features)
--> 647         self.elements = [unpack(Element, e) for e in elements]
    648         self.app_keys = [KeyIndex(index) for index in app_keys]
    649         self.secure_network_beacon = secure_network_beacon

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in <listcomp>(.0)
    645         self.crpl = unpack(Identifier, crpl)
    646         self.features = unpack(NodeFeatures, features)
--> 647         self.elements = [unpack(Element, e) for e in elements]
    648         self.app_keys = [KeyIndex(index) for index in app_keys]
    649         self.secure_network_beacon = secure_network_beacon

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in unpack(cls, obj)
     72         return cls(*obj)
     73     elif isinstance(obj, dict):
---> 74         return cls(**obj)
     75     else:
     76         return cls(obj)

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in __init__(self, index, location, models, unicast_address, name)
    602         self.index = index
    603         self.location = Identifier(location)
--> 604         self.models = [unpack(Model, m) for m in models]
    605         if unicast_address:
    606             self.unicast_address = UnicastAddress(unicast_address)

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in <listcomp>(.0)
    602         self.index = index
    603         self.location = Identifier(location)
--> 604         self.models = [unpack(Model, m) for m in models]
    605         if unicast_address:
    606             self.unicast_address = UnicastAddress(unicast_address)

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in unpack(cls, obj)
     72         return cls(*obj)
     73     elif isinstance(obj, dict):
---> 74         return cls(**obj)
     75     else:
     76         return cls(obj)

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in __init__(self, model_id, subscribe, publish, bind, company_id)
    588
    589         self.subscribe = [any_address(a, allow_unassigned=False) for a in subscribe]
--> 590         self.publish = unpack(Publish, publish)
    591         self.bind = [KeyIndex(i) for i in bind]
    592

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in unpack(cls, obj)
     72         return cls(*obj)
     73     elif isinstance(obj, dict):
---> 74         return cls(**obj)
     75     else:
     76         return cls(obj)

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in __init__(self, address, index, ttl, period, retransmit, credentials)
    362         self.ttl = TTL(ttl)
    363         self.period = PublishPeriod(period)
--> 364         self.retransmit = unpack(PublishRetransmit, retransmit)
    365         self.credentials = FriendshipCredentials(credentials)
    366

A:\nrf5_SDK_for_Mesh_v2.0.1_src\scripts\interactive_pyaci\mesh\types.py in unpack(cls, obj)
     72         return cls(*obj)
     73     elif isinstance(obj, dict):
---> 74         return cls(**obj)
     75     else:
     76         return cls(obj)

TypeError: __init__() got an unexpected keyword argument 'interval'
{
  "$schema": "",
  "appKeys": [
    {
      "boundNetKey": 0,
      "index": 0,
      "key": "4f68ad85d9f48ac8589df665b6b49b8a",
      "name": "lights"
    },
    {
      "boundNetKey": 0,
      "index": 1,
      "key": "2aa2a6ded5a0798ceab5787ca3ae39fc",
      "name": "locks"
    }
  ],
  "groups": [
    {
      "address": 49153,
      "name": "Room 1",
      "parentAddress": 0
    },
    {
      "address": 49154,
      "name": "Room 2",
      "parentAddress": 0
    }
  ],
  "ivIndex": 0,
  "ivUpdate": 0,
  "meshName": "BT Mesh",
  "meshUUID": "01020304050607080102030405060708",
  "netKeys": [
    {
      "index": 0,
      "key": "18eed9c2a56add85049ffc3c59ad0e12",
      "minSecurity": "low",
      "name": "root",
      "phase": 0
    }
  ],
  "nodes": [
    {
      "UUID": "0059ffff0000000023ed93861a057ff9",
      "appKeys": [
        0
      ],
      "cid": "0059",
      "configComplete": false,
      "crpl": "0020",
      "deviceKey": "5d720152ab1a395927e08c2618976d44",
      "elements": [
        {
          "index": 0,
          "location": "0000",
          "models": [
            {
              "modelId": "0000"
            },
            {
              "modelId": "0002"
            },
            {
              "bind": [
                0
              ],
              "modelId": "00590000"
            }
          ]
        }
      ],
      "features": {
        "friend": 2,
        "lowPower": 2,
        "proxy": 2,
        "relay": 0
      },
      "name": "Light bulb",
      "netKeys": [
        0
      ],
      "pid": "0000",
      "security": "low",
      "unicastAddress": 16,
      "vid": "0000"
    },
    {
      "UUID": "0059abcdefabcdefaccdefabcdefabcd",
      "appKeys": [
        0
      ],
      "cid": "0059",
      "configComplete": false,
      "crpl": 32,
      "deviceKey": "101b9992f719f5fba1139a7da4807cbf",
      "elements": [
        {
          "index": 0,
          "location": "0000",
          "models": [
            {
              "modelId": "0000"
            },
            {
              "modelId": "0002"
            }
          ]
        },
        {
          "index": 1,
          "location": "0000",
          "models": [
            {
              "bind": [
                0
              ],
              "modelId": "00590001",
              "publish": {
                "address": 16,
                "credentials": 0,
                "index": 0,
                "period": 0,
                "retransmit": {
                  "count": 0,
                  "interval": 50
                },
                "ttl": 1
              }
            }
          ]
        },
        {
          "index": 2,
          "location": "0000",
          "models": [
            {
              "modelId": "00590001"
            }
          ]
        },
        {
          "index": 3,
          "location": "0000",
          "models": [
            {
              "modelId": "00590001"
            }
          ]
        },
        {
          "index": 4,
          "location": "0000",
          "models": [
            {
              "modelId": "00590001"
            }
          ]
        }
      ],
      "features": {
        "friend": 2,
        "lowPower": 2,
        "proxy": 2,
        "relay": 0
      },
      "name": "Light switch",
      "netKeys": [
        0
      ],
      "pid": "0000",
      "security": "low",
      "unicastAddress": 17,
      "vid": "0000"
    }
  ],
  "provisioners": [
    {
      "UUID": "00000000000000000000000000000000",
      "allocatedGroupRange": [
        {
          "highAddress": 65279,
          "lowAddress": 49152
        }
      ],
      "allocatedUnicastRange": [
        {
          "highAddress": 32767,
          "lowAddress": 16
        }
      ],
      "name": "BT Mesh Provisioner"
    }
  ],
  "timestamp": "2018-05-15 21:51:40.737473"
}

  • The reported issue fixed by following changes in types.py (In class Retransmit missing "interval" parameter). Please suggest if better fix available.

    class Retransmit(object):
    COUNT_MIN = 0
    COUNT_MAX = 7
    INTERVAL_STEPS_MIN = 0
    INTERVAL_STEPS_MAX = 31
    INTERVAL_STEP_SIZE = 1

    def __init__(self, count, interval=0, interval_steps=0):
    if self.COUNT_MIN <= count <= self.COUNT_MAX:
    self.count = count
    else:
    raise ValueError("Count %d is not in range [%d, %d]" % (
    count, self.COUNT_MIN, self.COUNT_MAX))
    if self.INTERVAL_STEPS_MIN <= interval_steps <= self.INTERVAL_STEPS_MAX:
    self.interval_steps = interval_steps
    else:
    raise ValueError("Interval steps %d is not in range [%d, %d]" % (
    interval_steps, self.INTERVAL_STEPS_MIN, self.INTERVAL_STEPS_MAX))

    self.interval = (interval_steps + 1) * self.INTERVAL_STEP_SIZE
    if interval != 0:
    self.interval = interval

    def pack(self):
    return (self.count | (self.interval_steps << 3) & 0xFF)

    @classmethod
    def unpack(cls, val):
    count = val & 0x07
    interval_steps = ((val >> 3) & 0x1f)
    return cls(count, interval_steps)

    def __repr__(self):
    return str(self.__dict__)

    def to_json(self):
    return {"count": self.count, "interval": self.interval}
Related