Merge with latest 2.3

This commit is contained in:
Bertrand Songis
2020-01-08 16:35:30 +01:00
91 changed files with 1139 additions and 860 deletions
+18 -14
View File
@@ -21,6 +21,10 @@
#include "opentx.h"
#include "io/frsky_firmware_update.h"
#if defined(LOG_BLUETOOTH)
extern FIL g_bluetoothFile;
#endif
#if defined(PCBX9E)
#define BLUETOOTH_COMMAND_NAME "TTM:REN-"
#define BLUETOOTH_ANSWER_NAME "TTM:REN"
@@ -44,9 +48,9 @@ Bluetooth bluetooth;
void Bluetooth::write(const uint8_t * data, uint8_t length)
{
TRACE_NOCRLF("BT>");
BLUETOOTH_TRACE("BT>");
for (int i=0; i<length; i++) {
TRACE_NOCRLF(" %02X", data[i]);
BLUETOOTH_TRACE(" %02X", data[i]);
while (btTxFifo.isFull()) {
if (!bluetoothIsWriting())
bluetoothWriteWakeup();
@@ -54,13 +58,13 @@ void Bluetooth::write(const uint8_t * data, uint8_t length)
}
btTxFifo.push(data[i]);
}
TRACE_NOCRLF("\r\n");
BLUETOOTH_TRACE(CRLF);
bluetoothWriteWakeup();
}
void Bluetooth::writeString(const char * str)
{
TRACE("BT> %s", str);
BLUETOOTH_TRACE("BT> %s" CRLF, str);
while (*str != 0) {
btTxFifo.push(*str++);
}
@@ -77,19 +81,19 @@ char * Bluetooth::readline(bool error_reset)
if (!btRxFifo.pop(byte)) {
#if defined(PCBX9E)
// X9E BT module can get unresponsive
TRACE("NO RESPONSE FROM BT MODULE");
BLUETOOTH_TRACE("NO RESPONSE FROM BT MODULE" CRLF);
#endif
return nullptr;
}
TRACE_NOCRLF("%02X ", byte);
BLUETOOTH_TRACE("%02X ", byte);
#if 0
if (error_reset && byte == 'R' && bufferIndex == 4 && memcmp(buffer, "ERRO", 4)) {
#if defined(PCBX9E) // X9E enter BT reset loop if following code is implemented
TRACE("BT Error...");
BLUETOOTH_TRACE("BT Error..." CRLF);
#else
TRACE("BT Reset...");
BLUETOOTH_TRACE("BT Reset..." CRLF);
bufferIndex = 0;
bluetoothDisable();
state = BLUETOOTH_STATE_OFF;
@@ -104,12 +108,12 @@ char * Bluetooth::readline(bool error_reset)
if (bufferIndex > 2 && buffer[bufferIndex-1] == '\r') {
buffer[bufferIndex-1] = '\0';
bufferIndex = 0;
TRACE("BT< %s", buffer);
BLUETOOTH_TRACE("BT< %s" CRLF, buffer);
if (error_reset && !strcmp((char *)buffer, "ERROR")) {
#if defined(PCBX9E) // X9E enter BT reset loop if following code is implemented
TRACE("BT Error...");
BLUETOOTH_TRACE("BT Error..." CRLF);
#else
TRACE("BT Reset...");
BLUETOOTH_TRACE("BT Reset..." CRLF);
bluetoothDisable();
state = BLUETOOTH_STATE_OFF;
wakeupTime = get_tmr10ms() + 100; /* 1s */
@@ -137,7 +141,7 @@ char * Bluetooth::readline(bool error_reset)
void Bluetooth::processTrainerFrame(const uint8_t * buffer)
{
TRACE("");
BLUETOOTH_TRACE(CRLF);
for (uint8_t channel=0, i=1; channel<8; channel+=2, i+=3) {
// +-500 != 512, but close enough.
@@ -155,7 +159,7 @@ void Bluetooth::appendTrainerByte(uint8_t data)
// we check for "DisConnected", but the first byte could be altered (if received in state STATE_DATA_XOR)
if (data == '\n') {
if (!strncmp((char *)&buffer[bufferIndex-13], "isConnected", 11)) {
TRACE("BT< DisConnected");
BLUETOOTH_TRACE("BT< DisConnected" CRLF);
state = BLUETOOTH_STATE_DISCONNECTED;
bufferIndex = 0;
wakeupTime += 200; // 1s
@@ -285,7 +289,7 @@ void Bluetooth::receiveTrainer()
return;
}
TRACE_NOCRLF("%02X ", byte);
BLUETOOTH_TRACE("%02X ", byte);
processTrainerByte(byte);
}