示例#1
0
 def callback_afUnusedPanIdFoundHandler(self, panId, channel):
     parameters = ezsp.EmberNetworkParameters()
     parameters.extendedPanId = byte_tuple.convertToExtPan(self.bridge_configuration['extended_pan_id'])
     parameters.panId = panId
     parameters.radioTxPower = self.bridge_configuration['radio_power']
     parameters.radioChannel = channel
     self.formNetwork(parameters)
     framework.ApplicationFramework.callback_afUnusedPanIdFoundHandler(self, panId, channel)
示例#2
0
    def _resetAndInitNCP(self):
        self.ezspInit()
        if not self._getVersion():
            return False
        _applicationZdoFlags = 0
        if self.EMBER_APPLICATION_RECEIVES_SUPPORTED_ZDO_REQUESTS:
            _applicationZdoFlags |= ezsp.EMBER_APP_RECEIVES_SUPPORTED_ZDO_REQUESTS
        if self.EMBER_APPLICATION_HANDLES_UNSUPPORTED_ZDO_REQUESTS:
            _applicationZdoFlags |= ezsp.EMBER_APP_HANDLES_UNSUPPORTED_ZDO_REQUESTS
        if self.EMBER_APPLICATION_HANDLES_ENDPOINT_ZDO_REQUESTS:
            _applicationZdoFlags |= ezsp.EMBER_APP_HANDLES_ZDO_ENDPOINT_REQUESTS
        if self.EMBER_APPLICATION_HANDLES_BINDING_ZDO_REQUESTS:
            _applicationZdoFlags |= ezsp.EMBER_APP_HANDLES_ZDO_BINDING_REQUESTS
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_APPLICATION_ZDO_FLAGS, _applicationZdoFlags, 'application zdo flags')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_SOURCE_ROUTE_TABLE_SIZE, self.EMBER_SOURCE_ROUTE_TABLE_SIZE, 'source route table size')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_SECURITY_LEVEL, self.SECURITY_LEVEL, 'security level')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_ADDRESS_TABLE_SIZE, self.EMBER_AF_ADDRESS_TABLE_SIZE, 'address table size')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE, self.EMBER_AF_TRUST_CENTER_ADDRESS_CACHE_SIZE, 'TC addr cache')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_STACK_PROFILE, self.EMBER_STACK_PROFILE, 'stack profile')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_KEY_TABLE_SIZE, self.EMBER_KEY_TABLE_SIZE, 'key table size')
        self._setEzspPolicy(ezsp.EZSP_BINDING_MODIFICATION_POLICY, ezsp.EZSP_DISALLOW_BINDING_MODIFICATION, 'binding modify', 'disallow')
        self._setEzspPolicy(ezsp.EZSP_MESSAGE_CONTENTS_IN_CALLBACK_POLICY, ezsp.EZSP_MESSAGE_TAG_ONLY_IN_CALLBACK, 'message content in msgSent', 'Tag only')
        self._setEzspValue(ezsp.EZSP_VALUE_MAXIMUM_INCOMING_TRANSFER_SIZE, (self.EMBER_AF_INCOMING_BUFFER_LENGTH & 255, self.EMBER_AF_INCOMING_BUFFER_LENGTH >> 8), 'maximum incoming transfer size')
        self._setEzspValue(ezsp.EZSP_VALUE_MAXIMUM_OUTGOING_TRANSFER_SIZE, (self.EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH & 255, self.EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH >> 8), 'maximum outgoing transfer size')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_FRAGMENT_WINDOW_SIZE, 8, 'Fragment window size')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_FRAGMENT_DELAY_MS, 0, 'Fragment delay')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT, self.EMBER_END_DEVICE_POLL_TIMEOUT, 'End device poll timeout')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT, self.EMBER_END_DEVICE_POLL_TIMEOUT_SHIFT, 'End device poll timeout shift')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_TX_POWER_MODE, self.bridge_configuration['tx_power_mode'], 'TX power mode')
        self._setEzspConfigValue(ezsp.EZSP_CONFIG_DISABLE_RELAY, self.bridge_configuration['disable_relay'], 'Disable relay')
        self.logger.info('End device timeout is %i seconds.' % (self.EMBER_END_DEVICE_POLL_TIMEOUT << self.EMBER_END_DEVICE_POLL_TIMEOUT_SHIFT))
        self.emberSetManufacturerCode(self.EMBER_AF_MANUFACTURER_CODE)
        self._setPacketBufferCount()
        if self.EMBER_AF_ENABLE_FRAGMENTATION:
            self.fragmentationInit()
        for ep in self.ENDPOINTS:
            self._createEndpoint(ep)

        self.TCSecurityPolicyInit()
        self._joinedNetwork = False
        parameters = ezsp.EmberNetworkParameters()
        try:
            nodeType = self.ezspGetNetworkParameters(parameters)
            self._joinedNetwork = True
        except ezsp.EmberStatus as e:
            if e.value != ezsp.EMBER_NOT_JOINED:
                raise 
        if self._joinedNetwork:
            if nodeType == self.ZA_DEVICE_TYPE:
                self._networkInit()
            elif nodetype == ezsp.EMBER_ROUTER:
                if self.ZA_DEVICE_TYPE == config.ZA_COORDINATOR:
                    self._networkInit()
        self._eui64 = self.ezspGetEui64()
        return True
