[gateway] Add property "model_id"

This commit is contained in:
remittor
2023-10-07 10:50:08 +03:00
parent f00200da5a
commit 791f1759ff
3 changed files with 8 additions and 3 deletions
+1 -3
View File
@@ -30,8 +30,6 @@ if gw.status < 1:
die("Xiaomi Mi Wi-Fi device not found (IP: {})".format(gw.ip_addr))
dn = gw.device_name
from xqmodel import get_modelid_by_name
model_id = get_modelid_by_name(dn)
#if dn in 'R2100 R2350 RM1800 RM2100 RA67':
# import connect2
@@ -53,7 +51,7 @@ model_id = get_modelid_by_name(dn)
# import connect4
# sys.exit(0)
if model_id < 0 or model_id >= get_modelid_by_name('R2100'):
if gw.model_id < 0 or gw.model_id >= gw.get_modelid_by_name('R2100'):
import connect5
sys.exit(0)
+6
View File
@@ -28,6 +28,7 @@ if sys.version_info < (3,8,0):
sys.exit(1)
from multiprocessing import shared_memory
import xqmodel
def die(*args):
@@ -62,6 +63,7 @@ class Gateway():
self.verbose = 2
self.timeout = 4
self.memcfg = None # shared memory "XMiR_12345"
self.model_id = -2
self.device_name = None
self.device_info = None
self.rom_version = None
@@ -84,6 +86,8 @@ class Gateway():
self.device_info = None
self.xqpassword = None
self.status = -2
self.xqModelList = xqmodel.xqModelList
self.get_modelid_by_name = xqmodel.get_modelid_by_name
self.init_memcfg(load_cfg)
atexit.register(self.shutdown)
atexit.register(self.free_memcfg)
@@ -99,6 +103,7 @@ class Gateway():
die("Can't found valid SSH server on IP {}".format(self.ip_addr))
def detect_device(self):
self.model_id = -2
self.device_name = None
self.device_info = None
self.rom_version = None
@@ -143,6 +148,7 @@ class Gateway():
pass
if not self.device_name:
die("You need to make the initial configuration in the WEB of the device!")
self.model_id = self.get_modelid_by_name(self.device_name, unk = True)
self.status = -1
x = r0.text.find('a href="/cgi-bin/luci/web/init/hello')
if (x > 10):
+1
View File
@@ -22,6 +22,7 @@ mi[18] = "R4CM"
mi[19] = "R4AC"
mi[20] = "R3GV2"
mi[21] = "R2600"
mi[22] = "R2100"
mi[23] = "RM2100"
mi[24] = "R3600"