Ejemplo n.º 1
0
def leaveMgtReJoin(self, saddr, ieee, rejoin=True):
    """
    E_SL_MSG_MANAGEMENT_LEAVE_REQUEST / 0x47


    This function requests a remote node to leave the network. The request also
    indicates whether the children of the leaving node should also be requested to leave
    and whether the leaving node(s) should subsequently attempt to rejoin the network.

    This function is provided in the ZDP API for the reason
    of interoperability with nodes running non-NXP ZigBee PRO
    stacks that support the generated request. On receiving a
    request from this function, the NXP ZigBee PRO stack will
    return the status ZPS_ZDP_NOT_SUPPORTED.

    """

    self.log.logging(
        "BasicOutput",
        "Log",
        "leaveMgtReJoin - sAddr: %s , ieee: %s, [%s/%s]"
        % (saddr, ieee, self.pluginconf.pluginConf["allowAutoPairing"], rejoin),
        saddr,
    )
    if not self.pluginconf.pluginConf["allowAutoPairing"]:
        self.log.logging(
            "BasicOutput",
            "Log",
            "leaveMgtReJoin - no action taken as 'allowAutoPairing' is %s"
            % self.pluginconf.pluginConf["allowAutoPairing"],
            saddr,
        )
        return None

    if rejoin:
        self.log.logging(
            "BasicOutput",
            "Status",
            "Switching Zigate in pairing mode to allow %s (%s) coming back" % (saddr, ieee),
            saddr,
        )

        # If Zigate not in Permit to Join, let's switch it to Permit to Join for 60'
        duration = self.permitTojoin["Duration"]
        stamp = self.permitTojoin["Starttime"]
        if duration == 0:
            dur_req = 60
            self.permitTojoin["Duration"] = 60
            self.permitTojoin["Starttime"] = int(time())
            self.log.logging(
                "BasicOutput", "Debug", "leaveMgtReJoin - switching Zigate in Pairing for %s sec" % dur_req, saddr
            )
            send_zigatecmd_raw(self, "0049", "FFFC" + "%02x" % dur_req + "00")
            self.log.logging("BasicOutput", "Debug", "leaveMgtReJoin - Request Pairing Status")
            zigate_get_permit_joint_status(self)
            #send_zigatecmd_raw(self, "0014", "")  # Request status
        elif duration != 255:
            if int(time()) >= (self.permitTojoin["Starttime"] + 60):
                dur_req = 60
                self.permitTojoin["Duration"] = 60
                self.permitTojoin["Starttime"] = int(time())
                self.log.logging(
                    "BasicOutput", "Debug", "leaveMgtReJoin - switching Zigate in Pairing for %s sec" % dur_req, saddr
                )
                send_zigatecmd_raw(self, "0049", "FFFC" + "%02x" % dur_req + "00")
                self.log.logging("BasicOutput", "Debug", "leaveMgtReJoin - Request Pairing Status")
                zigate_get_permit_joint_status(self)
                #send_zigatecmd_raw(self, "0014", "")  # Request status

        # Request a Re-Join and Do not remove children
        _leave = "01"
        _rejoin = "01"
        _rmv_children = "01"
        _dnt_rmv_children = "00"

        self.log.logging("BasicOutput", "Status", "Request a rejoin of (%s/%s)" % (saddr, ieee), saddr)
        return zdp_management_leave_request(self, saddr, ieee, _rejoin, _dnt_rmv_children)
Ejemplo n.º 2
0
def zdp_get_list_attribute_extended_infos(self, nwkid, EpIn, EpOut, cluster, start_attribute="0000", manuf_specific="00", manuf_code="0000"):
    self.log.logging( "zdpCommand", "Debug","zdp_get_list_attribute_extended_infos %s %s %s %s %s %s %s" %(
        nwkid, EpIn, EpOut, cluster, start_attribute, manuf_specific, manuf_code))
    return send_zigatecmd_raw(self, nwkid, "0141", EpIn + EpOut + cluster + start_attribute + "00" + manuf_specific + manuf_code + "01")
