From 2bc71b18feb1aabb8182659cd4918d6538e6fc02 Mon Sep 17 00:00:00 2001 From: remittor Date: Sun, 7 Nov 2021 14:53:30 +0300 Subject: [PATCH] Add support device rm2100 (Redmi AC2100) --- connect.py | 13 +++++++++---- connect2.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 connect2.py diff --git a/connect.py b/connect.py index de1b7dc..1cbc87a 100644 --- a/connect.py +++ b/connect.py @@ -30,8 +30,13 @@ gw = gateway.Gateway(timeout = 4) if gw.status < 1: die("Xiaomi Mi Wi-Fi device not found (IP: {})".format(ip_addr)) -dname = gw.device_name -if dname == 'r3600' or dname == 'rb03': +dn = gw.device_name + +if dn == 'rm2100': + import connect2 + sys.exit(0) + +if dn == 'r3600' or dn == 'rb03': import connect3 sys.exit(0) @@ -65,9 +70,9 @@ fn_pf2 = dn_tmp + fn_pfname + '_02' fn_pf3 = dn_tmp + fn_pfname + '_03' fn_suffix = '_mips' -if dname == 'r3d': +if dn == 'r3d': fn_suffix = '_armv7a' -if dname == "rb03": +if dn == "rb03": fn_suffix = '_arm64' fn_pf = dn_dir + fn_pfname + fn_suffix diff --git a/connect2.py b/connect2.py new file mode 100644 index 0000000..700dad8 --- /dev/null +++ b/connect2.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import sys +import types +import platform +import ctypes +import binascii +import re +import requests +import urllib + +sys.path.append(os.path.dirname(os.path.abspath(__file__))) +from gateway import * + + +gw = Gateway(timeout = 4) +if gw.status < 1: + die("Xiaomi Mi Wi-Fi device not found (IP: {})".format(gw.ip_addr)) + +print("device_name =", gw.device_name) +print("rom_version = {} {}".format(gw.rom_version, gw.rom_channel)) +print("mac address = {}".format(gw.mac_address)) + +gw.ssh_port = 22 +if gw.ping(verbose = 0) is True: + die(0, "Stock SSH server already installed and running") + +stok = gw.web_login() + +def exec_cmd(cmd): + params = { 'bssid': 'Xiaomi', 'user_id': user_id, 'ssid': ('-h' + '\n' + cmd + '\n') } + res = requests.get(gw.apiurl + "set_config_iotdev", params = params) + +exec_cmd('nvram set ssh_en=1; nvram commit;') +exec_cmd('echo -e "root\\nroot" | passwd root') +exec_cmd("sed -i 's/channel=.*/channel=\"debug\"/g' /etc/init.d/dropbear") +exec_cmd("/etc/init.d/dropbear stop") +exec_cmd("/etc/init.d/dropbear start") + +time.sleep(0.5) +gw.ping() + +print("") +print("#### Connection to device {} is OK ####".format(gw.device_name)) +