Skip to content

Commit ede709b

Browse files
committed
Allow wifi settings for service to work.
1 parent d00b4a6 commit ede709b

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

esp32/modules/easyrtc.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
import machine, time
88

99
# Functions
10-
def string(date=False, time=True):
11-
[year, month, mday, wday, hour, min, sec, usec] = machine.RTC().datetime()
10+
def string(print_date=False, print_time=True, timestamp = -1):
11+
if timestamp<0:
12+
[year, month, mday, wday, hour, minute, sec, usec] = machine.RTC().datetime()
13+
else:
14+
[year, month, mday, hour, minute, second, wday, yday] = time.localtime(timestamp)
1215
monthstr = str(month)
1316
if (month<10):
1417
monthstr = "0"+monthstr
@@ -18,15 +21,15 @@ def string(date=False, time=True):
1821
hourstr = str(hour)
1922
if (hour<10):
2023
hourstr = "0"+hourstr
21-
minstr = str(min)
22-
if (min<10):
24+
minstr = str(minute)
25+
if (minute<10):
2326
minstr = "0"+minstr
2427
output = ""
25-
if date:
28+
if print_date:
2629
output += daystr+"-"+monthstr+"-"+str(year)
2730
if time:
2831
output += " "
29-
if time:
32+
if print_time:
3033
output += hourstr+":"+minstr
3134
return output
3235

esp32/modules/services.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def setup(pmCb=False, drawCb=False):
115115

116116
if loopEnabled:
117117
try:
118-
loopCallbacks[srv.loop] = 0
118+
loopCallbacks[srv.loop] = wifiInLoop
119119
except:
120120
print("[SERVICES] Loop requested but not defined in service "+app)
121121

@@ -152,6 +152,14 @@ def loop_timer_callback(tmr):
152152
requestedInterval = 99999999
153153
newLoopCallbacks = loopCallbacks
154154
for cb in loopCallbacks:
155+
if loopCallbacks[cb]:
156+
print("[SERVICES] Loop needs wifi!")
157+
if not easywifi.status():
158+
if not easywifi.enable():
159+
print("[SERVICES] Wifi not available!")
160+
continue
161+
else:
162+
print("[SERVICES] Loop does not need wifi!")
155163
rqi = 0
156164
try:
157165
rqi = cb()
@@ -171,6 +179,8 @@ def loop_timer_callback(tmr):
171179
if requestedInterval>=99999999:
172180
print("[SERVICES] No loop interval returned.")
173181
requestedInterval = -1
182+
183+
easywifi.disable() # Always disable wifi
174184

175185
try:
176186
if pmCallback(requestedInterval):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy