File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,18 @@ local MSP_SET_RTC = 246
33local MSP_TX_INFO = 186
44
55local lastRunTS
6+ local sensorId = - 1
67local timeIsSet = false
78local mspMsgQueued = false
89
9- local function modelActive ()
10- local telemId = (getFieldInfo (protocol .stateSensor )[' id' ] or - 1 )
11- local sensorValue = getValue (telemId )
10+ local function getSensorValue ()
11+ if sensorId == - 1 then
12+ sensorId = getFieldInfo (protocol .stateSensor )[' id' ] or - 1
13+ end
14+ return getValue (sensorId )
15+ end
16+
17+ local function modelActive (sensorValue )
1218 return type (sensorValue ) == " number" and sensorValue > 0
1319end
1420
@@ -24,7 +30,9 @@ local function run_bg()
2430 -- ------------------------------------
2531 -- SYNC DATE AND TIME
2632 -- ------------------------------------
27- if not timeIsSet and modelActive () then
33+ local sensorValue = getSensorValue ()
34+
35+ if not timeIsSet and modelActive (sensorValue ) then
2836 -- Send datetime when the telemetry connection is available
2937 -- assuming when sensor value higher than 0 there is an telemetry connection
3038 -- only send datetime one time after telemetry connection became available
@@ -47,7 +55,7 @@ local function run_bg()
4755 mspMsgQueued = true
4856
4957 timeIsSet = true
50- elseif not modelActive () then
58+ elseif not modelActive (sensorValue ) then
5159 timeIsSet = false
5260 end
5361
You can’t perform that action at this time.
0 commit comments