Ejemplo n.º 3
0
def zdp_unbinding_device(self, ieee , ep , cluster , addrmode , destaddr , destep):
    self.log.logging( "zdpCommand", "Debug","zdp_unbinding_device %s %s %s %s %s %s" %(ieee , ep , cluster , addrmode , destaddr , destep))
    return send_zigatecmd_raw(self, "0031", ieee + ep + cluster + addrmode + destaddr + destep)
Ejemplo n.º 4
0
def zdp_many_to_one_route_request(self, bCacheRoute, u8Radius):
    self.log.logging( "zdpCommand", "Debug","zdp_many_to_one_route_request %s %s" %(bCacheRoute, u8Radius))
    return send_zigatecmd_raw(self, "004F", bCacheRoute + u8Radius)
Ejemplo n.º 5
0
def zdp_attribute_discovery_request(self, nwkid, EpIn, EpOut, cluster, start_attribute="0000", manuf_specific="00", manuf_code="0000"):
    self.log.logging( "zdpCommand", "Debug","zdp_attribute_discovery_request %s %s %s %s %s %s %s" %(
        nwkid, EpIn, EpOut, cluster, start_attribute, manuf_specific, manuf_code))
    return send_zigatecmd_raw(self, nwkid, "0140", EpIn + EpOut + cluster + start_attribute + "00" + manuf_specific + manuf_code + "01")
Ejemplo n.º 6
0
def zdp_reset_device(self, nwkid, epin, epout):
    self.log.logging( "zdpCommand", "Log","zdp_reset_device %s %s %s" %(nwkid, epin, epout))
    return send_zigatecmd_raw(self, "0050", "02" + nwkid + epin + epout)
Ejemplo n.º 7
0
def zdp_management_network_update_request(self, target_address , channel_mask , scanDuration , scan_repeat="00" , nwk_updateid="00", nwk_manager="0000"):
    self.log.logging( "zdpCommand", "Debug","zdp_management_network_update_request %s %s %s %s %s %s" %(
        target_address , channel_mask , scanDuration , scan_repeat , nwk_updateid, nwk_manager))
    datas = target_address + channel_mask + scanDuration + scan_repeat + nwk_updateid + nwk_manager
    return send_zigatecmd_raw(self, "004A", datas)
Ejemplo n.º 8
0
def zdp_permit_joining_request(self, tgtnwkid , duration , significance):
    self.log.logging( "zdpCommand", "Log","zdp_permit_joining_request %s %s %s" %(tgtnwkid , duration , significance))
    return send_zigatecmd_raw(self, "0049", tgtnwkid + duration + significance)
Ejemplo n.º 9
0
def zdp_management_leave_request(self, nwkid, ieee, rejoin="01", remove_children="00"):
    self.log.logging( "zdpCommand", "Log","zdp_management_leave_request %s %s %s %s" %(nwkid, ieee, rejoin, remove_children))
    return send_zigatecmd_raw(self, "0047", nwkid + ieee + rejoin + remove_children)
Ejemplo n.º 10
0
def zdp_simple_descriptor_request(self, nwkid, endpoint):
    self.log.logging( "zdpCommand", "Log","zdp_active_endpoint_request %s %s" %(nwkid, endpoint))
    if 'ZiGateInRawMode' in self.pluginconf.pluginConf and self.pluginconf.pluginConf["ZiGateInRawMode"]:
        return zdp_raw_simple_descriptor_request(self, nwkid, endpoint)
    return send_zigatecmd_raw(self, "0043", nwkid + endpoint)
Ejemplo n.º 11
0
def zdp_node_descriptor_request(self, nwkid):
    self.log.logging( "zdpCommand", "Log","zdp_node_descriptor_request %s" %(nwkid, ))
    if 'ZiGateInRawMode' in self.pluginconf.pluginConf and self.pluginconf.pluginConf["ZiGateInRawMode"]:
        return zdp_raw_node_descriptor_request(self, nwkid)
    return send_zigatecmd_raw(self, "0042", nwkid)
Ejemplo n.º 12
0
def zdp_IEEE_address_request(self, lookup, u8RequestType , u8StartIndex):
    self.log.logging( "zdpCommand", "Debug","zdp_IEEE_address_request %s %s %s" %( lookup, u8RequestType , u8StartIndex ))
    return send_zigatecmd_raw(self, "0041", "02" + lookup + lookup + u8RequestType + u8StartIndex)