Merge from 2.3
This commit is contained in:
@@ -20,31 +20,7 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
class Pxx2Telemetry
|
||||
{
|
||||
protected:
|
||||
static void processGetHardwareInfoFrame(uint8_t module, uint8_t *frame);
|
||||
|
||||
static void processReceiverSettingsFrame(uint8_t module, uint8_t *frame);
|
||||
|
||||
static void processRegisterFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processBindFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processTelemetryFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processSpectrumFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processRadioFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processPowerMeterFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
static void processAuthenticationFrame(uint8_t module, uint8_t * frame);
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
void processGetHardwareInfoFrame(uint8_t module, uint8_t * frame)
|
||||
void processGetHardwareInfoFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_GET_HARDWARE_INFO) {
|
||||
return;
|
||||
@@ -59,6 +35,11 @@ void processGetHardwareInfoFrame(uint8_t module, uint8_t * frame)
|
||||
memcpy(&destination->information, &frame[4], length);
|
||||
if (destination->information.capabilities & ~((1 << MODULE_CAPABILITY_COUNT) - 1))
|
||||
destination->information.capabilityNotSupported = true;
|
||||
if (!globalData.upgradeModulePopup && destination->information.modelID == PXX2_MODULE_ISRM_S_X10S &&
|
||||
destination->information.swVersion.major == 0 && destination->information.swVersion.minor == 1 && destination->information.swVersion.revision < 5) {
|
||||
globalData.upgradeModulePopup = 1;
|
||||
POPUP_WARNING(STR_MODULE_UPGRADE_ALERT);
|
||||
}
|
||||
}
|
||||
else if (index < PXX2_MAX_RECEIVERS_PER_MODULE && modelId < DIM(PXX2ReceiversNames)) {
|
||||
memcpy(&destination->receivers[index].information, &frame[4], length);
|
||||
@@ -68,7 +49,7 @@ void processGetHardwareInfoFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processModuleSettingsFrame(uint8_t module, uint8_t * frame)
|
||||
void processModuleSettingsFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_MODULE_SETTINGS) {
|
||||
return;
|
||||
@@ -88,7 +69,7 @@ void processModuleSettingsFrame(uint8_t module, uint8_t * frame)
|
||||
moduleState[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
|
||||
void processReceiverSettingsFrame(uint8_t module, uint8_t * frame)
|
||||
void processReceiverSettingsFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_RECEIVER_SETTINGS) {
|
||||
return;
|
||||
@@ -116,7 +97,7 @@ void processReceiverSettingsFrame(uint8_t module, uint8_t * frame)
|
||||
moduleState[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
|
||||
void processRegisterFrame(uint8_t module, uint8_t * frame)
|
||||
void processRegisterFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_REGISTER) {
|
||||
return;
|
||||
@@ -151,7 +132,7 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processBindFrame(uint8_t module, uint8_t * frame)
|
||||
void processBindFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_BIND) {
|
||||
return;
|
||||
@@ -202,7 +183,7 @@ void processBindFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processResetFrame(uint8_t module, uint8_t * frame)
|
||||
void processResetFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_RESET) {
|
||||
return;
|
||||
@@ -215,7 +196,7 @@ void processResetFrame(uint8_t module, uint8_t * frame)
|
||||
moduleState[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
|
||||
void processTelemetryFrame(uint8_t module, uint8_t * frame)
|
||||
void processTelemetryFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
uint8_t origin = (module << 2) + (frame[3] & 0x03);
|
||||
if (origin != TELEMETRY_ENDPOINT_SPORT) {
|
||||
@@ -224,13 +205,16 @@ void processTelemetryFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
|
||||
#if defined(ACCESS_LIB) && !defined(SIMU)
|
||||
void processAuthenticationFrame(uint8_t module, uint8_t * frame)
|
||||
void processAuthenticationFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
uint8_t cryptoType = frame[3];
|
||||
uint8_t messageDigest[16] = {0};
|
||||
|
||||
if (frame[0] == 4 && PXX2_AUTH_REFUSED_FLAG == frame[4]) {
|
||||
POPUP_INFORMATION(STR_AUTH_FAILURE);
|
||||
if (!globalData.upgradeModulePopup) {
|
||||
globalData.upgradeModulePopup = 1;
|
||||
POPUP_INFORMATION(STR_AUTH_FAILURE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,12 +225,22 @@ void processAuthenticationFrame(uint8_t module, uint8_t * frame)
|
||||
intmoduleSendBuffer(pxx2.getData(), pxx2.getSize());
|
||||
// we remain in AUTHENTICATION mode to avoid a CHANNELS frame is sent at the end of the mixing process
|
||||
}
|
||||
|
||||
if (!globalData.upgradeModulePopup) {
|
||||
if (globalData.authenticationCount >= 2) {
|
||||
globalData.upgradeModulePopup = 1;
|
||||
POPUP_WARNING(STR_MODULE_UPGRADE_ALERT);
|
||||
}
|
||||
else {
|
||||
globalData.authenticationCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define processAuthenticationFrame(module, frame)
|
||||
#endif
|
||||
|
||||
void processSpectrumAnalyserFrame(uint8_t module, uint8_t * frame)
|
||||
void processSpectrumAnalyserFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_SPECTRUM_ANALYSER) {
|
||||
return;
|
||||
@@ -273,7 +267,7 @@ void processSpectrumAnalyserFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processPowerMeterFrame(uint8_t module, uint8_t * frame)
|
||||
void processPowerMeterFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_POWER_METER) {
|
||||
return;
|
||||
@@ -285,7 +279,7 @@ void processPowerMeterFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processOtaUpdateFrame(uint8_t module, uint8_t * frame)
|
||||
void processOtaUpdateFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_OTA_UPDATE) {
|
||||
return;
|
||||
@@ -311,7 +305,7 @@ void processOtaUpdateFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processModuleFrame(uint8_t module, uint8_t *frame)
|
||||
void processModuleFrame(uint8_t module, const uint8_t *frame)
|
||||
{
|
||||
switch (frame[2]) {
|
||||
case PXX2_TYPE_ID_HW_INFO:
|
||||
@@ -348,7 +342,7 @@ void processModuleFrame(uint8_t module, uint8_t *frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processToolsFrame(uint8_t module, uint8_t * frame)
|
||||
void processToolsFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
switch (frame[2]) {
|
||||
case PXX2_TYPE_ID_POWER_METER:
|
||||
@@ -361,8 +355,13 @@ void processToolsFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processPXX2Frame(uint8_t module, uint8_t *frame)
|
||||
void processPXX2Frame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
LOG_TELEMETRY_WRITE_START();
|
||||
for (uint8_t i = 0; i < 1 + frame[0]; i++) {
|
||||
LOG_TELEMETRY_WRITE_BYTE(frame[i]);
|
||||
}
|
||||
|
||||
switch (frame[1]) {
|
||||
case PXX2_TYPE_C_MODULE:
|
||||
processModuleFrame(module, frame);
|
||||
|
||||
Reference in New Issue
Block a user