scooterhacking / NinebotCrypto

An implementation of the NinebotCrypto protocol by majsi.
GNU Affero General Public License v3.0
42 stars 15 forks source link

[Swift] Crash if deviceName less then 12 symbols #2

Open ILYA2606 opened 4 years ago

ILYA2606 commented 4 years ago

Crash if deviceName less then 12 symbols. GoKart, for example.
NBScooter0915 is works, but user can change bluetooth name with official app.

Example with livedata command:

image image
nopbxlr commented 4 years ago

Hello, Since I couldn't reproduce the issue on the original C# version of the lib (implemented in Ninebot IAP), I can safely assume that this issue is Swift specific.

I have no idea about Swift though, so hopefully the contributor who ported it will pitch in and help! @robbiet480

robbiet480 commented 4 years ago

Thanks for the ping @lothean-dev

Sadly @ILYA2606 you are gonna be on your own for this one because I'm not actively using this code anymore (I stopped working on the project entirely). @lothean-dev is right that if its not happening in the C# code it must be a translation issue with my Swift code. Perhaps you can try playing with the at argument of the insert and see if you can insert at the end instead?

ILYA2606 commented 4 years ago

@robbiet480 @lothean-dev Thanks for response! I fix it by adding zero bytes in deviceName.
While you are here, tell me if I understand correctly:
1) deviceName is bluetooth name? NBScooter0915, for example 2) Ninebot ES live data command for encryption is 5A A5 01 3E 20 01 B0 20 CF FE? Don't need to increase the package size?

robbiet480 commented 4 years ago
  1. I believe that is correct, yes.
  2. You would want to ask @lothean-dev or @majsi
robbiet480 commented 3 years ago

@ILYA2606 If you’ve fixed the issues, it would be really appreciated if you contributed the fixes back to this repo. Thanks!

LexNastin commented 8 months ago

Shouldn't be waking a 3+ year old thread, BUT this issue among others in the Swift implementation are closed by #12 :D