def __init__(self, parent, primary, user, password, manifest=None, udp_data=None, address=None): self.parent = parent self.user = user self.password = password self.connected = 0 self.parent.logger.info("FoscamHD2:init: Adding manifest=%s upd_data=%s" % (manifest,udp_data)) self.status = {} # Use Basic authorization for all HD cameras? self.auth_mode = 0 # Use manifest values if passed in. if manifest is not None: self.name = manifest['name'] if address is None: self.parent.send_error("FoscamHD2:init:%s: address must be passed in when using manifest for: " % (name,manifest)) return False self.address = address # TODO: It's ok to not have drivers? Just let query fill out the info? if not 'drivers' in manifest: self.parent.send_error("FoscamHD2:init:%s: no drivers in manifest: " % (name,manifest)) return False drivers = manifest['drivers'] # Get the things we need from the drivers, the rest will be queried. self.ip = long2ip(drivers['GV2']) self.port = drivers['GV3'] self.sys_ver = drivers['GV11'] self.full_sys_ver = self.sys_ver elif udp_data is not None: self.name = udp_data['name'] self.address = udp_data['id'].lower() self.ip = udp_data['ip'] self.port = udp_data['port'] self.sys_ver = self._parse_sys_ver(udp_data['sys']) self.full_sys_ver = str(udp_data['sys']) else: self.parent.send_error("FoscamHD2:init:%s: One of manifest or udp_data must be passed in." % (address)) return False # Add the Camera self.parent.logger.info("FoscamHD2:init: Adding %s %s" % (self.name,self.address)) super(FoscamHD2, self).__init__(parent, self.address, self.name, primary, manifest) # This tracks if _set_motion_params was successful self.set_motion_params_st = True # Initialize things that don't change. self.set_driver('GV1', VERSION_MAJOR, uom=56, report=False) self.set_driver('GV12', VERSION_MINOR, uom=56, report=False) self.set_driver('GV2', ip2long(self.ip), uom=56, report=False) self.set_driver('GV3', self.port, uom=56, report=False) self.set_driver('GV11', self.sys_ver, uom=56, report=False) # Call query to pull in the params before adding the motion node. self.query(); # Add my motion node now that the camera is defined. #self.motion = Motion(parent, self, manifest) # Tell the camera to ping the parent server on motion. #self._set_alarm_params({ # 'motion_armed': 1, # 'http': 1, # 'http_url': "http://%s:%s/motion/%s" % (parent.server.server_address[0], parent.server.server_address[1], self.motion.address) #}); # Query again now that we have set paramaters #self.query(); self.parent.logger.info("FoscamHD2:init: Added camera at %s:%s '%s' %s" % (self.ip,self.port,self.name,self.address))
def query(self, **kwargs): """ query the camera """ # pylint: disable=unused-argument self.l_info("query","start") self._get_status() if self.connected == 1: # Full System Version self.full_sys_ver = self.camera.software_information[0].split('=')[1].decode('utf-8'); sys_ver_l = self.full_sys_ver.split('.') # Just the first part as a float self.sys_ver = myfloat("{0}.{1}".format(sys_ver_l[0],sys_ver_l[1])) self.set_driver('GV1', self.sys_ver, uom=56) # Initialize network info self.ip_address = get_network_ip(self.host) self.set_driver('GV2', ip2long(self.ip_address), uom=56, report=False) self.set_driver('GV3', self.port, uom=56, report=False) # Motion self.set_driver('GV5', bool2int(self.camera.is_motion_detector_on()), uom=2) self._get_motion_params() self.set_driver('GV6', self.record_enable, uom=2) self.set_driver('GV7', self.mail_enable, uom=2) self.set_driver('GV8', self.snapshot_enable, uom=2) self.set_driver('GV9', self.snapshot_times, uom=56) # All done. self.report_driver() self.l_info("query","done") return True
def update_config(self, user, password, udp_data=None): self.parent.logger.info("FoscamMJPEG:update_config: upd_data=%s" % (udp_data)) self.user = user self.password = password if udp_data is not None: self.name = udp_data['name'] self.ip = udp_data['ip'] self.port = udp_data['port'] self.sys_ver = self._parse_sys_ver(udp_data['sys']) self.full_sys_ver = str(udp_data['sys']) self.set_driver('GV2', ip2long(self.ip), uom=56, report=False) self.set_driver('GV3', self.port, uom=56, report=False) self.set_driver('GV11', self.sys_ver, uom=56, report=False) self.query()
def __init__(self, parent, primary, ip_address, port, user, password, manifest=None, name=None, address=None): self.parent = parent self.ip = ip_address self.port = port self.user = user self.password = password self.connected = 0 self.parent.logger.info("FoscamMJPEG:init: Adding %s:%s" % (self.ip,self.port)) # # Get status which contains the camera id and alias, and we need it to add Motion node. self._get_status() if not self.status: return None if name is None: name = self.status['alias'] if address is None: address = self.status['id'] # Address must be lower case? address = address.lower() # Add the Camera super(FoscamMJPEG, self).__init__(parent, address, name, primary, manifest) self.set_driver('GV1', VERSION, uom=56, report=False) self.set_driver('GV2', ip2long(ip_address), uom=56, report=False) self.set_driver('GV3', port, uom=56, report=False) self._get_params(); # Add my motion node. self.motion = Motion(parent, self, manifest) # Tell the camera to ping the parent server on motion. self._set_alarm_params({ 'motion_armed': 1, 'http': 1, 'http_url': "http://%s:%s/motion/%s" % (parent.server.server_address[0], parent.server.server_address[1], self.motion.address) }); # Call query to pull in the params. self.query(); self.parent.logger.info("FoscamMJPEG:init: Added camera at %s:%s '%s' %s" % (self.ip,self.port,name,address))
def update_drivers(self): self.setDriver('ST', 1) self.setDriver('GV2', ip2long(self.ip)) self.setDriver('GV3', self.port) self.setDriver('GV10', self.auth_mode) self.setDriver('GV11', self.sys_ver)
def update_drivers(self): self.setDriver('GV2', ip2long(self.ip)) self.setDriver('GV3', self.port) self.setDriver('GV11', self.sys_s_ver)
def __init__(self, parent, primary, user, password, manifest=None, udp_data=None, address=None): self.parent = parent self.user = user self.password = password self.connected = 0 self.parent.logger.info("FoscamMJPEG:init: Adding manifest=%s upd_data=%s" % (manifest,udp_data)) self.auth_mode = 0 # Use manifest values if passed in. if manifest is not None: self.name = manifest['name'] if address is None: self.parent.send_error("FoscamMJPEG:init:%s: address must be passed in when using manifest for: " % (name,manifest)) return False self.address = address # TODO: It's ok to not have drivers? Just let query fill out the info? if not 'drivers' in manifest: self.parent.send_error("FoscamMJPEG:init:%s: no drivers in manifest: " % (name,manifest)) return False drivers = manifest['drivers'] # Get the things we need from the drivers, the rest will be queried. self.ip = long2ip(drivers['GV2']) self.port = drivers['GV3'] # New in 0.3 if 'GV10' in drivers: self.auth_mode = drivers['GV10'] else: # Old default was digest self.auth_mode = 1 if 'GV11' in drivers: self.sys_ver = drivers['GV11'] else: # Old default was digest self.sys_ver = 0.0 self.full_sys_ver = self.sys_ver elif udp_data is not None: self.name = udp_data['name'] self.address = udp_data['id'].lower() self.auth_mode = self._get_auth_mode(udp_data['sys']) self.ip = udp_data['ip'] self.port = udp_data['port'] self.sys_ver = self._parse_sys_ver(udp_data['sys']) self.full_sys_ver = str(udp_data['sys']) else: self.parent.send_error("FoscamMJPEG:init:%s: One of manifest or udp_data must be passed in." % (address)) return False # Add the Camera self.parent.logger.info("FoscamMJPEG:init: Adding %s %s auth_mode=%d" % (self.name,self.address,self.auth_mode)) super(FoscamMJPEG, self).__init__(parent, self.address, self.name, primary, manifest) self.set_driver('GV1', VERSION_MAJOR, uom=56, report=False) self.set_driver('GV12', VERSION_MINOR, uom=56, report=False) self.set_driver('GV2', ip2long(self.ip), uom=56, report=False) self.set_driver('GV3', self.port, uom=56, report=False) self.set_driver('GV10', self.auth_mode, uom=25, report=False) self.set_driver('GV11', self.sys_ver, uom=56, report=False) # Init these in case we can't query. self.status = {} self.params = {} for param in ('led_mode', 'alarm_motion_armed', 'alarm_mail', 'alarm_motion_sensitivity', 'alarm_motion_compensation', 'alarm_upload_interval'): if not param in self.params: self.params[param] = 0 # Call query to pull in the params before adding the motion node. self.query(); # Add my motion node now that the camera is defined. self.motion = Motion(parent, self, manifest) # Tell the camera to ping the parent server on motion. self._set_alarm_params({ 'motion_armed': 1, 'http': 1, 'http_url': "http://%s:%s/motion/%s" % (parent.server.server_address[0], parent.server.server_address[1], self.motion.address) }); # Query again now that we have set paramaters self.query(); self.parent.logger.info("FoscamMJPEG:init: Added camera at %s:%s '%s' %s" % (self.ip,self.port,self.name,self.address))