I set a scheduled task every 1 minute.
It seems to work, but how do I call my Pico in this function?
The Pico function that I want to call is 'message" and takes 3 parameters.
normally when I call it from the client side I write:
anvil.server.call(‘message’, nr, l1, l2)
but I tried the 2:
-
anvil.server.call(‘message’, nr, l1, l2)
-
message(nr,l1,l2)
see the line “anvil.server.call(‘message’, nr, l1, l2)” in my code, that’s my question.
The rest is executed from the scheduled task, but not the pico call.
if I try it with a timer on the client side, it works fine and calls the Pico (sends the message)
Maybe I need to put the UPLINK code inside this function, I don’t know.
Code Sample:
@anvil.server.background_task
def msgsend():
msgbool = msgboolcheck()
if msgbool:
notsendnrs = [r['msgnr'] for r in app_tables.msg.search(msgsend=False)]
print(notsendnrs)
if len(notsendnrs)> 0:
print(len(notsendnrs))
nr1stnotsend = notsendnrs[0]
print(nr1stnotsend)
if nr1stnotsend:
rowid = app_tables.msg.get(msgnr=nr1stnotsend)
nr = rowid['msgnr']
l1 = rowid['msgl1']
l2 = rowid['msgl2']
rowid.update(msgsend=True,msgsendtime=datetime.now(tz))
anvil.server.call('message',nrl,l1l,l2l)
else:
return