mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Merge pull request #7461 from fujin/smartaudio-21-compat
SmartAudio: Handle SA2.1 GET SETTINGS response.
This commit is contained in:
commit
8c0e5d81e0
1 changed files with 11 additions and 3 deletions
|
@ -86,7 +86,8 @@ enum {
|
||||||
SA_CMD_SET_CHAN,
|
SA_CMD_SET_CHAN,
|
||||||
SA_CMD_SET_FREQ,
|
SA_CMD_SET_FREQ,
|
||||||
SA_CMD_SET_MODE,
|
SA_CMD_SET_MODE,
|
||||||
SA_CMD_GET_SETTINGS_V2 = 0x09 // Response only
|
SA_CMD_GET_SETTINGS_V2 = 0x09, // Response only
|
||||||
|
SA_CMD_GET_SETTINGS_V21 = 0x11,
|
||||||
} smartAudioCommand_e;
|
} smartAudioCommand_e;
|
||||||
|
|
||||||
// This is not a good design; can't distinguish command from response this way.
|
// This is not a good design; can't distinguish command from response this way.
|
||||||
|
@ -149,7 +150,7 @@ static uint8_t saLockMode = SA_MODE_SET_UNLOCK; // saCms variable?
|
||||||
bool saDeferred = true; // saCms variable?
|
bool saDeferred = true; // saCms variable?
|
||||||
|
|
||||||
// Receive frame reassembly buffer
|
// Receive frame reassembly buffer
|
||||||
#define SA_MAX_RCVLEN 11
|
#define SA_MAX_RCVLEN 15
|
||||||
static uint8_t sa_rbuf[SA_MAX_RCVLEN+4]; // XXX delete 4 byte guard
|
static uint8_t sa_rbuf[SA_MAX_RCVLEN+4]; // XXX delete 4 byte guard
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -276,7 +277,9 @@ static void saProcessResponse(uint8_t *buf, int len)
|
||||||
|
|
||||||
if (resp == sa_outstanding) {
|
if (resp == sa_outstanding) {
|
||||||
sa_outstanding = SA_CMD_NONE;
|
sa_outstanding = SA_CMD_NONE;
|
||||||
} else if ((resp == SA_CMD_GET_SETTINGS_V2) && (sa_outstanding == SA_CMD_GET_SETTINGS)) {
|
} else if ((resp == SA_CMD_GET_SETTINGS_V2 ||
|
||||||
|
resp == SA_CMD_GET_SETTINGS_V21) &&
|
||||||
|
(sa_outstanding == SA_CMD_GET_SETTINGS)) {
|
||||||
sa_outstanding = SA_CMD_NONE;
|
sa_outstanding = SA_CMD_NONE;
|
||||||
} else {
|
} else {
|
||||||
saStat.ooopresp++;
|
saStat.ooopresp++;
|
||||||
|
@ -284,17 +287,22 @@ static void saProcessResponse(uint8_t *buf, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (resp) {
|
switch (resp) {
|
||||||
|
case SA_CMD_GET_SETTINGS_V21: // Version 2.1 Get Settings
|
||||||
case SA_CMD_GET_SETTINGS_V2: // Version 2 Get Settings
|
case SA_CMD_GET_SETTINGS_V2: // Version 2 Get Settings
|
||||||
case SA_CMD_GET_SETTINGS: // Version 1 Get Settings
|
case SA_CMD_GET_SETTINGS: // Version 1 Get Settings
|
||||||
if (len < 7) {
|
if (len < 7) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX(fujin): For now handle V21 saDevice.version as '2'.
|
||||||
|
// From spec: "Bit 7-3 is holding the Smart audio version where 0 is V1, 1 is V2, 2 is V2.1"
|
||||||
|
// saDevice.version = buf[0];
|
||||||
saDevice.version = (buf[0] == SA_CMD_GET_SETTINGS) ? 1 : 2;
|
saDevice.version = (buf[0] == SA_CMD_GET_SETTINGS) ? 1 : 2;
|
||||||
saDevice.channel = buf[2];
|
saDevice.channel = buf[2];
|
||||||
saDevice.power = buf[3];
|
saDevice.power = buf[3];
|
||||||
saDevice.mode = buf[4];
|
saDevice.mode = buf[4];
|
||||||
saDevice.freq = (buf[5] << 8)|buf[6];
|
saDevice.freq = (buf[5] << 8)|buf[6];
|
||||||
|
// XXX(fujin): Receive additional SA2.1 fields here for dBm based power level.
|
||||||
|
|
||||||
DEBUG_SET(DEBUG_SMARTAUDIO, 0, saDevice.version * 100 + saDevice.mode);
|
DEBUG_SET(DEBUG_SMARTAUDIO, 0, saDevice.version * 100 + saDevice.mode);
|
||||||
DEBUG_SET(DEBUG_SMARTAUDIO, 1, saDevice.channel);
|
DEBUG_SET(DEBUG_SMARTAUDIO, 1, saDevice.channel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue