TS: serial: do not disable serial after failed BT init attemp (#231)

Instead enable it on default baudrate and wait for direct connection

(cherry picked from commit 4f2aa57bee6a50195768ffb0e7d7d2ff374048e4)

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
rusefillc 2023-04-20 14:22:59 -04:00 committed by GitHub
parent 2f90b66fdb
commit 21202975b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 13 deletions

View File

@ -191,28 +191,39 @@ int SerialTsChannel::reStart() {
} while ((!done) && (--retry));
if (retry <= 0) {
sdStop(m_driver);
ret = -3;
}
}
/* switch to new baudrate? */
if (cfg.speed != baud) {
sdStop(m_driver);
if (ret == 0) {
/* switch to new baudrate? */
if (cfg.speed != baud) {
sdStop(m_driver);
if (ret == 0) {
/* switch baudrate */
cfg.speed = baud;
sdStart(m_driver, &cfg);
if (ret == 0) {
/* switch baudrate */
cfg.speed = baud;
sdStart(m_driver, &cfg);
chThdSleepMilliseconds(10);
chThdSleepMilliseconds(10);
}
}
}
/* now reset BT to apply new settings */
chprintf((BaseSequentialStream *)m_driver, "AT+RESET\r\n");
if (bt_wait_ok() != 0) {
sdStop(m_driver);
ret = -4;
if (ret == 0) {
/* now reset BT to apply new settings */
chprintf((BaseSequentialStream *)m_driver, "AT+RESET\r\n");
if (bt_wait_ok() != 0) {
sdStop(m_driver);
ret = -4;
}
}
if (ret < 0) {
/* set requested baudrate and wait for direct uart connection */
cfg.speed = baud;
sdStart(m_driver, &cfg);
}
} else {
/* Direct uart connetion */