camcamfresh / Xiaomi-M365-BLE-Controller-Replacement

Replacing the BLE Controller with a Cellular Controller
142 stars 34 forks source link

Is there specific reason to send same command multiple time? #23

Closed kyuhyong closed 5 years ago

kyuhyong commented 5 years ago

In void escControl(), I see sending same command repeatedly here. https://github.com/camcamfresh/Xiaomi-M365-BLE-Controller-Replacement/blob/2dd581ccc5f5c46db6ae40c149a34edba7d66131/MotorControl#L68 Is this for making sure the serial messages not being lost anyway? Also, why does it need to have motor, and motor1 messages at the same time even though they all look the same. Thanks,

Kyu

camcamfresh commented 5 years ago

motor is sent 4 times in an effort to mimic the factory controller.

motor1 is very similar to motor because it is the same message but also requests the motor controller to send data back to the microcontroller (the x1 structure).

motor is sent more often than motor1 because the brake and throttle values need to be sent to the motor controller every few milliseconds, whereas we only need replies from the motor controller every few hundred milliseconds.

kyuhyong commented 5 years ago

Thank you for such a kind explanation.