Code Monkey home page Code Monkey logo

huawai-api's Introduction

Introduction

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.

Usage

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

Installation

These scripts require

Modules can be installed with pip:

pip install requests
pip install xmltodict

Thanks

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

huawai-api's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.