Skip to content

Commit

Permalink
Use MSP_BUILD_INFO if >= MSP 1.47
Browse files Browse the repository at this point in the history
  • Loading branch information
atomgomba committed Mar 17, 2024
1 parent 1067f8b commit 4a7ec40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/SCRIPTS/BF/features.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local features = {
vtx = true,
gps = true,
osdSD = true,
vtx = true,
gps = true,
osdSD = true,
blackbox = true,
}

return features
24 changes: 19 additions & 5 deletions src/SCRIPTS/BF/features_info.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local MSP_GPS_CONFIG = 135
local MSP_VTX_CONFIG = 88
local MSP_OSD_CONFIG = 84

local MSP_BUILD_INFO = 5

local BUILD_OPTION_GPS = 16412
Expand All @@ -21,20 +22,33 @@ local returnTable = {
}

local function processBuildInfoReply(payload)
-- TODO: parse build options
features.gps = false
features.vtx = false
features.osdSD = false
for i=1,#payload,2 do
local byte1 = payload[i]
local byte2 = payload[i + 1]
local word = bit32.bor(bit32.arshift(byte1, -8), byte2)
if word == BUILD_OPTION_GPS then
features.gps = true
elseif word == BUILD_OPTION_OSD_SD then
features.osdSD = true
elseif word == BUILD_OPTION_VTX then
features.vtx = true
end
end
end

local function processMspReply(cmd, payload, err)
isInFlight = false
local isOkay = not err
if cmd == MSP_BUILD_INFO then
if not isOkay then
return
end
isGpsRead = true
isVtxRead = true
isOsdSDRead = true
processBuildInfoReply(payload)
if isOkay then
processBuildInfoReply(payload)
end
elseif cmd == MSP_GPS_CONFIG then
isGpsRead = true
local providerSet = payload[1] ~= 0
Expand Down

0 comments on commit 4a7ec40

Please sign in to comment.