def __init__(self, sensor_table, srv): self.light_sensor = LightSensor() self.mutex = esp.mutex() self.sensor_table = sensor_table self.sensors = dict() self.task = esp.os_task(callback=lambda task: handler(task, srv, self)) for sensor_name, sensor_port in sensor_table.items(): self.sensors[sensor_name] = Sensor(sensor_name, sensor_port, 10000, task=self.task, mutex=self.mutex) pyb.udelay(10000)
def __init__(self, got_date): self.soc = esp.socket() self.soc.onconnect(lambda sock: on_connect(self, sock)) self.soc.onrecv(lambda sock, data: socket_recv(self, sock, data)) self.mutex = esp.mutex(spin_time=3000) self.got_date = got_date