fix: X7S BT detection (#3754)
* Add X7S BT detection * Compile fix * chore: remove obsolte section
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
#include "tasks.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
#include "bluetooth_driver.h"
|
||||
#endif
|
||||
|
||||
#if defined(LIBOPENUI)
|
||||
#include "libopenui.h"
|
||||
// #include "shutdown_animation.h"
|
||||
@@ -1078,6 +1082,12 @@ void opentxStart(const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS)
|
||||
|
||||
uint8_t calibration_needed = !(startOptions & OPENTX_START_NO_CALIBRATION) && (g_eeGeneral.chkSum != evalChkSum());
|
||||
|
||||
#if defined(BLUETOOTH_PROBE)
|
||||
extern volatile uint8_t btChipPresent;
|
||||
auto oldBtMode = g_eeGeneral.bluetoothMode;
|
||||
g_eeGeneral.bluetoothMode = BLUETOOTH_TELEMETRY;
|
||||
#endif
|
||||
|
||||
#if defined(GUI)
|
||||
if (!calibration_needed && !(startOptions & OPENTX_START_NO_SPLASH)) {
|
||||
AUDIO_HELLO();
|
||||
@@ -1114,6 +1124,12 @@ void opentxStart(const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS)
|
||||
PLAY_MODEL_NAME();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLUETOOTH_PROBE)
|
||||
if (bluetooth.localAddr[0] != '\0')
|
||||
btChipPresent = 1;
|
||||
g_eeGeneral.bluetoothMode = oldBtMode;
|
||||
#endif
|
||||
}
|
||||
|
||||
void opentxClose(uint8_t shutdown)
|
||||
|
||||
@@ -107,50 +107,6 @@ void bluetoothDisable()
|
||||
}
|
||||
}
|
||||
|
||||
// @Cliff
|
||||
// ISR is handled by the serial driver,
|
||||
// however, it is unclear at this point
|
||||
// how the detection should be implemented.
|
||||
// Maybe setting a temporary callback on
|
||||
// the interface, or trying to pull some data.
|
||||
//
|
||||
// Also, it is quite unclear why we would need
|
||||
// to disable sending when the TX buffer is exahausted.
|
||||
// The serial driver does take care of that but does not
|
||||
// set any particular piece of state that could be queried
|
||||
// to deduct the state of this TX buffer.
|
||||
#if _OBSOLETE_
|
||||
extern "C" void BT_USART_IRQHandler(void)
|
||||
{
|
||||
DEBUG_INTERRUPT(INT_BLUETOOTH);
|
||||
if (USART_GetITStatus(BT_USART, USART_IT_RXNE) != RESET) {
|
||||
USART_ClearITPendingBit(BT_USART, USART_IT_RXNE);
|
||||
uint8_t byte = USART_ReceiveData(BT_USART);
|
||||
btRxFifo.push(byte);
|
||||
#if defined(BLUETOOTH_PROBE)
|
||||
if (!btChipPresent) {
|
||||
// This is to differentiate X7 and X7S and X-Lite with/without BT
|
||||
btChipPresent = 1;
|
||||
bluetoothDisable();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USART_GetITStatus(BT_USART, USART_IT_TXE) != RESET) {
|
||||
uint8_t byte;
|
||||
bool result = btTxFifo.pop(byte);
|
||||
if (result) {
|
||||
USART_SendData(BT_USART, byte);
|
||||
}
|
||||
else {
|
||||
USART_ITConfig(BT_USART, USART_IT_TXE, DISABLE);
|
||||
// => BLUETOOTH_WRITE_IDLE
|
||||
bluetoothWriteState = BLUETOOTH_WRITE_DONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void bluetoothWrite(const void* buffer, uint32_t len)
|
||||
{
|
||||
if (!_bt_usart_ctx) return;
|
||||
|
||||
@@ -26,4 +26,5 @@ void bluetoothWrite(const void*, uint32_t) {}
|
||||
int bluetoothRead(uint8_t*) { return 0; }
|
||||
void bluetoothDisable() {}
|
||||
bool bluetoothIsWriting() { return false; }
|
||||
volatile uint8_t btChipPresent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user