blakadder / nspanel

Sonoff NSPanel protocol and hacking information. Tasmota Berry driver for NSPanel
https://blakadder.github.io/nspanel/
Creative Commons Zero v1.0 Universal
131 stars 36 forks source link

bug in split_55() ? #18

Open peepshow-21 opened 2 years ago

peepshow-21 commented 2 years ago

  def split_55(b)
    var ret = []
    var s = size(b)   
    var i = s-1   # start from last
    while i > 0
      if b[i] == 0x55 && b[i+1] == 0xAA           
        ret.push(b[i..s-1]) # push last msg to list
        b = b[(0..i-1)]   # write the rest back to b
      end
      i -= 1
    end
    ret.push(b)
    return ret
  end

should be like this i think;

        ret.push(b[(i+2)..s-1]) # push last msg to list

I think it needs that or the split message will still have the split chars in the messsage

blakadder commented 2 years ago

you think or you're certain? what kind of testing makes you think that?

peepshow-21 commented 2 years ago

I don't use that file, I have my own based on that. I noticed it there because it sent 2 messages. The stock screen can send multiple messages and your script splits them with 0x55aa, which is correct. but when you split you are leaving the separator in the message. so I'm 90% sure it will be wrong. instead of being "{ blah blah json..}" it will be "0x55aa{ blah blah json }". I made that change to mine to fix mine, so I think it would be needed in yours. but I'm not using stock anymore so not really able to test. Just giving you the heads up in case you wanted to check.

On Sun, 30 Jan 2022 at 20:33, blakadder @.***> wrote:

you think or you're certain? what kind of testing makes you think that?

— Reply to this email directly, view it on GitHub https://github.com/blakadder/nspanel/issues/18#issuecomment-1025224953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKBSYTCDBPFXO3NDT2THMQLUYWOC7ANCNFSM5NEN6RIQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>