Skip to content

Commit

Permalink
Use MSP_BOARD_INFO if available (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomgomba committed Feb 2, 2024
1 parent 7a845bc commit a34582b
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/SCRIPTS/BF/features_info.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
local MSP_GPS_CONFIG = 135
local MSP_VTX_CONFIG = 88
local MSP_OSD_CONFIG = 84
local MSP_BOARD_INFO = 0

local BUILD_OPTION_GPS = 16412
local BUILD_OPTION_OSD_SD = 16416
local BUILD_OPTION_VTX = 16421

local isGpsRead = false
local isVtxRead = false
Expand All @@ -15,10 +20,38 @@ local returnTable = {
t = "",
}

local function processBuildInfoReply(payload)
local dateLength = 11
local timeLength = 8
local revisionLength = 7
local offset = 1
local firstIndex = dateLength + timeLength + revisionLength + offset
local option = payload[firstIndex]
while option do
if option == BUILD_OPTION_GPS then
features.gps = true
elseif option == BUILD_OPTION_OSD_SD then
features.osdSD = true
elseif option == BUILD_OPTION_VTX then
features.vtx = true
end
offset = offset + 1
option = payload[firstIndex + offset]
end
end

local function processMspReply(cmd, payload, err)
isInFlight = false
local isOkay = not err
if cmd == MSP_GPS_CONFIG then
if cmd == MSP_BOARD_INFO then
if not isOkay then
return
end
isGpsRead = true
isVtxRead = true
isOsdSDRead = true
processBuildInfoReply(payload)
elseif cmd == MSP_GPS_CONFIG then
isGpsRead = true
local providerSet = payload[1] ~= 0
features.gps = isOkay and providerSet
Expand All @@ -37,7 +70,10 @@ local function updateFeatures()
if lastRunTS + INTERVAL < getTime() then
lastRunTS = getTime()
local cmd
if not isGpsRead then
if apiVersion >= 1.47 then
cmd = MSP_BOARD_INFO
returnTable.t = "Checking options..."
elseif not isGpsRead then
cmd = MSP_GPS_CONFIG
returnTable.t = "Checking GPS..."
elseif not isVtxRead then
Expand Down

0 comments on commit a34582b

Please sign in to comment.