1- local MSP_GPS_CONFIG = 135
21local MSP_VTX_CONFIG = 88
2+ local MSP_GPS_CONFIG = 135
33local MSP_OSD_CONFIG = 84
4- local MSP_BUILD_INFO = 5
54
6- local BUILD_OPTION_GPS = 16412
7- local BUILD_OPTION_OSD_SD = 16416
8- local BUILD_OPTION_VTX = 16421
5+ local MSP_RADIO_SETUP = 69
6+
7+ local BUILD_OPTION_VTX = bit32.lshift (1 , 0 )
8+ local BUILD_OPTION_GPS = bit32.lshift (1 , 1 )
9+ local BUILD_OPTION_OSD_SD = bit32.lshift (1 , 2 )
910
10- local isGpsRead = false
1111local isVtxRead = false
12+ local isGpsRead = false
1213local isOsdSDRead = false
1314
1415local lastRunTS = 0
@@ -20,29 +21,31 @@ local returnTable = {
2021 t = " " ,
2122}
2223
23- local function processBuildInfoReply (payload )
24- -- TODO: parse build options
24+ local function processRadioSetupReply (payload )
25+ isVtxRead = true
26+ isGpsRead = true
27+ isOsdSDRead = true
28+
29+ features .vtx = bit32.band (payload [1 ], BUILD_OPTION_VTX ) ~= 0
30+ features .gps = bit32.band (payload [1 ], BUILD_OPTION_GPS ) ~= 0
31+ features .osdSD = bit32.band (payload [1 ], BUILD_OPTION_OSD_SD ) ~= 0
2532end
2633
2734local function processMspReply (cmd , payload , err )
2835 isInFlight = false
2936 local isOkay = not err
30- if cmd == MSP_BUILD_INFO then
31- if not isOkay then
32- return
37+ if cmd == MSP_RADIO_SETUP then
38+ if isOkay then
39+ processRadioSetupReply ( payload )
3340 end
34- isGpsRead = true
41+ elseif cmd == MSP_VTX_CONFIG then
3542 isVtxRead = true
36- isOsdSDRead = true
37- processBuildInfoReply ( payload )
43+ local vtxTableAvailable = payload [ 12 ] ~= 0
44+ features . vtx = isOkay and vtxTableAvailable
3845 elseif cmd == MSP_GPS_CONFIG then
3946 isGpsRead = true
4047 local providerSet = payload [1 ] ~= 0
4148 features .gps = isOkay and providerSet
42- elseif cmd == MSP_VTX_CONFIG then
43- isVtxRead = true
44- local vtxTableAvailable = payload [12 ] ~= 0
45- features .vtx = isOkay and vtxTableAvailable
4649 elseif cmd == MSP_OSD_CONFIG then
4750 isOsdSDRead = true
4851 local osdSDAvailable = payload [1 ] ~= 0
@@ -55,14 +58,14 @@ local function updateFeatures()
5558 lastRunTS = getTime ()
5659 local cmd
5760 if apiVersion >= 1.47 then
58- cmd = MSP_BUILD_INFO
61+ cmd = MSP_RADIO_SETUP
5962 returnTable .t = " Checking options..."
60- elseif not isGpsRead then
61- cmd = MSP_GPS_CONFIG
62- returnTable .t = " Checking GPS..."
6363 elseif not isVtxRead then
6464 cmd = MSP_VTX_CONFIG
6565 returnTable .t = " Checking VTX..."
66+ elseif not isGpsRead then
67+ cmd = MSP_GPS_CONFIG
68+ returnTable .t = " Checking GPS..."
6669 elseif not isOsdSDRead then
6770 cmd = MSP_OSD_CONFIG
6871 returnTable .t = " Checking OSD (SD)..."
@@ -74,7 +77,7 @@ local function updateFeatures()
7477 end
7578 mspProcessTxQ ()
7679 processMspReply (mspPollReply ())
77- return isGpsRead and isVtxRead and isOsdSDRead
80+ return isVtxRead and isGpsRead and isOsdSDRead
7881end
7982
8083returnTable .f = updateFeatures
0 commit comments