def setNetworkKey(self, key):
        """set Thread Network master key

        Args:
            key: Thread Network master key used in secure the MLE/802.15.4 packet

        Returns:
            True: successful to set the Thread Network master key
            False: fail to set the Thread Network master key
        """
        masterKey = ''
        print '%s call setNetworkKey' % self.port

        try:
            if not isinstance(key, str):
                masterKey = self.__convertLongToString(key)

                # prpend '0' at the beginning
                if len(masterKey) < 32:
                    masterKey = masterKey.zfill(32)

                cmd = WPANCTL_CMD + 'setprop Network:Key %s' % masterKey
                datasetCmd = WPANCTL_CMD + 'setprop Dataset:MasterKey %s' % masterKey
            else:
                masterKey = key
                cmd = WPANCTL_CMD + 'setprop Network:Key %s' % masterKey
                datasetCmd = WPANCTL_CMD + 'setprop Dataset:MasterKey %s' % masterKey

            self.networkKey = masterKey
            self.hasActiveDatasetToCommit = True
            return self.__sendCommand(cmd)[0] != 'Fail' and self.__sendCommand(datasetCmd)[0] != 'Fail'
        except Exception, e:
            ModuleHelper.WriteIntoDebugLogger('setNetworkkey() Error: ' + str(e))
def setNetworkKey ( self , key ) : masterKey = '' print '%s call setNetworkKey' % self . port try : if not isinstance ( key , str ) : masterKey = self . __convertLongToString ( key ) if len ( masterKey ) < 32 : masterKey = masterKey . zfill ( 32 ) cmd = WPANCTL_CMD + 'setprop Network:Key %s' % masterKey datasetCmd = WPANCTL_CMD + 'setprop Dataset:MasterKey %s' % masterKey else : masterKey = key cmd = WPANCTL_CMD + 'setprop Network:Key %s' % masterKey datasetCmd = WPANCTL_CMD + 'setprop Dataset:MasterKey %s' % masterKey self . networkKey = masterKey self . hasActiveDatasetToCommit = True return self . __sendCommand ( cmd ) [ 0 ] != 'Fail' and self . __sendCommand ( datasetCmd ) [ 0 ] != 'Fail' except Exception , e : ModuleHelper . WriteIntoDebugLogger ( 'setNetworkkey() Error: ' + str ( e ) )
set Thread Network master key

        Args:
            key: Thread Network master key used in secure the MLE/802.15.4 packet

        Returns:
            True: successful to set the Thread Network master key
            False: fail to set the Thread Network master key