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)); } while ((!done) && (--retry));
if (retry <= 0) { if (retry <= 0) {
sdStop(m_driver);
ret = -3; ret = -3;
} }
} }
/* switch to new baudrate? */ if (ret == 0) {
if (cfg.speed != baud) { /* switch to new baudrate? */
sdStop(m_driver); if (cfg.speed != baud) {
sdStop(m_driver);
if (ret == 0) { if (ret == 0) {
/* switch baudrate */ /* switch baudrate */
cfg.speed = baud; cfg.speed = baud;
sdStart(m_driver, &cfg); sdStart(m_driver, &cfg);
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
}
} }
} }
/* now reset BT to apply new settings */ if (ret == 0) {
chprintf((BaseSequentialStream *)m_driver, "AT+RESET\r\n"); /* now reset BT to apply new settings */
if (bt_wait_ok() != 0) { chprintf((BaseSequentialStream *)m_driver, "AT+RESET\r\n");
sdStop(m_driver); if (bt_wait_ok() != 0) {
ret = -4; 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 { } else {
/* Direct uart connetion */ /* Direct uart connetion */