def run(self): while True: print("\tVersion: %s" % self.this_version) print("\tDevice : %s exist" % base.get_device_num()) self.display() self.get_num() if (self.input is 0): continue elif (self.input is 1): led.Led(led.Led.led_menu_array).run() elif (self.input is 2): wifi.Wifi(wifi.Wifi.wifi_menu_array).run() elif (self.input is 3): alexa.Alexa().run() elif (self.input is 4): bt.Bt(bt.Bt.bt_menu_array).run() elif (self.input is 5): development.Development().run() elif (self.input is 6): fastboot_all.FastbootImage().run() elif (self.input is 7): os.system('adb reboot') os._exit(0) elif (self.input is 8): os._exit(0) else: print("error") continue
def __alexa_onestep_activate(self): self.bt_instance = bt.BtAddress(bt.Bt.bt_address_modify_menu_array) self.wifi_instance = wifi.Wifi(wifi.Wifi.wifi_menu_array) self.bt_instance.bt_solid_address() sleep(1) self.wifi_instance.wifi_connect() sleep(1) pause = input("\nAny key to Continue when AVSLED flash GREEN twice") self.__alexa_activate()
def __init__(self): self.LIMITE_TECHO = memoria.lee_techo() self.LIMITE_ACELERACION = memoria.lee_aceleracion() self.maximo_aceleracion = 0 self.insidePin = Pin(self.insideLedPin, mode=Pin.OUT) self.hitPin = Pin(self.hitLedPin, mode=Pin.OUT) self.golpeLed = memoria.lee_impacto() self.wifiVar = wifi.Wifi(self) #self.tfminiVar = tfmini.Tfmini() self.acel = acelerometro.Acelerometro() self.loraVar = lora.Lora(self.dev, self.nwk, self.app)
def main(): # Connect to wifi w = wifi.Wifi(config.ssid, config.password, config.ifconfig) if not w.connect(): print("Could not connect to wifi") machine.reset() time.sleep_ms(300) print("Connecting to MQTT") c = mqtt.MQTTClient('umqtt_client', config.mqttserver, port=config.mqttport) c.DEBUG = True c.set_callback(_make_mqtt_callback(c)) _mqtt_connect(c) while True: c.wait_msg(timeout=1.0 / 25.0)
import gc esp.osdebug(None) gc.collect() # EXAMPLE IP ADDRESS # mqtt_server = '192.168.1.144' client_id = ubinascii.hexlify(machine.unique_id()) topic_led = b'/control/3/led' topic_sensor = b'/sensor/air' last_message = 0 message_interval = 5 counter = 0 import wifi wifinet = wifi.Wifi(Config.wifi_ssid, Config.wifi_password) from machine import RTC import ntptime rtc = RTC() try: ntptime.settime() except OSError as e: pass print(rtc.datetime()) from dht import DHT22 from machine import Pin, PWM import json