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

Fixes for 3DCM020200r015 firmware #289

Merged
merged 12 commits into from
Sep 6, 2024
Merged

Fixes for 3DCM020200r015 firmware #289

merged 12 commits into from
Sep 6, 2024

Conversation

epenet
Copy link
Collaborator

@epenet epenet commented Sep 5, 2024

Should fix #288

cc @AlexT59

@epenet epenet added the bug Something isn't working label Sep 5, 2024
@epenet
Copy link
Collaborator Author

epenet commented Sep 5, 2024

@AlexT59 are you able to run some extra tests to see if SFR Box v8 needs further tweaks?

@AlexT59
Copy link

AlexT59 commented Sep 5, 2024

I tried to run the example.py, the first step with the bug of the temperature seems fixed but I got the following exeption:

> python3 src/example.py
DEBUG:httpx:load_ssl_context verify=True cert=None trust_env=True http2=False
DEBUG:httpx:load_verify_locations cafile='/home/dev/.local/lib/python3.10/site-packages/certifi/cacert.pem'
DEBUG:httpcore.connection:connect_tcp.started host='192.168.1.1' port=80 local_address=None timeout=5.0 socket_options=None
DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f685724a7a0>
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'Ok', [(b'Server', b'micro_httpd'), (b'Cache-Control', b'no-cache'), (b'Date', b'Thu, 05 Sep 2024 14:18:00 GMT'), (b'Content-Type', b'text/xml; charset=utf-8'), (b'X-XSS-Protection', b'1; mode=block'), (b'X-Frame-Options', b'deny'), (b'Connection', b'close')])
INFO:httpx:HTTP Request: GET http://192.168.1.1/api/1.0/?method=system.getInfo "HTTP/1.1 200 Ok"
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete
DEBUG:sfrbox_api.bridge:HTTP Response: GET http://192.168.1.1/api/1.0/?method=system.getInfo "HTTP/1.1 200 Ok" <?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"><system product_id="ALGD1-UBE-r0" serial_number="MU1B01140006020043" mac_addr="***hidden***" net_mode="router" net_infra="fttb" uptime="1574768" version_mainfirmware="3DCM020200r015" version_rescuefirmware="3DCM020200r015" version_bootloader="3.00" version_dsldriver="" current_datetime="20240905161741" refclient="" idur="RNCUAOL" alimvoltage="12251" temperature="59.0" />
</rsp>

SystemInfo(product_id='ALGD1-UBE-r0', mac_addr='***hidden***', net_mode='router', net_infra='fttb', uptime=1574768, version_mainfirmware='3DCM020200r015', version_rescuefirmware='3DCM020200r015', version_bootloader='3.00', version_dsldriver='', current_datetime='20240905161741', refclient='', idur='RNCUAOL', alimvoltage=12251, temperature=59.0, serial_number='MU1B01140006020043')
DEBUG:httpcore.connection:connect_tcp.started host='192.168.1.1' port=80 local_address=None timeout=5.0 socket_options=None
DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f6857249030>
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'Ok', [(b'Server', b'micro_httpd'), (b'Cache-Control', b'no-cache'), (b'Date', b'Thu, 05 Sep 2024 14:18:00 GMT'), (b'Content-Type', b'text/xml; charset=utf-8'), (b'X-XSS-Protection', b'1; mode=block'), (b'X-Frame-Options', b'deny'), (b'Connection', b'close')])
INFO:httpx:HTTP Request: GET http://192.168.1.1/api/1.0/?method=dsl.getInfo "HTTP/1.1 200 Ok"
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete
DEBUG:sfrbox_api.bridge:HTTP Response: GET http://192.168.1.1/api/1.0/?method=dsl.getInfo "HTTP/1.1 200 Ok" <?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"><dsl linemode="G.DMT" uptime="4857" counter="1" crc="0" status="up" noise_down="4.5" noise_up="4.2" attenuation_down="3.2" attenuation_up="5.2" rate_down="8000" rate_up="800"
</firewall>
</rsp>