示例#3
0
 def getNetworkInformationDict(self):
     networkStatusDict = {ezsp.EMBER_NO_NETWORK: 'EMBER_NO_NETWORK',
      ezsp.EMBER_JOINING_NETWORK: 'EMBER_JOINING_NETWORK',
      ezsp.EMBER_JOINED_NETWORK: 'EMBER_JOINED_NETWORK',
      ezsp.EMBER_JOINED_NETWORK_NO_PARENT: 'EMBER_JOINED_NETWORK_NO_PARENT',
      ezsp.EMBER_LEAVING_NETWORK: 'EMBER_LEAVING_NETWORK'}
     securityProfileDict = {security_config.NONE_SECURITY_PROFILE: 'No Security',
      security_config.HA_SECURITY_PROFILE: 'HA',
      security_config.SE_SECURITY_PROFILE_TEST: 'SE Test',
      security_config.SE_SECURITY_PROFILE_FULL: 'SE Full'}
     nodeTypeDict = {ezsp.EMBER_UNKNOWN_DEVICE: 'EMBER_UNKNOWN_DEVICE',
      ezsp.EMBER_COORDINATOR: 'EMBER_COORDINATOR',
      ezsp.EMBER_ROUTER: 'EMBER_ROUTER',
      ezsp.EMBER_END_DEVICE: 'EMBER_END_DEVICE',
      ezsp.EMBER_SLEEPY_END_DEVICE: 'EMBER_SLEEPY_END_DEVICE',
      ezsp.EMBER_MOBILE_END_DEVICE: 'EMBER_MOBILE_END_DEVICE'}
     powerModeDict = {ezsp.EMBER_TX_POWER_MODE_DEFAULT: 'EMBER_TX_POWER_MODE_DEFAULT',
      ezsp.EMBER_TX_POWER_MODE_BOOST: 'EMBER_TX_POWER_MODE_BOOST',
      ezsp.EMBER_TX_POWER_MODE_ALTERNATE: 'EMBER_TX_POWER_MODE_ALTERNATE',
      ezsp.EMBER_TX_POWER_MODE_BOOST_AND_ALTERNATE: 'EMBER_TX_POWER_MODE_BOOST_AND_ALTERNATE'}
     return_dict = {}
     state = self.emberNetworkState()
     return_dict['node_eui64'] = byte_tuple.eui64ToHexString(self._eui64)
     return_dict['network_status'] = networkStatusDict[state]
     power_mode_value = self.ezspGetConfigurationValue(ezsp.EZSP_CONFIG_TX_POWER_MODE)
     return_dict['radio_power_mode'] = powerModeDict[power_mode_value]
     if state == ezsp.EMBER_JOINED_NETWORK or state == ezsp.EMBER_JOINED_NETWORK_NO_PARENT:
         parameters = ezsp.EmberNetworkParameters()
         node = self.ezspGetNetworkParameters(parameters)
         if node in nodeTypeDict:
             nodeType = nodeTypeDict[node]
         else:
             nodeType = 'Unknown'
         securityLevel = self.ezspGetConfigurationValue(ezsp.EZSP_CONFIG_SECURITY_LEVEL)
         if self.EMBER_AF_SECURITY_PROFILE == security_config.CUSTOM_SECURITY_PROFILE:
             securityProfile = self.CUSTOM_PROFILE_STRING
         else:
             securityProfile = securityProfileDict[self.EMBER_AF_SECURITY_PROFILE]
         return_dict['node_type'] = nodeType
         return_dict['pan_id'] = '0x%04X' % parameters.panId
         return_dict['extended_pan_id'] = byte_tuple.extPanToHexString(parameters.extendedPanId)
         return_dict['node_id'] = '0x%04X' % self.emberGetNodeId()
         return_dict['channel'] = parameters.radioChannel
         return_dict['power'] = parameters.radioTxPower
         return_dict['security_level'] = securityLevel
         return_dict['security_profile'] = securityProfile
     return return_dict