File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,14 @@ function fireAnimalCollars() {
187
187
} ) ;
188
188
}
189
189
190
+ function fireOverallFarmStatus ( ) {
191
+ return fetch ( `${ devices } /status` , {
192
+ method : 'GET'
193
+ } ) . catch ( ( e ) => {
194
+ debug ( e ) ;
195
+ } ) ;
196
+ }
197
+
190
198
function fireTractors ( ) {
191
199
return fetch ( `${ devices } /devices/tractors` , {
192
200
method : 'PUT'
@@ -197,6 +205,7 @@ function fireTractors() {
197
205
198
206
setInterval ( fireAnimalCollars , 5000 ) ;
199
207
setInterval ( fireDevices , 3000 ) ;
208
+ setInterval ( fireOverallFarmStatus , 10000 ) ;
200
209
201
210
if ( autoMoveTractors > 0 ) {
202
211
setInterval ( fireTractors , autoMoveTractors ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ if (DEVICE_TRANSPORT === 'HTTP') {
43
43
}
44
44
45
45
iotRouter . get ( '/status' , ( req , res ) => {
46
+ IoTDevices . emitOverallFarmStatus ( ) ;
46
47
res . status ( 200 ) . send ( ) ;
47
48
} ) ;
48
49
Original file line number Diff line number Diff line change @@ -169,9 +169,6 @@ function stopDevices() {
169
169
Emitter . emit ( 'barn' , 'door-locked' ) ;
170
170
}
171
171
172
- // Broadcast weather conditions
173
- setInterval ( emitWeatherConditions , 10000 ) ;
174
-
175
172
myCache . init ( ) . then ( ( ) => {
176
173
for ( let i = 1 ; i <= numberOfPigs ; i ++ ) {
177
174
const lng = addAndTrim ( 13.356 + 0.0004 * getRandom ( - 10 ) , true ) ;
@@ -228,7 +225,7 @@ myCache.init().then(() => {
228
225
myCache . set ( 'weather' , 'cloudy' ) ;
229
226
} ) ;
230
227
231
- function emitWeatherConditions ( ) {
228
+ function fireOverallFarmStatus ( ) {
232
229
if ( Emitter ) {
233
230
myCache . get ( 'weather' ) . then ( ( state ) => {
234
231
Emitter . emit ( 'weather' , state ) ;
@@ -658,5 +655,6 @@ module.exports = {
658
655
fireDevices,
659
656
fireAnimalCollars,
660
657
fireTractorStatus,
658
+ fireAppStatus,
661
659
initDevices,
662
660
} ;
You can’t perform that action at this time.
0 commit comments