GithubHelp home page GithubHelp logo

Comments (5)

codetheweb avatar codetheweb commented on June 4, 2024

Yeah, I'm not completely sure what the best solution is here. There's three possibilities:

  • Formatting is perfect, none of the padding renders as an ASCII character and numOfLeftBrackets == numOfRightBrackets
  • Random padding results in numOfLeftBrackets > numOfRightBrackets
  • Random padding results in numOfRightBrackets > numOfLeftBrackets

I'm not really sure what to do. One interesting thing to note is that I've never seen a } before the main payload, although that's most likely due to chance and not design.

The best way to parse returned data would be to simply start parsing at a certain index in the string like the actual device does, however this would add complexity as we would need to add the index to requests.json.

from tuyapi.

bobalob avatar bobalob commented on June 4, 2024

Is the message returned from the device encrypted or plain text?

from tuyapi.

codetheweb avatar codetheweb commented on June 4, 2024

The majority of the time it is returned in plain text. However, there seem to be a (very) few random times when it's returned encrypted. I have no idea what triggers this. If it's returned encrypted, a JSON error will be thrown.

from tuyapi.

ronyfadel avatar ronyfadel commented on June 4, 2024

@codetheweb for the moment, let's loop over min(rightBrackets, leftBrackets)? I hit the infinite loop with the following returned data (devID modified):

00 00 55 AA 00 00 00 00 00 00 00 0A 00 00 00 44 00 00 00 00 7B 22 64 65 76 49 64 22 3A 22 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 22 2C 22 64 70 73 22 3A 7B 22 31 22 3A 66 61 6C 73 65 2C 22 32 22 3A 30 7D 7D B6 7B 49 82 00 00 AA 55

which roughly translates to:

��U™������� ���D����{"devId":"dddddddddddddddddddd","dps":{"1":false,"2":0}}∂{IÇ��™U

Notice the extra '{' at the end.

from tuyapi.

codetheweb avatar codetheweb commented on June 4, 2024

Fixed.

from tuyapi.

Related Issues (20)

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.