Skip to content

Commit

Permalink
Merge pull request #475 from klutvott123/skip-vtx-table
Browse files Browse the repository at this point in the history
Skip vtx tables download if not available
  • Loading branch information
haslinghuis authored Mar 13, 2023
2 parents 6676a11 + 61d3029 commit d900131
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 21 deletions.
9 changes: 3 additions & 6 deletions src/SCRIPTS/BF/MSP/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local MSP_STARTFLAG = bit32.lshift(1,4)
local mspSeq = 0
local mspRemoteSeq = 0
local mspRxBuf = {}
local mspRxError = false
local mspRxSize = 0
local mspRxCRC = 0
local mspRxReq = 0
Expand Down Expand Up @@ -65,17 +66,13 @@ end
function mspReceivedReply(payload)
local idx = 1
local status = payload[idx]
local err = bit32.btest(status, 0x80)
local version = bit32.rshift(bit32.band(status, 0x60), 5)
local start = bit32.btest(status, 0x10)
local seq = bit32.band(status, 0x0F)
idx = idx + 1
if err then
mspStarted = false
return nil
end
if start then
mspRxBuf = {}
mspRxError = bit32.btest(status, 0x80)
mspRxSize = payload[idx]
mspRxReq = mspLastReq
idx = idx + 1
Expand Down Expand Up @@ -117,7 +114,7 @@ function mspPollReply()
return nil
elseif mspReceivedReply(mspData) then
mspLastReq = 0
return mspRxReq, mspRxBuf
return mspRxReq, mspRxBuf, mspRxError
end
end
end
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/acc_cal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local accCalibrated = false
local lastRunTS = 0
local INTERVAL = 500

local function processMspReply(cmd,rx_buf)
if cmd == MSP_ACC_CALIBRATION then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_ACC_CALIBRATION and not err then
accCalibrated = true
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/api_version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local apiVersionReceived = false
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_API_VERSION and #rx_buf >= 3 then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_API_VERSION and #rx_buf >= 3 and not err then
apiVersion = rx_buf[2] + rx_buf[3] / 100
apiVersionReceived = true
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/board_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ local i2cRegisteredDeviceCount = 0
local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
if cmd == MSP_BOARD_INFO then
local function processMspReply(cmd, payload, err)
if cmd == MSP_BOARD_INFO and not err then
local length
local i = 1
length = 4
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/mcu_id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ local MCUIdReceived = false
local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
if cmd == MSP_UID then
local function processMspReply(cmd, payload, err)
if cmd == MSP_UID and not err then
local i = 1
local id = ""
for j = 1, 3 do
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/rssi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ local rssiSource = RSSI_SOURCE_NONE
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_TX_INFO and #rx_buf >= 1 then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_TX_INFO and #rx_buf >= 1 and not err then
rssiSource = rx_buf[1]
rssiSourceReceived = true
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/rtc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local timeIsSet = false
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_SET_RTC then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_SET_RTC and not err then
timeIsSet = true
end
end
Expand Down
5 changes: 4 additions & 1 deletion src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local function createPopupMenu()
end
end

local function processMspReply(cmd,rx_buf)
local function processMspReply(cmd,rx_buf,err)
if not Page or not rx_buf then
elseif cmd == Page.write then
if Page.eepromWrite then
Expand All @@ -109,6 +109,9 @@ local function processMspReply(cmd,rx_buf)
rebootFc()
end
invalidatePages()
elseif cmd == Page.read and err then
Page.fields = { { x = 6, y = radio.yMinLimit, value = "", ro = true } }
Page.labels = { { x = 6, y = radio.yMinLimit, t = "N/A" } }
elseif cmd == Page.read and #rx_buf > 0 then
Page.values = rx_buf
for i=1,#Page.fields do
Expand Down
15 changes: 13 additions & 2 deletions src/SCRIPTS/BF/vtx_tables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,26 @@ local requestedBand = 1
local requestedPowerLevel = 1
local vtxTableConfig = {}
local frequencyTable = {}
local frequenciesPerBand = 0
local bandTable = {}
local powerTable = {}

local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
local function processMspReply(cmd, payload, err)
if cmd == MSP_VTX_CONFIG then
if err then
-- Vtx not available. Create empty vtx table to skip future download attempts
frequencyTable[1] = {}
vtxTableConfig.channels = 0
bandTable = { [0] = "U", "1" }
powerTable = { "LV0" }
vtxConfigReceived = true
vtxTableAvailable = true
vtxFrequencyTableReceived = true
vtxPowerTableReceived = true
return
end
vtxConfigReceived = true
vtxTableAvailable = payload[12] ~= 0
vtxTableConfig.bands = payload[13]
Expand Down

0 comments on commit d900131

Please sign in to comment.