Skip to content

Commit 6b99ff0

Browse files
committed
working text message code
1 parent 42293e8 commit 6b99ff0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

code.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def transmit_sms_queue():
188188
qfiles = os.listdir('/queue/')
189189
heatseek_json = '{{"c":"{}","i":"{}","r":['.format(secrets["cell_id"], secrets["reading_interval"])
190190
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]:
192193
if not qfile.startswith('1'):
193194
print('Removing extraneous file in queue /queue/{}'.format(qfile))
194195
os.remove('/queue/{}'.format(qfile))
@@ -207,11 +208,15 @@ def transmit_sms_queue():
207208
heatseek_json += (",".join(heatseek_json_ar))
208209
heatseek_json += ']}'
209210
send_success = False
210-
print("Sending queued data file /queue/{}".format(qfile))
211211
send_success = fona.send_sms(SMS_RELAY_NUMBER, str(heatseek_json))
212212
if send_success:
213213
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
215220
return True
216221
else:
217222
print("Sending queued heatseek data failed")

0 commit comments

Comments
 (0)