def __init__(self, mcontroller, dev_props): self.capabilities = [AT_COMM_CAPABILITY, X_ZONE_CAPABILITY] #Device list with tuplas representating the device (product_id, vendor_id) self.device_list = [(0xc, 0x1931)] MobileDevice.__init__(self, mcontroller, dev_props)
def set_mode_domain(self, mode, domain): if domain == CARD_DOMAIN_CS: real_domain = 0 elif domain == CARD_DOMAIN_PS: real_domain = 1 elif domain == CARD_DOMAIN_CS_PS : real_domain = 2 elif domain == CARD_DOMAIN_ANY: real_domain = 3 else: real_domain = 2 if mode == CARD_TECH_SELECTION_GPRS : res = self.send_at_command("AT^SYSCFG=13,0,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_UMTS : res = self.send_at_command("AT^SYSCFG=14,0,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_GRPS_PREFERED : res = self.send_at_command("AT^SYSCFG=2,1,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_UMTS_PREFERED : res = self.send_at_command("AT^SYSCFG=2,2,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_AUTO : res = self.send_at_command("AT^SYSCFG=2,0,3FFFFFFF,1,%s" % real_domain) else: self.dbg_msg ("SET MODE DOMAIN : CRASH") return False if res[2] == 'OK' : self.dbg_msg ("SET MODE DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain) return True else: self.dbg_msg ("SET MODE DOMAIN (CRASH) : %s" % res) return False
def __init__(self, mcontroller, dev_props): self.capabilities = [AT_COMM_CAPABILITY, X_ZONE_CAPABILITY, SMS_CAPABILITY, ADDRESSBOOK_CAPABILITY] #Device list with tuplas representating the device (product_id, vendor_id) self.device_list = [(0x1,0x19d2), (0x66,0x19d2), (0x124, 0x19d2) ] MobileDevice.__init__(self, mcontroller, dev_props)
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.linux.driver") and props["info.linux.driver"] == "nozomi": if props.has_key("linux.sysfs_path") : files = os.listdir(props["linux.sysfs_path"] + "/tty") for f in files: if f.startswith("noz"): ports.append(f) ports.sort() print ports if len(ports) >= 3 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Option Nozomi" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() device_udi = self.dev_props["info.udi"] for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device") : ports.append(os.path.basename(props["serial.device"])) ports.sort() print ports if len(ports) >= 3 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Novatel" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def __init__(self, mcontroller, dev_props): self.capabilities = [AT_COMM_CAPABILITY, X_ZONE_CAPABILITY, SMS_CAPABILITY, ADDRESSBOOK_CAPABILITY] #Device list with tuplas representating the device (product_id, vendor_id) self.device_list = [(0x4400,0x1410),(0x7001, 0x1410)] MobileDevice.__init__(self, mcontroller, dev_props)
def init_device(self): print 0 port = "/dev/rfcomm%s" % os.path.basename( self.dev_props["linux.sysfs_path"]).strip("hci") parent_dev_dbus_obj = self.dbus.get_object( "org.freedesktop.Hal", self.dev_props["info.parent"]) try: parent_props = parent_dev_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: print "init error in Bluetooth device" self.set_property("data-device", port) self.set_property("devices-autoconf", True) MobileDevice.init_device(self) return True if parent_props.has_key("info.subsystem"): if parent_props["info.subsystem"] == "usb_device": if parent_props.has_key("info.product"): self.pretty_name = parent_props["info.product"] if self.pretty_name == "Bluetooth Host Controller Interface": self.pretty_name = "Bluetooth" self.set_property("data-device", port) self.set_property("devices-autoconf", True) self.set_property("device-icon", "bluetooth") MobileDevice.init_device(self) return True
def set_mode_domain(self, mode, domain): if mode == CARD_TECH_SELECTION_GPRS : res = self.send_at_command("AT!SELRAT=02") elif mode == CARD_TECH_SELECTION_UMTS : res = self.send_at_command("AT!SELRAT=01") elif mode == CARD_TECH_SELECTION_GRPS_PREFERED : res = self.send_at_command("AT!SELRAT=04") elif mode == CARD_TECH_SELECTION_UMTS_PREFERED : res = self.send_at_command("AT!SELRAT=03") elif mode == CARD_TECH_SELECTION_AUTO : res = self.send_at_command("AT!SELRAT=00") else: self.dbg_msg ("SET MODE DOMAIN : CRASH") return False self.dbg_msg ("SET MODE : %s" % res) if domain == CARD_DOMAIN_CS: real_domain = 00 elif domain == CARD_DOMAIN_PS: real_domain = 01 elif domain == CARD_DOMAIN_CS_PS : real_domain = 02 elif domain == CARD_DOMAIN_ANY: real_domain = 02 else: real_domain = 02 res = self.send_at_command("AT!SELMODE=%s" % real_domain) self.dbg_msg ("SET DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain)
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props["info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path") : files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB") : ports.append(f) ports.sort() print ports if len(ports) == 4 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.pretty_name = "Option" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def set_mode_domain(self, mode, domain): if mode == CARD_TECH_SELECTION_GPRS: res = self.send_at_command("AT!SELRAT=02") elif mode == CARD_TECH_SELECTION_UMTS: res = self.send_at_command("AT!SELRAT=01") elif mode == CARD_TECH_SELECTION_GRPS_PREFERED: res = self.send_at_command("AT!SELRAT=04") elif mode == CARD_TECH_SELECTION_UMTS_PREFERED: res = self.send_at_command("AT!SELRAT=03") elif mode == CARD_TECH_SELECTION_AUTO: res = self.send_at_command("AT!SELRAT=00") else: self.dbg_msg("SET MODE DOMAIN : CRASH") return False self.dbg_msg("SET MODE : %s" % res) if domain == CARD_DOMAIN_CS: real_domain = 00 elif domain == CARD_DOMAIN_PS: real_domain = 01 elif domain == CARD_DOMAIN_CS_PS: real_domain = 02 elif domain == CARD_DOMAIN_ANY: real_domain = 02 else: real_domain = 02 res = self.send_at_command("AT!SELMODE=%s" % real_domain) self.dbg_msg("SET DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain)
def set_mode_domain(self, mode, domain): rmode = None rdomain = None if mode == CARD_TECH_SELECTION_GPRS : rmode = "1" elif mode == CARD_TECH_SELECTION_UMTS : rmode = "2" elif mode == CARD_TECH_SELECTION_GRPS_PREFERED : rmode = "1" elif mode == CARD_TECH_SELECTION_UMTS_PREFERED : rmode = "2" elif mode == CARD_TECH_SELECTION_AUTO : rmode = "0" else: rmode = "0" if domain == CARD_DOMAIN_CS: rdomain = "0" elif domain == CARD_DOMAIN_PS: rdomain = "1" elif domain == CARD_DOMAIN_CS_PS : rdomain = "2" elif domain == CARD_DOMAIN_ANY: rdomain = "2" else: rdomain = "2" res = self.send_at_command("AT$NWRAT=%s,%s" % (rmode, rdomain)) self.dbg_msg ("SET DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain)
def init_device(self): ports = [] devices = self.hal_manager.GetAllDevices() for device in devices: device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.linux.driver" ) and props["info.linux.driver"] == "nozomi": if props.has_key("linux.sysfs_path"): files = os.listdir(props["linux.sysfs_path"] + "/tty") for f in files: if f.startswith("noz"): ports.append(f) ports.sort() print ports if len(ports) >= 3: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Option Nozomi" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def init_device(self): print 0 port = "/dev/rfcomm%s" % os.path.basename(self.dev_props["linux.sysfs_path"]).strip("hci") parent_dev_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", self.dev_props["info.parent"]) try: parent_props = parent_dev_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: print "init error in Bluetooth device" self.set_property("data-device", port) self.set_property("devices-autoconf", True) MobileDevice.init_device(self) return True if parent_props.has_key("info.subsystem") : if parent_props["info.subsystem"] == "usb_device" : if parent_props.has_key("info.product") : self.pretty_name = parent_props["info.product"] if self.pretty_name == "Bluetooth Host Controller Interface": self.pretty_name = "Bluetooth" self.set_property("data-device", port) self.set_property("devices-autoconf", True) self.set_property("device-icon", "bluetooth") MobileDevice.init_device(self) return True
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() device_udi = self.dev_props["info.udi"] for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device") : ports.append(os.path.basename(props["serial.device"])) ports = dict(map(lambda i: (i,1),ports)).keys() ports.sort() print ports dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) >= 3 : if dev == (0x7001, 0x1410) and len(ports) != 4 : return False if dev == (0x7001, 0x1410) : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) else: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Novatel" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: if dev == (0x7001, 0x1410) and len(ports) == 1 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[0][:-1] + str(int(ports[0][-1]) + 1)) print "data --> %s" % self.get_property("data-device") print "conf --> %s" % self.get_property("conf-device") self.set_property("device-icon", "network-wireless") self.pretty_name = "Novatel" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True return False
def __init__(self, mcontroller, dev_props): self.capabilities = [ AT_COMM_CAPABILITY, X_ZONE_CAPABILITY, SMS_CAPABILITY, ADDRESSBOOK_CAPABILITY, NO_OPTIONS_MENU ] self.device_port = None MobileDevice.__init__(self, mcontroller, dev_props)
def init_device(self): if self.device_port != None: self.set_property("data-device", self.device_port) self.set_property("devices-autoconf", True) MobileDevice.init_device(self) return True else: return False
def set_mode_domain(self, mode, domain): res = self.send_at_command("AT_OPSYS=%s,%s" % (mode,domain)) if res[2] == 'OK' : self.dbg_msg ("SET MODE DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain) return True else: self.dbg_msg ("SET MODE DOMAIN (CRASH) : %s" % res) return False
def set_mode_domain(self, mode, domain): res = self.send_at_command("AT_OPSYS=%s,%s" % (mode, domain)) if res[2] == 'OK': self.dbg_msg("SET MODE DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain) return True else: self.dbg_msg("SET MODE DOMAIN (CRASH) : %s" % res) return False
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props["info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path") : files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB"): ports.append(f) if len(ports) == 0 : device_udi = self.dev_props["info.udi"] for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device") : ports.append(os.path.basename(props["serial.device"])) ports = dict(map(lambda i: (i,1),ports)).keys() ports.sort() print "-------------> %s" % ports dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) >= 3 : if dev == (0x7501, 0xaf0) : self.set_property("data-device", "/dev/%s" % ports[3]) self.set_property("conf-device", "/dev/%s" % ports[2]) else: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Option" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def init_device(self): if self.device_port != None: self.set_property("data-device", self.dev_props["serial.device"] ) self.pretty_name = "Serial Port (%s or %s for Win users)" % (os.path.basename( self.dev_props["serial.device"]), "COM%i" % (int( self.dev_props["serial.device"][-1])+1)) self.set_property("devices-autoconf", True) MobileDevice.init_device(self) return True else: return False
def open_device(self): MobileDevice.open_device(self) res = self.send_at_command("AT^PORTSEL=1") if res[2] != "OK" : print "error opening huawei device" res = self.send_at_command("AT+COPS=3,0") if res[2] != "OK" : print "error opening huawei device"
def init_device(self): if self.device_port != None: self.set_property("data-device", self.device_port) self.set_property("conf-device", self.device_port) self.set_property("devices-autoconf", True) self.set_property("device-icon", "stock_cell-phone") #self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def init_device(self): if self.device_port != None: self.set_property("data-device", self.dev_props["serial.device"]) self.pretty_name = "Serial Port (%s or %s for Win users)" % ( os.path.basename(self.dev_props["serial.device"]), "COM%i" % (int(self.dev_props["serial.device"][-1]) + 1)) self.set_property("devices-autoconf", True) MobileDevice.init_device(self) return True else: return False
def init_device(self): ports = [] devices = self.hal_manager.GetAllDevices() device_udi = self.dev_props["info.udi"] for device in devices: device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device"): ports.append(os.path.basename(props["serial.device"])) ports = list(set(ports)) ports.sort() dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) >= 3: if dev == (0x68a3, 0x1199) and len(ports) >= 4: self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("data-device", "/dev/%s" % ports[3]) elif dev == (0x6890, 0x1199) and len(ports) >= 4: self.set_property("conf-device", "/dev/%s" % ports[3]) self.set_property("data-device", "/dev/%s" % ports[4]) else: self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("data-device", "/dev/%s" % ports[0]) print "data ------------> %s" % self.get_property("data-device") print "conf ------------> %s" % self.get_property("conf-device") self.set_property("device-icon", "network-wireless") self.pretty_name = "Sierra" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() device_udi = self.dev_props["info.udi"] for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device") : ports.append(os.path.basename(props["serial.device"])) ports = list(set(ports)) ports.sort() dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) >= 3 : if dev == (0x68a3,0x1199) and len(ports) >= 4 : self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("data-device", "/dev/%s" % ports[3]) elif dev == (0x6890,0x1199) and len(ports) >= 4 : self.set_property("conf-device", "/dev/%s" % ports[3]) self.set_property("data-device", "/dev/%s" % ports[4]) else: self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("data-device", "/dev/%s" % ports[0]) print "data ------------> %s" % self.get_property("data-device") print "conf ------------> %s" % self.get_property("conf-device") self.set_property("device-icon", "network-wireless") self.pretty_name = "Sierra" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def actions_on_open_port(self): ret = MobileDevice.actions_on_open_port(self) if ret == False : return False dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) self.serial.write("AT+CPMS?\r") self.dbg_msg ("Send : AT+CPMS?") attempts = 5 res = self.serial.readline() while attempts != 0 : self.dbg_msg ("Recv : %s" % res) if res == "OK" : break elif res == None : attempts = attempts - 1 res = self.serial.readline() if res != "OK" : self.dbg_msg ("ACTIONS ON OPEN PORT END FAILED--------") return False
def get_net_info(self): tech_in_use, card_mode, card_domain, carrier, carrier_mode = MobileDevice.get_net_info(self) if tech_in_use == CARD_TECH_UMTS : res = self.send_at_command("AT^SYSINFO", accept_null_response=False) self.dbg_msg ("SYSCFG (HSPA stuff) : %s" % res) if res[2] == 'OK' : tech = int(res[1][0][-1]) if tech >= 5 : tech_in_use = CARD_TECH_HSPA return tech_in_use, card_mode, card_domain, carrier, carrier_mode
def get_carrier(self): res = self.send_at_command("AT+COPS=3,2") self.dbg_msg("CHANGE TO NUMERIC FORMAT : %s" % res) carrier = MobileDevice.get_carrier(self) res = self.send_at_command("AT+COPS=3,0") self.dbg_msg("CHANGE TO STRING FORMAT : %s" % res) if carrier == "21407": return "movistar" else: return carrier
def set_mode_domain(self, mode, domain): if domain == CARD_DOMAIN_CS: real_domain = 0 elif domain == CARD_DOMAIN_PS: real_domain = 1 elif domain == CARD_DOMAIN_CS_PS : real_domain = 2 else: self.dbg_msg ("SET DOMAIN : (CRASH)") return False res = self.send_at_command("AT+ZCSPS=%s" % real_domain) if res[2] == 'OK' : self.dbg_msg ("SET DOMAIN : %s" % res) else: self.dbg_msg ("SET DOMAIN (CRASH) : %s" % res) return False if mode == CARD_TECH_SELECTION_GPRS : res = self.send_at_command("AT+ZSNT=1,0,0") elif mode == CARD_TECH_SELECTION_UMTS : res = self.send_at_command("AT+ZSNT=2,0,0") elif mode == CARD_TECH_SELECTION_GRPS_PREFERED : res = self.send_at_command("AT+ZSNT=0,0,1") elif mode == CARD_TECH_SELECTION_UMTS_PREFERED : res = self.send_at_command("AT+ZSNT=0,0,2") elif mode == CARD_TECH_SELECTION_AUTO : res = self.send_at_command("AT+ZSNT=0,0,0") else: self.dbg_msg ("SET MODE : CRASH") return False if res[2] == 'OK' : self.dbg_msg ("SET MODE : %s" % res) MobileDevice.set_mode_domain(self, mode, domain) return True else: self.dbg_msg ("SET MODE (CRASH) : %s" % res) return False
def init_device(self) : ports = [] devices = self.hal_manager.GetAllDevices() for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props["info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path") : files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB") : ports.append(f) ports.sort() print ports self.set_property("device-icon", "network-wireless") dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) == 4 : if dev == (0x66,0x19d2) or dev == (0x124, 0x19d2): self.set_property("data-device", "/dev/%s" % ports[3]) self.set_property("conf-device", "/dev/%s" % ports[1]) else: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.pretty_name = "ZTE" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def get_carrier(self): res = self.send_at_command("AT+COPS=3,2") self.dbg_msg ("CHANGE TO NUMERIC FORMAT : %s" % res) carrier = MobileDevice.get_carrier(self) res = self.send_at_command("AT+COPS=3,0") self.dbg_msg ("CHANGE TO STRING FORMAT : %s" % res) if carrier == "21407" : return "movistar" else: return carrier
def __init__(self, devId, connected=True): self._deviceId = devId self._device = dev = MobileDevice.AMDevice(devId) dev.connect() name = '' try: name = dev.get_value(name='DeviceName') except Exception as e: logging.exception(e) self.name = str(name, 'utf-8') print(self.name) self.id = dev.get_deviceid() self.connected = connected
def set_mode_domain(self, mode, domain): if domain == CARD_DOMAIN_CS: real_domain = 0 elif domain == CARD_DOMAIN_PS: real_domain = 1 elif domain == CARD_DOMAIN_CS_PS: real_domain = 2 elif domain == CARD_DOMAIN_ANY: real_domain = 3 else: real_domain = 2 if mode == CARD_TECH_SELECTION_GPRS: res = self.send_at_command("AT^SYSCFG=13,0,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_UMTS: res = self.send_at_command("AT^SYSCFG=14,0,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_GRPS_PREFERED: res = self.send_at_command("AT^SYSCFG=2,1,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_UMTS_PREFERED: res = self.send_at_command("AT^SYSCFG=2,2,3FFFFFFF,1,%s" % real_domain) elif mode == CARD_TECH_SELECTION_AUTO: res = self.send_at_command("AT^SYSCFG=2,0,3FFFFFFF,1,%s" % real_domain) else: self.dbg_msg("SET MODE DOMAIN : CRASH") return False if res[2] == 'OK': self.dbg_msg("SET MODE DOMAIN : %s" % res) MobileDevice.set_mode_domain(self, mode, domain) return True else: self.dbg_msg("SET MODE DOMAIN (CRASH) : %s" % res) return False
def actions_on_open_port(self): io = MobileDeviceIO(self.get_property("data-device")) io.open() io.write("AT$NWDMAT=1\r") self.dbg_msg ("Send to DATA PORT : AT$NWDMAT=1") attempts = 5 res = io.readline() while attempts != 0 : self.dbg_msg ("Recv to DATA PORT: %s" % res) if res == "OK" : break elif res == None : attempts = attempts - 1 res = io.readline() if res != "OK" : self.dbg_msg ("ACTIONS ON OPEN PORT END FAILED--------") io.close() return False io.close() ret = MobileDevice.actions_on_open_port(self) if ret == False : return False self.serial.write("AT\r") self.dbg_msg ("Send : AT") attempts = 5 res = self.serial.readline() while attempts != 0 : self.dbg_msg ("Recv : %s" % res) if res == "OK" : break elif res == None : attempts = attempts - 1 res = self.serial.readline() if res != "OK" : self.dbg_msg ("ACTIONS ON OPEN PORT END FAILED--------") return False self.dbg_msg ("ACTIONS ON OPEN PORT END --------") return True
def get_net_info(self): tech_in_use, card_mode, card_domain, carrier, carrier_mode = MobileDevice.get_net_info(self) if tech_in_use == CARD_TECH_UMTS : res = self.send_at_command("AT$CNTI=0", accept_null_response=False) self.dbg_msg ("AT$CNTI=0 (HSPA stuff) : %s" % res) tech = res[1][0] if res[2] == 'OK' : if "HSDPA" in tech : tech_in_use == CARD_TECH_HSDPA elif "HSUPA" in tech : tech_in_use = CARD_TECH_HSUPA return tech_in_use, card_mode, card_domain, carrier, carrier_mode
def get_net_info(self): tech_in_use, card_mode, card_domain, carrier, carrier_mode = MobileDevice.get_net_info( self) if tech_in_use == CARD_TECH_UMTS: res = self.send_at_command("AT*CNTI=0", accept_null_response=False) self.dbg_msg("AT*CNTI=0 (HSPA stuff) : %s" % res) tech = res[1][0] if res[2] == 'OK': if "HSDPA" in tech: tech_in_use == CARD_TECH_HSDPA elif "HSUPA" in tech: tech_in_use = CARD_TECH_HSUPA return tech_in_use, card_mode, card_domain, carrier, carrier_mode
def get_net_info(self): tech_in_use, card_mode, card_domain, carrier, carrier_mode = MobileDevice.get_net_info( self) if tech_in_use == CARD_TECH_UMTS: res = self.send_at_command("AT^SYSINFO", accept_null_response=False) self.dbg_msg("SYSCFG (HSPA stuff) : %s" % res) if res[2] == 'OK': tech = int(res[1][0][-1]) if tech == 5: tech_in_use = CARD_TECH_HSDPA elif tech == 6: tech_in_use = CARD_TECH_HSUPA elif tech == 7: tech_in_use = CARD_TECH_HSPA return tech_in_use, card_mode, card_domain, carrier, carrier_mode
def get_card_status(self): self.dbg_msg ("get_card_status init") if not self.is_on() : return CARD_STATUS_OFF pin_status = self.pin_status() if pin_status == None: return CARD_STATUS_ERROR if pin_status == PIN_STATUS_NO_SIM : return CARD_STATUS_NO_SIM if pin_status == PIN_STATUS_SIM_FAILURE : return CARD_STATUS_NO_SIM if pin_status == PIN_STATUS_WAITING_PIN : return CARD_STATUS_PIN_REQUIRED if pin_status == PIN_STATUS_WAITING_PUK: return CARD_STATUS_PUK_REQUIRED self.dbg_msg ("get_card_status init superclass") return MobileDevice.get_card_status(self)
def turn_on(self): ret = MobileDevice.turn_on(self) self.actions_on_open_port() return ret
def get_ussd_cmd(self, ussd_cmd, func): print "get_USSD_cmd (HUAWEI)" self.send_at_command("AT^PORTSEL=0") MobileDevice.get_ussd_cmd(self, ussd_cmd, func)
def turn_off(self): self.actions_on_open_port() return MobileDevice.turn_off(self)
def get_ussd_cmd_handler(self, fd, at_command, condition, func): ret = MobileDevice.get_ussd_cmd_handler(self, fd, at_command, condition, func) self.send_at_command("AT^PORTSEL=1") return ret
def __init__(self, mcontroller): self.capabilities = [] MobileDevice.__init__(self, mcontroller, {"info.udi": "NoneDevice"}) self.pretty_name = "NoneDevice"
def __init__(self, mcontroller, dev_props): self.capabilities = [] self.device_port = None MobileDevice.__init__(self, mcontroller, dev_props)
def init_device(self): ports = [] devices = self.hal_manager.GetAllDevices() for device in devices: device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props[ "info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path"): files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB"): ports.append(f) if len(ports) == 0: device_udi = self.dev_props["info.udi"] for device in devices: device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: return False device_tmp = props["info.udi"] if device_tmp.startswith(device_udi): if props.has_key("serial.device"): ports.append(os.path.basename(props["serial.device"])) ports = dict(map(lambda i: (i, 1), ports)).keys() ports.sort() print "-------------> %s" % ports dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) if len(ports) >= 3: if dev == (0x7501, 0xaf0): self.set_property("data-device", "/dev/%s" % ports[3]) self.set_property("conf-device", "/dev/%s" % ports[2]) else: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.set_property("device-icon", "network-wireless") self.pretty_name = "Option" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def getAppAFC(dev, appName): return MobileDevice.AFCApplicationDirectory(dev, appName)
def init_device(self): t0 = time.time() mainloop = gobject.MainLoop(is_running=True) context = mainloop.get_context() while time.time() - t0 <= 10.0: if context.pending(): context.iteration() ports = [] devices = self.hal_manager.GetAllDevices() for device in devices: device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties( dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props[ "info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path"): files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB"): ports.append(f) ports.sort() print ports dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) self.set_property("device-icon", "network-wireless") if (dev == (0x1004, 0x12d1) and len(ports) == 4) or (dev == (0x1001, 0x12d1) and len(ports) >= 3): self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1003, 0x12d1) and len(ports) >= 2: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1406, 0x12d1) and len(ports) >= 2: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1417, 0x12d1) and len(ports) >= 2: self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[3]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf: self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def actions_on_open_port(self): ret = MobileDevice.actions_on_open_port(self) if ret == False: return False dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) self.serial.write("ATZ\r") self.dbg_msg("Send : ATZ") attempts = 5 res = self.serial.readline() while attempts != 0: self.dbg_msg("Recv : %s" % res) if res == "OK": break elif res == None: attempts = attempts - 1 res = self.serial.readline() if res != "OK": self.dbg_msg("ACTIONS ON OPEN PORT END FAILED--------") return False self.serial.write("AT^PORTSEL=1\r") self.dbg_msg("Send : AT^PORTSEL=1") attempts = 5 res = self.serial.readline() while attempts != 0: self.dbg_msg("Recv : %s" % res) if res == "OK": break elif res == None: attempts = attempts - 1 res = self.serial.readline() if res != "OK": self.dbg_msg("ACTIONS ON OPEN PORT END FAILED--------") return False self.serial.write("AT+COPS=3,0\r") self.dbg_msg("Send : AT+COPS=3,0") attempts = 5 res = self.serial.readline() while attempts != 0: self.dbg_msg("Recv : %s" % res) if res == "OK" or res == "ERROR" or "ERROR" in res: break elif res == None: attempts = attempts - 1 res = self.serial.readline() if res == None: self.dbg_msg("ACTIONS ON OPEN PORT END FAILED--------") return False if dev == (0x1406, 0x12d1): self.serial.write("AT^CURC=0\r") self.dbg_msg("Send : AT^CURC") attempts = 5 res = self.serial.readline() while attempts != 0: self.dbg_msg("Recv : %s" % res) if res == "OK": break elif res == None: attempts = attempts - 1 res = self.serial.readline() if res != "OK": self.dbg_msg("ACTIONS ON OPEN PORT END FAILED--------") return False self.dbg_msg("ACTIONS ON OPEN PORT END --------") return True
def __init__(self, mcontroller): self.capabilities = [] MobileDevice.__init__(self, mcontroller, {"info.udi" : "NoneDevice"}) self.pretty_name="NoneDevice"
def init_device(self) : t0 = time.time() mainloop = gobject.MainLoop(is_running=True) context = mainloop.get_context() while time.time() - t0 <= 10.0 : if context.pending() : context.iteration() ports = [] devices = self.hal_manager.GetAllDevices() for device in devices : device_dbus_obj = self.dbus.get_object("org.freedesktop.Hal", device) try: props = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") except: return False if props.has_key("info.parent") and props["info.parent"] == self.dev_props["info.udi"]: if props.has_key("usb.linux.sysfs_path") : files = os.listdir(props["usb.linux.sysfs_path"]) for f in files: if f.startswith("ttyUSB") : ports.append(f) ports.sort() print ports dev = (self.dev_props["usb_device.product_id"], self.dev_props["usb_device.vendor_id"]) self.set_property("device-icon", "network-wireless") if (dev == (0x1004,0x12d1) and len(ports) == 4) or (dev == (0x1001,0x12d1) and len(ports) >= 3): self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[2]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1003,0x12d1) and len(ports) >= 2 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1406,0x12d1) and len(ports) >= 2 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[1]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True elif dev == (0x1417,0x12d1) and len(ports) >= 2 : self.set_property("data-device", "/dev/%s" % ports[0]) self.set_property("conf-device", "/dev/%s" % ports[3]) self.pretty_name = "Huawei" self.set_property("devices-autoconf", True) if not self.exists_conf : self.set_property("priority", "50") MobileDevice.init_device(self) return True else: return False
def turn_off(self): self.actions_on_reopen_port() return MobileDevice.turn_off(self)
def __init__(self, mcontroller, dev_props): self.capabilities = [] MobileDevice.__init__(self, mcontroller, dev_props)
def turn_on(self): ret = MobileDevice.turn_on(self) self.actions_on_reopen_port() return ret