Package: huawei-modem-api-client
Python HTTP API client for Huawei ModemsThis is a python library to interact with a Huawei modem over HTTP API.The library has been tested on these devices:E5180E8372B315B529s-23aH122-373 (HUAWEI 5G CPE Pro 2 locoked to the UK Network Three)Please let me know if you tested it successfully with other modems as well.Currently Supportedwebserverget_session_token_info: gets a session token to useuserlogin: creates a new session on the HTTP APIlogout: deletes current session on the HTTP APIsmsget_sms: get information from boxes: inbox, outboxsend_sms: sends an SMS through device's modemdelete_sms: deletes an sms from one of their boxessms_count: get the sms count on each boxsms_set_read: set the sms status to readussdstatus: get status of ussd. This will tell you if there are ussd messages available to readsend: sends a ussd messageget: retrieves a ussd messagewlan:get_connected_hosts: gets a list of connected devicesblock_host: blocks the device from networkunblock_host: unblock device on networkget_blocked_hosts: gets a list of blocked devicesis_host_blocked: checks if device is blockedswitch_wlan_24ghz: allows to switch on or off the wlan 2.4Ghz module of the routerswitch_wlan_5ghz: allows to switch on or off the wlan 5Ghz module of the routerdialup:connect_mobile: enables mobile (ie LTE / 4G / 3G / etc) networkdisconnect_mobile: disables mobile networkget_mobile_status: checks the mobile connection statusdevice:reboot: reboots the modemPrerequisitesrequestslibrary (and its dependencies) is required.sixlibrary (and its dependencies for Python 2 and 3 compatibility)typinglibrary (support for type hints)This isrequirements.txtcontent:requests>=2.25.1
six>=1.15.0
typing>=3.7.4.3Installingpipinstallhuawei-modem-api-clientExampleimporthuaweisms.api.userimporthuaweisms.api.wlanimporthuaweisms.api.smsctx=huaweisms.api.user.quick_login("myusername","mypassword")print(ctx)# output: <ApiCtx modem_host=192.168.8.1># sending smshuaweisms.api.sms.send_sms(ctx,'phone-number','this is the sms message')# connected devicesdevice_list=huaweisms.api.wlan.get_connected_hosts(ctx)Note: The default modem host is assumed to be192.168.8.1. If that is not the case for you, you can specify your modem ip as follows:importhuaweisms.api.userctx=huaweisms.api.user.quick_login("myusername","mypassword",modem_host='10.11.12.13')print(ctx)#output: <ApiCtx modem_host=10.11.12.13>HTTPS ExamplesWhen the router uses HTTPS instead of HTTP, you can pass theuri_schemewhen creating the context instance which
becomes used on subsequent api calls that use the same context.importhuaweisms.api.userctx=huaweisms.api.user.quick_login('username','password',modem_host='192.168.12.13',uri_scheme='https')If the router that uses HTTPS uses self-signed certificates, there will be SSL errors. You can ignore certificate
validation/verification as follows:importhuaweisms.api.userctx=huaweisms.api.user.quick_login('username','password',modem_host='192.168.12.13',uri_scheme='https',verify=False)Built Withrequests- Python HTTP Requests for Humans™ContributingSend me a PM if you want to contribute.AuthorsPablo Santa Cruz-Owner-pabloMka Madlavana-Collaborator-dopstarLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details