Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huawei_lte_api.exceptions.ResponseErrorException: 9003: Unknown #211

Open
LaurentMarsan opened this issue May 14, 2024 Discussed in #208 · 3 comments
Open

huawei_lte_api.exceptions.ResponseErrorException: 9003: Unknown #211

LaurentMarsan opened this issue May 14, 2024 Discussed in #208 · 3 comments

Comments

@LaurentMarsan
Copy link

Discussed in #208

Originally posted by LaurentMarsan April 20, 2024
Hello
Just installed your lib, I'm trying to simply switch wifi on/off.
When switching on, everything ok (I red that you made it such a way to do nothing if already enabled), but when switching off, I get:

Traceback (most recent call last):
  File "setWifi.py", line 29, in <module>
    setWifi(0)
  File "setWifi.py", line 21, in setWifi
    if client.wlan.wifi_network_switch(val) == ResponseEnum.OK.value:
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/api/WLan.py", line 255, in wifi_network_switch
    return self.save_wlan_settings(items)
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/api/WLan.py", line 243, in save_wlan_settings
    return self.set_multi_basic_settings([item.to_dict() for item in settings])
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/api/WLan.py", line 112, in set_multi_basic_settings
    'WifiRestart': 1
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/Session.py", line 215, in post_set
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/Session.py", line 34, in wrapped
    return fn(*args, **kw)
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
  File "/home/pi/.local/lib/python3.7/site-packages/huawei_lte_api/Session.py", line 158, in _check_response_status
    error_code
huawei_lte_api.exceptions.ResponseErrorException: 9003: Unknown

Any idea? Something I made wrong?
Hardware is b525s-23a, btw.

Code used is

from huawei_lte_api.Connection import Connection
from huawei_lte_api.Client import Client
from huawei_lte_api.enums.client import ResponseEnum
from time import sleep

def setWifi(val):
    with Connection("http://192.168.8.1", username="admin", password="XXXXXXXXXXXXXXX") as connection:
        client = Client(connection)
        if client.wlan.wifi_network_switch(val) == ResponseEnum.OK.value:
            print('Wi-Fi was toggled successfully')
            return True
        else:
            print('Error')
            return False

if __name__=="__main__":
    setWifi(False)
    sleep(30)
    setWifi(True)
@Salamek
Copy link
Owner

Salamek commented Jun 14, 2024

Sorry i was not able to reproduce your issue on my B310s-22... you need to hunt this bug down on your own...
Check what request your webUI is making to the router in your browser dev tools -> network tab and compare that request to the request that huawei-lte-api is doing, see what is different and try to get it working. (I can't fix what i can't reproduce)

@LaurentMarsan
Copy link
Author

Thanks for your answer. I'm ok for a bug hunt, but I'm not an expert at all.
Could you please/
1/ give more details about the dev tool I should use (on Firefox, for instance)?
2/ which request should I try in my browser?
3/ how to compare this browser request to the request from huawei-lte-api?

@Salamek
Copy link
Owner

Salamek commented Jun 16, 2024

Hmm, it text i have provided in previous response did not help much... i think it will be better if you just dump the POST request for enable/disable. See this video on how to do that and send me both files (on my email that is in my github profile, one for disable POST request other for enable POST request). I'll do the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants