File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,8 @@ def transmit_sms_queue():
188
188
qfiles = os .listdir ('/queue/' )
189
189
heatseek_json = '{{"c":"{}","i":"{}","r":[' .format (secrets ["cell_id" ], secrets ["reading_interval" ])
190
190
heatseek_json_ar = []
191
- for qfile in qfiles :
191
+ ## Get the files in batches of 2
192
+ for qfile in qfiles [0 :SMS_QUEUE_LENGTH ]:
192
193
if not qfile .startswith ('1' ):
193
194
print ('Removing extraneous file in queue /queue/{}' .format (qfile ))
194
195
os .remove ('/queue/{}' .format (qfile ))
@@ -207,11 +208,15 @@ def transmit_sms_queue():
207
208
heatseek_json += ("," .join (heatseek_json_ar ))
208
209
heatseek_json += ']}'
209
210
send_success = False
210
- print ("Sending queued data file /queue/{}" .format (qfile ))
211
211
send_success = fona .send_sms (SMS_RELAY_NUMBER , str (heatseek_json ))
212
212
if send_success :
213
213
print ("SUCCESS sending queued to Heat Seek at {}" .format (time .time ()))
214
- clear_queued_files ()
214
+ for qfile in qfiles [0 :SMS_QUEUE_LENGTH ]:
215
+ os .remove ('/queue/{}' .format (qfile ))
216
+ qfiles = os .listdir ('/queue/' )
217
+ if len (qfiles ) > 0 :
218
+ transmit_sms_queue ()
219
+ # TODO: call this again recursively if we still have files
215
220
return True
216
221
else :
217
222
print ("Sending queued heatseek data failed" )
You can’t perform that action at this time.
0 commit comments