Traceback (most recent call last):
  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1713, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 2, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 111, in _check_response
    element: XmlElement = DefusedElementTree.fromstring(response.text)
  File "/home/dev/.local/lib/python3.10/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1715, in feed
    self._raiseerror(v)
  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1622, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 2, column 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/dev/GIT/sfrbox-api/src/example.py", line 33, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/dev/GIT/sfrbox-api/src/example.py", line 23, in main
    print(await box.dsl_get_info())
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 168, in dsl_get_info
    xml_response = await self._send_get("dsl", "getInfo")
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 51, in wrapper
    return await func(*args, **kwargs)
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 143, in _send_get
    element = self._check_response(response)
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 113, in _check_response
    raise SFRBoxError(f"Failed to parse response: {response.text}") from exc
sfrbox_api.exceptions.SFRBoxError: Failed to parse response: <?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"><dsl linemode="G.DMT" uptime="4857" counter="1" crc="0" status="up" noise_down="4.5" noise_up="4.2" attenuation_down="3.2" attenuation_up="5.2" rate_down="8000" rate_up="800"
</firewall>
</rsp>

@epenet
Copy link
Collaborator Author

epenet commented Sep 5, 2024

Wow! That seems to be a bug on the box: the return is not a valid XML!
It is mixing dsl element name and firewall element closure.

<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok" version="1.0">
  <dsl linemode="G.DMT" uptime="4857" counter="1" crc="0" status="up" noise_down="4.5" noise_up="4.2" attenuation_down="3.2" attenuation_up="5.2" rate_down="8000" rate_up="800"
  </firewall>
</rsp>

@epenet epenet changed the title Fix temperature parsing for float values Fixes for firmware 3DCM020200r015 Sep 5, 2024
@epenet
Copy link
Collaborator Author

epenet commented Sep 5, 2024

Please try again with this workaround

@epenet epenet changed the title Fixes for firmware 3DCM020200r015 Fixes for 3DCM020200r015 firmware Sep 5, 2024
@AlexT59
Copy link

AlexT59 commented Sep 5, 2024

Thanks for your fix, seems to work great !

But there is another error ^^

Here is the traceback:

INFO:httpx:HTTP Request: GET http://192.168.1.1/api/1.0/?method=ftth.getInfo "HTTP/1.1 200 Ok"
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete
DEBUG:sfrbox_api.bridge:HTTP Response: GET http://192.168.1.1/api/1.0/?method=ftth.getInfo "HTTP/1.1 200 Ok" <?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"></rsp>

Traceback (most recent call last):
  File "/home/dev/GIT/sfrbox-api/src/example.py", line 33, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/dev/GIT/sfrbox-api/src/example.py", line 25, in main
    print(await box.ftth_get_info())
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 179, in ftth_get_info
    xml_response = await self._send_get("ftth", "getInfo")
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 52, in wrapper
    return await func(*args, **kwargs)
  File "/home/dev/GIT/sfrbox-api/src/sfrbox_api/bridge.py", line 152, in _send_get
    raise SFRBoxError(
sfrbox_api.exceptions.SFRBoxError: Namespace ftth not found in response: <?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"></rsp>

When I try to open http://192.168.1.1/api/1.0/?method=ftth.getInfo in my browser I got this answer:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rsp stat="ok" version="1.0">
<script id="nimlmejbmnecnaghgmbahmbaddhjbecg"/>
<script/>
<script/>
</rsp>

@epenet
Copy link
Collaborator Author

epenet commented Sep 6, 2024

New version ready to be tried again...

@AlexT59
Copy link

AlexT59 commented Sep 6, 2024

Seems ok, thanks

@epenet epenet merged commit c05ec4f into main Sep 6, 2024
16 of 17 checks passed
@epenet epenet deleted the 20240905-1455 branch September 6, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Temperature type conflict - Unknown error occurred - haos
2 participants