def provision(self, uuid=None, key_index=0, name="", context_id=0, attention_duration_s=0): """Starts provisioning of the given unprovisioned device. Parameters: ----------- uuid : uint8_t[16] 16-byte long hexadcimal string or bytearray key_index : uint16_t NetKey index name : string Name to give the device (stored in the database) conext-id: Provisioning context ID to use. Normally no reason to change. attention_duration_s : uint8_t Time in seconds during which the device will identify itself using any means it can. """ if not uuid: uuid = self.unprov_list.pop(0) elif isinstance(uuid, str): uuid = bytearray.fromhex(uuid) elif not isinstance(uuid, bytearray): raise TypeError("UUID must be string or bytearray") if len(uuid) != 16: raise ValueError("UUID must be 16 bytes long") netkey = None for key in self.prov_db.net_keys: if key_index == key.index: netkey = key break if not netkey: raise ValueError("No network key found for key index %d" % (key_index)) self.iaci.send( cmd.Provision(context_id, uuid, netkey.key, netkey.index, self.prov_db.iv_index, self.__next_free_address, self.prov_db.iv_update, netkey.phase > 0, attention_duration_s)) self.__session_data["UUID"] = uuid self.__session_data["name"] = name self.__session_data["net_keys"] = [netkey.index] self.__session_data["unicast_address"] = mt.UnicastAddress( self.__next_free_address) self.__session_data["config_complete"] = False self.__session_data["security"] = netkey.min_security
def provision(self, unprovisioned_device_number=None, context_id=0): """Starts provisioning of the given unprovisioned device.""" unprov = self.__unprov_list.pop(unprovisioned_device_number) self.iaci.send( cmd.Provision(context_id, unprov["uuid"], **self.__prov_data))