from rfid_utils import RFID, Buzzer, OUT
from uasyncio import sleep_ms
from webserver import eprint, erfid
from binascii import hexlify
async def run():
await eprint("User code started")
rfid = RFID()
buz = Buzzer()
while 1:
await sleep_ms(500)
uid = rfid.read()
if uid:
OUT.on()
await erfid(uid)
await buz.beep()
await sleep_ms(3000)
OUT.off()
from rfid_utils import RFID, Buzzer
from uasyncio import sleep_ms
from webserver import eprint
from config import settings
from uasyncio import AsyncUDP
async def run():
await eprint("User code started")
rfid = RFID()
buz = Buzzer()
while 1:
await sleep_ms(500)
uid = rfid.read(settings.get('format'))
if uid:
await buz.beep()
await AsyncUDP.udp_send(uid, (settings.get('dest'), settings.get('dport')) )
await sleep_ms(3000)
from uasyncio import sleep_ms
from webserver import eprint
from config import settings
async def run():
await eprint("User code started")
s = settings
while 1:
await sleep_ms(1000)
await eprint('format:{}, dest:{}, port:{}'.format(s.get('format'), s.get('dest'), s.get('dport')))
from time import time
from uasyncio import sleep_ms, sleep
from machine import WDT
from rfid_utils import RFID, Buzzer, GLED, RLED, CardFilter, OUT, IN
from webserver import eprint, erfid
from config import settings, udb
async def granted(buz):
GLED.on()
await buz.beep()
GLED.off()
OUT.off()
await sleep(5)
OUT.on()
async def run():
await eprint("User code started")
rfid = RFID()
buz = Buzzer()
GLED.off()
RLED.off()
OUT.on()
c_filter = CardFilter(5)
wdt_enabled = settings.get('wdt')
str_format = settings.get('format')
if wdt_enabled:
wdt = WDT(timeout=10000)
while 1:
if wdt_enabled:
wdt.feed()
await sleep_ms(200)
c_filter.clean(time())
if IN.value() == 0:
await granted(buz)
uid = rfid.read(str_format)
if uid and uid not in c_filter:
c_filter.append(uid)
value = udb.get(uid)
if value is not None:
await eprint(uid + ' granted')
await granted(buz)
else:
RLED.on()
await eprint(uid + ' denied')
await buz.beep(500)
RLED.off()
from time import time
from uasyncio import sleep_ms, sleep
from machine import WDT
from rfid_utils import RFID, Buzzer, GLED, RLED, CardFilter, OUT, IN
from webserver import eprint, erfid
from config import settings, udb
async def door():
OUT.off()
await sleep(5)
OUT.on()
async def run():
await eprint("User code started")
rfid = RFID()
buz = Buzzer()
prev_in = None
GLED.off()
RLED.off()
OUT.on()
c_filter = CardFilter(5)
wdt_enabled = settings.get('wdt')
str_format = settings.get('format')
if wdt_enabled:
wdt = WDT(timeout=10000)
while 1:
if wdt_enabled:
wdt.feed()
await sleep_ms(100)
c_filter.clean(time())
if (prev_in == 0) and (IN.value() == 1):
await door()
prev_in = IN.value()
uid = rfid.read(str_format)
if uid and uid not in c_filter:
c_filter.append(uid)
await eprint(uid + ' granted')
GLED.on()
await buz.beep()
GLED.off()
await door()