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

viomi: Fix map issues (hopefully) #819

Merged
merged 2 commits into from
Apr 10, 2021
Merged

Conversation

depau
Copy link
Contributor

@depau depau commented Apr 9, 2021

This PR includes my Kaitai struct for the Viomi map, + some fixes I was able to figure out thanks to it.

The previous map implementation was expecting the segment outlines to be at an earlier offset, causing it to read garbage as the number of segments and eventually end up overflowing.

I was not able to figure out the mysterious chunk yet, but since all data seems to loosely stick to a TLV (tag-length-value) format, and since the tag seems to always be an 8 byte value, with the first 4 byte being always the same for maps generated by the same device, I just save these 4 bytes and then use them to scan for the next section.


Testing

Viomi owners, please test this and let me know if it works for you. If you still get no map or you see map parsing-related errors in the log, please:

  • Edit the config file, under debug enable enableDebugCapability.
    [...]
      "debug": {
        "memoryStatInterval": false,
        "enableDebugCapability": true
      }
    [...]
  • Restart valetudo
  • Install valetudo with the changes from this PR
    git clone https://github.com/Depau/Valetudo.git
    cd Valetudo
    git checkout viomi-map
    # Do your thing, build and send it to the robot
  • Use the following script to fetch the map from Valetudo
  • Send it to me on Telegram together with
    • A screenshot of the map
    • The number of segments
    • Firmware version and vacuum model as reported by the script
    • The status of the device when the map was retrieved (docked, idle, docked/idle but after a recent clean)
    • If possible, please also send a second map sample right after rebooting the device while it's idle and docked

Script:

#!/bin/sh
source /etc/YMsave01/os-release
source /etc/miio/device.conf
echo "Firmware version: $VIOMI_VERSION"
echo "Vacuum model: $model"

nc 127.0.0.1 80 > /mnt/UDISK/map.json << EOF
PUT /api/v2/robot/capabilities/DebugCapability
Host: localhost
Content-Type: application/json
Connection: close
Content-Length: 22

{"action": "last_map"}
EOF
echo "Downloaded last map to /mnt/UDISK/map.json"

nc 127.0.0.1 80 > /mnt/UDISK/map_err.json << EOF
PUT /api/v2/robot/capabilities/DebugCapability
Host: localhost
Content-Type: application/json
Connection: close
Content-Length: 26

{"action": "last_err_map"}
EOF
echo "Downloaded last error map to /mnt/UDISK/map_err.json"

@Hypfer Hypfer merged commit 07a1c7a into Hypfer:master Apr 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants