Пример #1
0
    def _OnSecurityConfig(self, evn):
        """
        Gateway->Security pressed. Callback function
        """
        # Configuration settings
        config = XmlNetwork(XmlSettings.network_file)
        # Open security config dialog
        dialog = SecurityDialog(self, config.security, config.password)

        res = dialog.ShowModal()

        # Save new settings in xml file
        if res == wx.ID_CANCEL:
            return

        config.security = 0
        if dialog.playbk:
            config.security += 1
        if dialog.smartencrypt:
            config.security += 2
        config.password = dialog.password
        config.save()

        self._Info(
            "In order to take the new settings, you need to restart the gateway",
            "Gateway restart required")
Пример #2
0
    def _OnGatewayNetworkConfig(self, evn):
        """
        Gateway->Network pressed. Callback function
        """
        # Configuration settings
        config = XmlNetwork(XmlSettings.network_file)
        # Open network config dialog
        if self.server.modem is None:
            dialog = NetworkDialog(self, config.devaddress,
                                   hex(config.network_id)[2:],
                                   config.freq_channel)
        else:
            dialog = NetworkDialog(self, self.server.modem.devaddress,
                                   hex(self.server.modem.syncword)[2:],
                                   self.server.modem.freq_channel)
        res = dialog.ShowModal()

        # Save new settings in xml file
        if res == wx.ID_CANCEL:
            return

        config.devaddress = int(dialog.devaddress)
        config.network_id = int(dialog.netid, 16)
        config.freq_channel = int(dialog.freq_channel)
        config.save()

        self._Info(
            "In order to take the new settings, you need to restart the gateway",
            "Gateway restart required")
Пример #3
0
 def config_network(self, channel, netid, address, security, password):
     """
     Configure network parameters from the serial modem
     
     @param channel RF channel
     @param netid SWAP network ID
     @param address network address
     @param security wireless security flag
     @param password password for wireless security
     """
     try:
         # Open network configuration
         config = XmlNetwork(self.main_settings.network_file)
         # Change parameters
         config.freq_channel = int(channel)
         config.network_id = int(netid, 16)
         config.devaddress = int(address)
         config.security = int(security)
         config.password = password                   
         config.save()
     except:
         raise LagartoException("Unable to save modem network settings")
Пример #4
0
 def config_network(self, channel, netid, address, security, password):
     """
     Configure network parameters from the serial modem
     
     @param channel RF channel
     @param netid SWAP network ID
     @param address network address
     @param security wireless security flag
     @param password password for wireless security
     """
     try:
         # Open network configuration
         config = XmlNetwork(self.main_settings.network_file)
         # Change parameters
         config.freq_channel = int(channel)
         config.network_id = int(netid, 16)
         config.devaddress = int(address)
         config.security = int(security)
         config.password = password
         config.save()
     except:
         raise LagartoException("Unable to save modem network settings")
Пример #5
0
 def _OnGatewayNetworkConfig(self, evn):
     """
     Gateway->Network pressed. Callback function
     """
     # Configuration settings
     config = XmlNetwork(XmlSettings.network_file)
     # Open network config dialog
     if self.server.modem is None:
         dialog = NetworkDialog(self, config.devaddress, hex(config.network_id)[2:], config.freq_channel)
     else:
         dialog = NetworkDialog(self, self.server.modem.devaddress, hex(self.server.modem.syncword)[2:], self.server.modem.freq_channel)
     res = dialog.ShowModal()
     
     # Save new settings in xml file
     if res == wx.ID_CANCEL:
         return
     
     config.devaddress = int(dialog.devaddress)
     config.network_id = int(dialog.netid, 16)
     config.freq_channel = int(dialog.freq_channel)
     config.save()
     
     self._Info("In order to take the new settings, you need to restart the gateway", "Gateway restart required")
Пример #6
0
    def _OnSecurityConfig(self, evn):
        """
        Gateway->Security pressed. Callback function
        """
        # Configuration settings
        config = XmlNetwork(XmlSettings.network_file)
        # Open security config dialog
        dialog = SecurityDialog(self, config.security, config.password)

        res = dialog.ShowModal()
        
        # Save new settings in xml file
        if res == wx.ID_CANCEL:
            return
        
        config.security = 0
        if dialog.playbk:
            config.security += 1
        if dialog.smartencrypt:
            config.security += 2
        config.password = dialog.password
        config.save()
        
        self._Info("In order to take the new settings, you need to restart the gateway", "Gateway restart required")
