1
- local MSP_GPS_CONFIG = 135
2
1
local MSP_VTX_CONFIG = 88
2
+ local MSP_GPS_CONFIG = 135
3
3
local MSP_OSD_CONFIG = 84
4
- local MSP_BUILD_INFO = 5
5
4
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 )
9
10
10
- local isGpsRead = false
11
11
local isVtxRead = false
12
+ local isGpsRead = false
12
13
local isOsdSDRead = false
13
14
14
15
local lastRunTS = 0
@@ -20,29 +21,31 @@ local returnTable = {
20
21
t = " " ,
21
22
}
22
23
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
25
32
end
26
33
27
34
local function processMspReply (cmd , payload , err )
28
35
isInFlight = false
29
36
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 )
33
40
end
34
- isGpsRead = true
41
+ elseif cmd == MSP_VTX_CONFIG then
35
42
isVtxRead = true
36
- isOsdSDRead = true
37
- processBuildInfoReply ( payload )
43
+ local vtxTableAvailable = payload [ 12 ] ~= 0
44
+ features . vtx = isOkay and vtxTableAvailable
38
45
elseif cmd == MSP_GPS_CONFIG then
39
46
isGpsRead = true
40
47
local providerSet = payload [1 ] ~= 0
41
48
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
46
49
elseif cmd == MSP_OSD_CONFIG then
47
50
isOsdSDRead = true
48
51
local osdSDAvailable = payload [1 ] ~= 0
@@ -55,14 +58,14 @@ local function updateFeatures()
55
58
lastRunTS = getTime ()
56
59
local cmd
57
60
if apiVersion >= 1.47 then
58
- cmd = MSP_BUILD_INFO
61
+ cmd = MSP_RADIO_SETUP
59
62
returnTable .t = " Checking options..."
60
- elseif not isGpsRead then
61
- cmd = MSP_GPS_CONFIG
62
- returnTable .t = " Checking GPS..."
63
63
elseif not isVtxRead then
64
64
cmd = MSP_VTX_CONFIG
65
65
returnTable .t = " Checking VTX..."
66
+ elseif not isGpsRead then
67
+ cmd = MSP_GPS_CONFIG
68
+ returnTable .t = " Checking GPS..."
66
69
elseif not isOsdSDRead then
67
70
cmd = MSP_OSD_CONFIG
68
71
returnTable .t = " Checking OSD (SD)..."
@@ -74,7 +77,7 @@ local function updateFeatures()
74
77
end
75
78
mspProcessTxQ ()
76
79
processMspReply (mspPollReply ())
77
- return isGpsRead and isVtxRead and isOsdSDRead
80
+ return isVtxRead and isGpsRead and isOsdSDRead
78
81
end
79
82
80
83
returnTable .f = updateFeatures
0 commit comments