YeelightController icon indicating copy to clipboard operation
YeelightController copied to clipboard

Hey Think I get the problem.

Open TrevisGordan opened this issue 7 years ago • 2 comments

Hey. Me again. I got the code to Build. (y). I think I see the problem. Unfortunately, I don't speak a "Line" SWIFT, but i have an idea how you can fix it. Here is what I would do:

Create a global counter in the readReplay function. (Every time it gets called ++...)

Now every time you get responses store it before you parse it. ( or If the first replay is always readable - read it. - but with the counter you always know how often it ran)

if the readReaply runs the second time. Store the data again. Then compare both replays. (as a string, or len or whatever suits you. Then you can validate the Reply. and only parse the reply you need. ;) this is at least what I would do in python :D

TrevisGordan avatar Apr 07 '18 22:04 TrevisGordan

Yeah, I think that this solution should work. Of course, with this solution, we aren't able to manage multiple bulb (that is not my problem) but I will try to implement this logic in the future!

alessandro308 avatar Apr 12 '18 09:04 alessandro308

I was thinking another solution. Execute a separate thread that reads only the incoming connections. Parse and store the messages received in a queue. Then the main thread, if there are new incoming messages, process them and update the interface. Do you think that this works?

alessandro308 avatar Apr 25 '18 10:04 alessandro308