Пример #7
0
    def http_command_received(self, command, params):
        """
        Process command sent from HTTP server. Method to be overrided by data server.
        Method required by LagartoServer
        
        @param command: command string
        @param params: dictionary of parameters
        
        @return True if command successfully processed by server.
        Return False otherwise
        """
        try:
            # Configure endpoint
            if command == "config_endpoint":
                endp = self.get_endpoint(endpid=params["id"])
                endp.name = params["name"]
                endp.location = params["location"]
                if "unit" in params:
                    endp.setUnit(params["unit"])
                self.network.save()
            elif command == "delete_mote":
                self.network.delete_mote(int(params["address"]))
            else:
                # Save gateway's wireless settings
                if command == "modem_network":
                    main_settings = XmlSettings(self.swap_settings)
                    # Open network configuration
                    config = XmlNetwork(main_settings.network_file)
                    # Change parameters
                    config.freq_channel = int(params["channel"])
                    config.network_id = int(params["netid"], 16)
                    config.devaddress = int(params["address"])
                    config.security = int(params["security"])
                    config.password = params["password"]
                # Save gateway's port settings
                elif command == "modem_serial":
                    main_settings = XmlSettings(self.swap_settings)
                    # Open network configuration
                    config = XmlSerial(main_settings.serial_file)
                    # Change parameters
                    config.port = params["port"]
                    config.speed = int(params["speed"])
                # Configure general settings
                elif command == "general_settings":
                    config = XmlSettings(self.swap_settings)
                    config.debug = int(params["debug"])
                    config.device_localdir = params["local"]
                    config.device_remote = params["remote"]
                    if "update" in params:
                        config.updatedef = params["update"] == "true"
                    config.serial_file = params["serial"]
                    config.network_file = params["network"]
                    config.swap_file = params["swapnet"]

                # Save config file
                config.save()
                # Save current network information
                self.network.save()
                # Restart server
                self.server.stop()
                self.server.start()

        except:
            return False

        return True
Пример #8
0
 def http_command_received(self, command, params):
     """
     Process command sent from HTTP server. Method to be overrided by data server.
     Method required by LagartoServer
     
     @param command: command string
     @param params: dictionary of parameters
     
     @return True if command successfully processed by server.
     Return False otherwise
     """
     try:
         # Configure endpoint
         if command == "config_endpoint":
             endp = self.get_endpoint(endpid=params["id"])
             endp.name = params["name"]
             endp.location = params["location"]
             if "unit" in params:
                 endp.setUnit(params["unit"])
             self.network.save()
         elif command == "delete_mote":
             self.network.delete_mote(int(params["address"]))
         elif command == "config_mote":
             mote_addr = int(params.get("moteaddr", "-1"))
             new_address = int(params.get("address", "-1"))
             state = int(params.get("state", "-1"))
             channel = int(params.get("channel", "-1"))
             interval = int(params.get("interval", "-1"))
             self.network.config_mote(mote_addr, new_address, state, channel, interval)
         else:
             # Save gateway's wireless settings
             if command == "modem_network":
                 main_settings = XmlSettings(self.swap_settings)
                 # Open network configuration
                 config = XmlNetwork(main_settings.network_file)
                 # Change parameters
                 config.freq_channel = int(params["channel"])
                 config.network_id = int(params["netid"], 16)
                 config.devaddress = int(params["address"])
                 config.security = int(params["security"])
                 config.password = params["password"]                   
             # Save gateway's port settings
             elif command == "modem_serial":
                 main_settings = XmlSettings(self.swap_settings)
                 # Open network configuration
                 config = XmlSerial(main_settings.serial_file)
                 # Change parameters
                 config.port = params["port"]
                 config.speed = int(params["speed"])   
             # Configure general settings
             elif command == "general_settings":
                 config = XmlSettings(self.swap_settings)
                 config.debug = int(params["debug"])
                 config.device_localdir = params["local"]
                 config.device_remote = params["remote"]
                 if "update" in params:
                     config.updatedef = params["update"] == "true"
                 config.serial_file = params["serial"]
                 config.network_file = params["network"]
                 config.swap_file = params["swapnet"]
                 
             # Save config file
             config.save()
             # Save current network information
             self.network.save()
             # Restart server
             self.server.stop()
             self.server.start()
             
     except:
         return False
     
     return True
Пример #9
0
        if netid is not None:
            network_cfg.network_id = netid
            save_file = True
    if opts.address is not None:
        addr = SwapManager.str_to_int(opts.address)
        if addr is not None:
            network_cfg.devaddress = addr
            save_file = True
    if opts.security is not None:
        secu = SwapManager.str_to_int(opts.security)
        if secu is not None:
            network_cfg.security = secu
            save_file = True

    if save_file:
        network_cfg.save()

    # Catch possible SIGINT signals
    signal.signal(signal.SIGINT, signal_handler)

    try:
        # SWAP manager
        swap_manager = SwapManager(settings)
    except SwapException as ex:
        ex.display()
        ex.log()

    while True:
        if swap_manager.server_started == True and swap_manager.prog_address is None:

            # Launch Macro
Пример #10
0
        if netid is not None:
            network_cfg.network_id = netid
            save_file = True
    if opts.address is not None:
        addr = SwapManager.str_to_int(opts.address)
        if addr is not None:
            network_cfg.devaddress = addr
            save_file = True
    if opts.security is not None:
        secu = SwapManager.str_to_int(opts.security)
        if secu is not None:
            network_cfg.security = secu
            save_file = True
        
    if save_file:
        network_cfg.save()

    # Catch possible SIGINT signals
    signal.signal(signal.SIGINT, signal_handler)

    try:        
        # SWAP manager
        swap_manager = SwapManager(settings)
    except SwapException as ex:
        ex.display()
        ex.log()

    while True:
        if swap_manager.server_started == True and swap_manager.prog_address is None:
            
            # Launch Macro