These python pieces of code allow to interact with some huawei modems using their remote API.
For now it only deals with a very limited number of functions as the initial aim was to enable or disable some specific LTE band while staying in automatic mode (not being stuck in 4G mode) so that the modem is still able to switch to 2G/3G for traditional (non VoLTE) voice calls.
This code has been tested with a Huawei B525s-23a modem (firmware 11.236.01.00.1217 and Web UI 21.100.31.00.03). It may or may not work with other Huawei modems: I don't really know. Yet, I would be glad to hear about it and to accept some merge requests to extend its scope...
It is still some quick and dirty code but I share it hoping that it can be helpful to some people as I have not found a python module which fully worked out of the box with the Huawai B525s modem.
The module huawei_api itself can be easily extended and used for your own needs.
The core standalone cli utility is lteband. Full usage is available with
./lteband.py --help
usage: lteband.py [-h] [--enable ENABLE] [--disable DISABLE] [--user USER]
--password PASSWORD [--logfile LOGFILE]
[--loglevel {DEBUG,INFO,WARN,ERROR}] [--ip IP]
Enable or Disable a FDD Band
optional arguments:
-h, --help show this help message and exit
--enable ENABLE Band number to enable
--disable DISABLE Band number to disable
--user USER Username to log in
--password PASSWORD password to log in
--logfile LOGFILE Filename to save logs
--loglevel {DEBUG,INFO,WARN,ERROR}
loglevel
--ip IP Modem IP address
This tool allows to enable or disable a LTE band for some Huawei modems
For a standard installation (IP 192.168.8.1, admin user), the short invocation is as simple as:
# Disable B3 (1800Mhz), xxx being the modem password:
./lteband.py --disable 3 --password xxxxx
INFO:huawei-api:Detected Device: B525s-23a
INFO:lteband:The Modem supports the following LTE bands: LTE BC1/LTE BC3/LTE BC7/LTE BC8/LTE BC20/LTE BC32/LTE BC38
INFO:lteband:New network configuration sent, waiting 5s
INFO:lteband:Current Band: B7
INFO:lteband:RSRQ: -4dB
INFO:lteband:RSRP: -92dBm
INFO:lteband:RSSI: -69dBm
INFO:lteband:SINR: 11dB
Re-enabling the Band is as simple as:
# Enable B3, xxx being the modem password:
./lteband.py --enable 3 --password xxxxx
INFO:huawei-api:Detected Device: B525s-23a
INFO:lteband:The Modem supports the following LTE bands: LTE BC1/LTE BC3/LTE BC7/LTE BC8/LTE BC20/LTE BC32/LTE BC38
INFO:lteband:New network configuration sent, waiting 5s
INFO:lteband:Current Band: B7
INFO:lteband:RSRQ: -8dB
INFO:lteband:RSRP: -92dBm
INFO:lteband:RSSI: -61dBm
INFO:lteband:SINR: 10dB
These scripts require
Modules can be installed with pip:
pip install requests
pip install xmltodict
Many thanks to:
- Jari Turkia for his blog entry
- Marcin for his source code (especially SCRAM algorithm to login)
- Denis A. Fedorov for his source code which was a starting point