Bluetooth fixes (reconnection issues, telemetry mode not working) (#5186)
Bluetooth fixes (reconnection issues, telemetry mode not working)
This commit is contained in:
@@ -95,8 +95,11 @@ enum MenuModelSetupItems {
|
||||
#if defined(PCBX7)
|
||||
ITEM_MODEL_TRAINER_LABEL,
|
||||
ITEM_MODEL_TRAINER_MODE,
|
||||
ITEM_MODEL_TRAINER_LINE1,
|
||||
ITEM_MODEL_TRAINER_LINE2,
|
||||
#if defined(BLUETOOTH)
|
||||
ITEM_MODEL_TRAINER_BLUETOOTH,
|
||||
#endif
|
||||
ITEM_MODEL_TRAINER_CHANNELS,
|
||||
ITEM_MODEL_TRAINER_PARAMS,
|
||||
#endif
|
||||
ITEM_MODEL_SETUP_MAX
|
||||
};
|
||||
@@ -153,13 +156,15 @@ enum MenuModelSetupItems {
|
||||
|
||||
#if defined(PCBX7)
|
||||
#if defined(BLUETOOTH)
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothFriend[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)1 : (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_LINE1_BLUETOOTH_M_ROWS : (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH ? (uint8_t)1 : HIDDEN_ROW)))
|
||||
#define TRAINER_BLUETOOTH_M_ROW ((bluetoothDistantAddr[0] == '\0' || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_BLUETOOTH_S_ROW (bluetoothDistantAddr[0] == '\0' ? HIDDEN_ROW : LABEL())
|
||||
#define TRAINER_BLUETOOTH_ROW (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW)),
|
||||
#else
|
||||
#define TRAINER_LINE1_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)1 : HIDDEN_ROW)
|
||||
#define TRAINER_BLUETOOTH_ROW
|
||||
#endif
|
||||
#define TRAINER_LINE2_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
|
||||
#define TRAINER_ROWS LABEL(Trainer), 0, TRAINER_LINE1_ROWS, TRAINER_LINE2_ROWS
|
||||
#define TRAINER_CHANNELS_ROW (IS_SLAVE_TRAINER() ? (uint8_t)1 : HIDDEN_ROW)
|
||||
#define TRAINER_PARAMS_ROW (IS_SLAVE_TRAINER() ? (uint8_t)2 : HIDDEN_ROW)
|
||||
#define TRAINER_ROWS LABEL(Trainer), 0, TRAINER_BLUETOOTH_ROW TRAINER_CHANNELS_ROW, TRAINER_PARAMS_ROW
|
||||
#else
|
||||
#define TRAINER_ROWS
|
||||
#endif
|
||||
@@ -803,22 +808,21 @@ void menuModelSetup(event_t event)
|
||||
#if defined(BLUETOOTH)
|
||||
if (checkIncDec_Ret) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7)
|
||||
case ITEM_MODEL_TRAINER_LINE1:
|
||||
#if defined(BLUETOOTH)
|
||||
#if defined(PCBX7) && defined(BLUETOOTH)
|
||||
case ITEM_MODEL_TRAINER_BLUETOOTH:
|
||||
if (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH) {
|
||||
if (attr) {
|
||||
s_editMode = 0;
|
||||
}
|
||||
if (bluetoothFriend[0]) {
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetoothFriend, TINSIZE);
|
||||
if (bluetoothDistantAddr[0]) {
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetoothDistantAddr, TINSIZE);
|
||||
if (bluetoothState != BLUETOOTH_STATE_CONNECTED) {
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, BUTTON("Bind"), menuHorizontalPosition == 0 ? attr : 0);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+5*FW, y, BUTTON("Clear"), menuHorizontalPosition == 1 ? attr : 0);
|
||||
@@ -829,7 +833,7 @@ void menuModelSetup(event_t event)
|
||||
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
if (bluetoothState == BLUETOOTH_STATE_CONNECTED || menuHorizontalPosition == 1) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
else {
|
||||
bluetoothState = BLUETOOTH_STATE_BIND_REQUESTED;
|
||||
@@ -849,11 +853,19 @@ void menuModelSetup(event_t event)
|
||||
bluetoothState = BLUETOOTH_STATE_DISCOVER_REQUESTED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
else {
|
||||
if (bluetoothDistantAddr[0])
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetoothDistantAddr, TINSIZE);
|
||||
else
|
||||
lcdDrawText(INDENT_WIDTH, y, "---");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, bluetoothState == BLUETOOTH_STATE_CONNECTED ? "Connected" : "!Connected");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7)
|
||||
case ITEM_MODEL_TRAINER_CHANNELS:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_CHANNELS:
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
@@ -889,7 +901,7 @@ void menuModelSetup(event_t event)
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7)
|
||||
case ITEM_MODEL_TRAINER_LINE2:
|
||||
case ITEM_MODEL_TRAINER_PARAMS:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_BIND:
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
|
||||
@@ -113,6 +113,8 @@ enum MenuRadioHardwareItems {
|
||||
ITEM_RADIO_HARDWARE_SH,
|
||||
#if defined(BLUETOOTH)
|
||||
ITEM_RADIO_HARDWARE_BLUETOOTH_MODE,
|
||||
ITEM_RADIO_HARDWARE_BLUETOOTH_LOCAL_ADDR,
|
||||
ITEM_RADIO_HARDWARE_BLUETOOTH_DISTANT_ADDR,
|
||||
ITEM_RADIO_HARDWARE_BLUETOOTH_NAME,
|
||||
#endif
|
||||
ITEM_RADIO_HARDWARE_JITTER_FILTER,
|
||||
@@ -122,7 +124,7 @@ enum MenuRadioHardwareItems {
|
||||
#define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#if defined(BLUETOOTH)
|
||||
#define BLUETOOTH_ROWS 0, uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? -1 : 0),
|
||||
#define BLUETOOTH_ROWS 0, uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : 0),
|
||||
#else
|
||||
#define BLUETOOTH_ROWS
|
||||
#endif
|
||||
@@ -214,6 +216,16 @@ void menuRadioHardware(event_t event)
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_HARDWARE_BLUETOOTH_LOCAL_ADDR:
|
||||
lcdDrawTextAlignedLeft(y, INDENT "Local addr");
|
||||
lcdDrawText(HW_SETTINGS_COLUMN2, y, bluetoothLocalAddr[0] == '\0' ? "---" : bluetoothLocalAddr);
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_HARDWARE_BLUETOOTH_DISTANT_ADDR:
|
||||
lcdDrawTextAlignedLeft(y, INDENT "Dist addr");
|
||||
lcdDrawText(HW_SETTINGS_COLUMN2, y, bluetoothDistantAddr[0] == '\0' ? "---" : bluetoothDistantAddr);
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_HARDWARE_BLUETOOTH_NAME:
|
||||
lcdDrawText(INDENT_WIDTH, y, STR_NAME);
|
||||
editName(HW_SETTINGS_COLUMN2, y, g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME, event, attr);
|
||||
|
||||
@@ -242,7 +242,7 @@ int getSwitchWarningsCount()
|
||||
#define PORT_CHANNELS_ROWS(x) (x==INTERNAL_MODULE ? INTERNAL_MODULE_CHANNELS_ROWS : (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : 1))
|
||||
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothFriend[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothDistantAddr[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)1 : (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_LINE1_BLUETOOTH_M_ROWS : (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH ? (uint8_t)1 : HIDDEN_ROW)))
|
||||
#define TRAINER_LINE2_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
|
||||
#else
|
||||
@@ -724,7 +724,7 @@ void menuModelSetup(event_t event)
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
if (attr && checkIncDec_Ret) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@@ -829,8 +829,8 @@ void menuModelSetup(event_t event)
|
||||
if (attr) {
|
||||
s_editMode = 0;
|
||||
}
|
||||
if (bluetoothFriend[0]) {
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetoothFriend, TINSIZE);
|
||||
if (bluetoothDistantAddr[0]) {
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetoothDistantAddr, TINSIZE);
|
||||
if (bluetoothState != BLUETOOTH_STATE_CONNECTED) {
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, BUTTON("Bind"), menuHorizontalPosition == 0 ? attr : 0);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+5*FW, y, BUTTON("Clear"), menuHorizontalPosition == 1 ? attr : 0);
|
||||
@@ -841,7 +841,7 @@ void menuModelSetup(event_t event)
|
||||
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
if (bluetoothState == BLUETOOTH_STATE_CONNECTED || menuHorizontalPosition == 1) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
else {
|
||||
bluetoothState = BLUETOOTH_STATE_BIND_REQUESTED;
|
||||
|
||||
@@ -233,7 +233,7 @@ int getSwitchWarningsCount()
|
||||
#define POT_WARN_ITEMS() ((g_model.potsWarnMode) ? uint8_t(NAVIGATION_LINE_BY_LINE|(NUM_POTS-1)) : (uint8_t)0)
|
||||
#define SLIDER_WARN_ITEMS() ((g_model.potsWarnMode) ? uint8_t(NAVIGATION_LINE_BY_LINE|(NUM_SLIDERS-1)) : (uint8_t)0)
|
||||
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothFriend[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothDistantAddr[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)1 : (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_LINE1_BLUETOOTH_M_ROWS : (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH ? (uint8_t)1 : HIDDEN_ROW)))
|
||||
#define TRAINER_LINE2_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
|
||||
|
||||
@@ -649,7 +649,7 @@ bool menuModelSetup(event_t event)
|
||||
g_model.trainerMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_VTRAINERMODES, g_model.trainerMode, 0, TRAINER_MODE_MAX(), attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -750,8 +750,8 @@ bool menuModelSetup(event_t event)
|
||||
if (attr) {
|
||||
s_editMode = 0;
|
||||
}
|
||||
if (bluetoothFriend[0]) {
|
||||
lcdDrawText(MENUS_MARGIN_LEFT + INDENT_WIDTH, y, bluetoothFriend);
|
||||
if (bluetoothDistantAddr[0]) {
|
||||
lcdDrawText(MENUS_MARGIN_LEFT + INDENT_WIDTH, y, bluetoothDistantAddr);
|
||||
if (bluetoothState != BLUETOOTH_STATE_CONNECTED) {
|
||||
drawButton(MODEL_SETUP_2ND_COLUMN, y, "Bind", menuHorizontalPosition == 0 ? attr : 0);
|
||||
drawButton(MODEL_SETUP_2ND_COLUMN+60, y, "Clear", menuHorizontalPosition == 1 ? attr : 0);
|
||||
@@ -762,7 +762,7 @@ bool menuModelSetup(event_t event)
|
||||
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
if (bluetoothState == BLUETOOTH_STATE_CONNECTED || menuHorizontalPosition == 1) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothFriend[0] = 0;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
}
|
||||
else {
|
||||
bluetoothState = BLUETOOTH_STATE_BIND_REQUESTED;
|
||||
|
||||
@@ -587,6 +587,10 @@ bool isTrainerModeAvailable(int mode)
|
||||
{
|
||||
if (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
|
||||
return false;
|
||||
#if defined(BLUETOOTH)
|
||||
else if (g_eeGeneral.bluetoothMode != BLUETOOTH_TRAINER && (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_SLAVE_BLUETOOTH))
|
||||
return false;
|
||||
#endif
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user