Exemple #1
0
def Project():
    import network
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(ssid, password)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    
    ota_updater = OTAUpdater('https://github.com/deepak4395/ESP32-ota')
    ota_updater.download_and_install_update_if_available(ssid,password)
    if (ota_updater.check_for_update_to_install_during_next_reboot()):
        machine.reset()
    while 1 :        
        print("Hello")
        sleep(1)
Exemple #2
0
def start():
    from main import ota_updater
    from main.action import process

    process()
    o = OTAUpdater('https://github.com/sasilva1998/OTATesting.git')
    o.download_and_install_update_if_available('NETLIFE-Silva', 'SASM3141')
    o.check_for_update_to_install_during_next_reboot()
Exemple #3
0
def connect_to_wifi_and_update():
    import time, machine, network, gc
    time.sleep(1)
    print('Memory free', gc.mem_free())

    from main.ota_updater import OTAUpdater
    import main.secrets as secret

    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(secret.WIFI_SSID, secret.WIFI_PASSWORD)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    otaUpdater = OTAUpdater('https://github.com/bigmachini/mqtt', main_dir='main', secrets_file="secrets.py")
    hasUpdated = otaUpdater.install_update_if_available()
    if hasUpdated:
        machine.reset()
    else:
        del (otaUpdater)
        gc.collect()
def download_and_install_update_if_available(wlan):
    print("Checking for updates")
    with open(GITHUB_TOKEN_FILE) as f:
        token = f.readline()
        o = OTAUpdater(GITHUB_REPO,
                       headers={
                           'User-Agent': 'winescout',
                           'Authorization': 'token {}'.format(token)
                       })
        o.check_for_update_to_install_during_next_reboot()
        o.download_and_install_update_if_available(wlan)
Exemple #5
0
def start():
    from main import ota_updater
    from main import time_date
    from main.logger import MainLogger
    from main.time_date import MyTimeDate

    ota_updater = OTAUpdater('https://github.com/mastercba/logger')
    #    ota_updater.download_and_install_update_if_available('TORRIMORA', 'santino989')
    ota_updater.using_network('TORRIMORA', 'santino989')
    ota_updater.check_for_update_to_install_during_next_reboot()

    # INIT time&date
    date = MyTimeDate()
    dt = date.readTimeDate()

    # Begin MAINcode
    loggerPRJ = MainLogger()
def download_and_install_update_if_available():
    o = OTAUpdater(config['your_repo'])
    o.check_for_update_to_install_during_next_reboot(config['ssid'],
                                                     config['wifi_pw'])
    o.download_and_install_update_if_available(config['ssid'],
                                               config['wifi_pw'])
Exemple #7
0
def download_and_install_update_if_available():
    ota_updater = OTAUpdater('https://github.com/mastercba/Lalmacigo')
    ota_updater.download_and_install_update_if_available(
        'TORRIMORA', 'santino989')
Exemple #8
0
def update_software():
    from main import configure
    o = OTAUpdater(configure.read_config_file("update_repo"), github_auth_token=configure.read_config_file('update_repo_token'))
    if str(o.get_current_version()) == "0.0.0":
        o.set_version_on_reboot(o.get_latest_version())
    o.update_software()
Exemple #9
0
def download_and_install_update_if_available():
    OTAUpdater.using_network('MI','dehradun')
    ota_updater = OTAUpdater('https://github.com/PankajRawat333/esp32_ota')
    ota_updater.check_for_update_to_install_during_next_reboot()
    ota_updater.download_and_install_update_if_available('MI','dehradun')
def main():
    global time_last_update  #variable important to OTA time update
    global switch_ap
    time_last_update = 0
    time_tick_send_message = 60 * 59
    time_sleep_across_measure = 0.9
    url = 'https://github.com/Yoendric/iotazure_powerONOFF'  #Github repository project
    o = OTAUpdater(url)
    led = Pin(14, Pin.OUT)
    led.value(1)
    wifi = Pin(4, Pin.OUT)
    pir = Pin(25, Pin.IN)
    pir.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=handle_interrupt)
    uart = UART(2, baudrate=9600, tx=26, rx=27)  # init with given baudrate
    uart.init(9600, bits=8, parity=None, stop=1)  # init with given parameters
    # Azure IoT-hub settings
    hostname = "checkinwattsiothub.azure-devices.net"
    device_id = ubinascii.hexlify(network.WLAN().config('mac'), ':').decode()
    device_id = device_id.upper()
    uri = "{hostname}/devices/{device_id}".format(hostname=hostname,
                                                  device_id=device_id)
    username_fmt = "{}/{}/?api-version=2018-06-30"
    key = "XxXK7Pun5XQa/NqUsGBmXBKI4euLUcU/72bjxuPr+jE="
    username = username_fmt.format(hostname, device_id)
    switch_ap = False
    ssid, passw = Get_Client_Wifi_Parameters()
    if pir.value() == 1:
        switch_ap = True
    while True:
        if switch_ap:
            print('Interrupt AP detected!')
            wifi.value(0)
            led.value(1)
            ssid, passw = ap_mode()
            while switch_ap:
                Blinky_LED(wifi)
        else:
            print('Modo cliente')
            wifi.value(1)
            if (ssid and passw):
                Connect_wifi_client(ssid, passw)
                download_and_install_update_if_available(url, ssid, passw)
                Adjustment_Time_RTC(-6)
                Reset_Energy(uart, 1)
                password = Sas_token(uri, key)
                f0 = ""
                f1 = ""
                while (not switch_ap):
                    if check_time_update_github(time_last_update):
                        try:
                            o.check_for_update_to_install_during_next_reboot()
                            time_last_update = time.mktime(time.localtime())
                        except:
                            print(
                                "NO SE PUEDE CONECTAR PARA VER SI HAY ACTUALIZACION"
                            )
                    sleep(time_sleep_across_measure)
                    wh = ""
                    MSG_TXT = '{{"ID": "010008","status": "{f0}","consumo":"{wh}","numero_act":"2"}}'
                    seg = 1
                    while (seg <= time_tick_send_message) and (f1 == f0) and (
                            not switch_ap):
                        led.value(seg % 2)
                        f1, wh = Read_PZEM(uart, seg, 1)
                        sleep(time_sleep_across_measure)
                        seg = seg + 1
                    f0 = f1
                    Reset_Energy(uart, 1)
                    if (not switch_ap):
                        msg_txt_formatted = MSG_TXT.format(f0=f0, wh=wh)
                        print("Message ready to ship to IoT Hub Azure")
                        print(msg_txt_formatted)
                        iot_hub_mqttsend(device_id, hostname, username,
                                         password, msg_txt_formatted)
            else:
                sleep(1)
Exemple #11
0
def download_and_install_update_if_available():

    o = OTAUpdater('https://github.com/sasilva1998/OTATesting.git')
    o.download_and_install_update_if_available('NETLIFE-Silva', 'SASM3141')
Exemple #12
0
def download_and_install_update_if_available():
    ota = OTAUpdater("https://github.com/Awesomespace/hackerlabstate")
    ota.download_and_install_update_if_available(wifi_ssid, wifi_password)
Exemple #13
0
def download_and_install_update_if_available():
    ota_updater = OTAUpdater('https://github.com/TribulusTechOTA/yfidot.git')
    ota_updater.download_and_install_update_if_available(
        'Tribulus', 'Redhat@345')
Exemple #14
0
def download_and_install_update_if_available():
    ota_updater = OTAUpdater('https://github.com/mattchapmangit/rpyhome.git')
    ota_updater.download_and_install_update_if_available(
        config['wifi_ssid'], config['wifi_password'])
Exemple #15
0
from main.ota_updater import OTAUpdater
from main.terminal import Terminal
import time

node_name = "node8"
node_ip = "192.168.1.28"
node_gateway = "192.168.1.1"
node_ssidname = "terminalUTAD"
node_ssidpassword = "******"
gitaddress = "https://github.com/jpbrito/terminal"

o = OTAUpdater(gitaddress)
o.using_network(node_ssidname, node_ssidpassword, node_ip)
t = Terminal(node_name, node_ip, node_gateway, node_ssidname,
             node_ssidpassword)


def download_and_install_update_if_available():
    o.using_network(node_ssidname, node_ssidpassword, node_ip)
    o.download_and_install_update_if_available(node_ssidname,
                                               node_ssidpassword, node_ip)
    o.check_for_update_to_install_during_next_reboot()


def start():
    #t = Terminal(node_name,node_ip,node_gateway,node_ssidname,node_ssidpassword)
    t.read()


def boot():
    download_and_install_update_if_available()
Exemple #16
0
def download_and_install_update_if_available():
	o = OTAUpdater('https://github.com/Ritesh1991/smhupdate')
	o.download_and_install_update_if_available('Ritesh', '9824168814')
def download_and_install_update_if_available():
    o = OTAUpdater(GITHUB_HTTPS_ADDRESS)
    o.download_and_install_update_if_available()
def download_and_install_update_if_available():
    ota_updater = OTAUpdater(
        'https://github.com/PankajRawat333/micropython-ota-updater')
    ota_updater.download_and_install_update_if_available('MI', 'dehradun')
def download_and_install_update_if_available(url, ssid, password):
    o = OTAUpdater(url)
    o.download_and_install_update_if_available(ssid, password)
Exemple #20
0
def main():
    global time_last_update  #variable important to OTA time update
    global switch_ap
    time_last_update = 0
    time_to_send = {9: 00}
    time_sleep_across_measure = 0.9
    url = 'https://github.com/Yoendric/check_SMS'  #Github repository project
    o = OTAUpdater(url)
    led = Pin(14, Pin.OUT)
    led.value(1)
    pir = Pin(23, Pin.IN)
    pir.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=handle_interrupt)
    uart = UART(2, baudrate=9600, tx=19, rx=18)  # init with given baudrate
    uart.init(9600, bits=8, parity=None, stop=1)  # init with given parameters
    #Reset_Energy_PZEM(uart,1)
    # Twilio settings
    account_sid = 'AC740a12f51481d5d366597094a5d41673'
    auth_token = '2e8ea574f317091'
    sms = TwilioSMS(account_sid, auth_token + 'fc7899eacf8a3c688')
    email = "*****@*****.**"
    lectura = 0
    Crear_Registro_Cliente(email, lectura)
    parametros = [
        'Voltage (V)', 'Corriente (A)', 'Potencia (W)', 'Energia (Wh)',
        'Frecuencia (Hz)', 'FactorPot', 'Consumo Energia'
    ]
    # End Twilio config
    switch_ap = False
    ssid, passw = Get_Client_Wifi_Parameters()
    if pir.value() == 1:
        switch_ap = True
    while True:
        if switch_ap:
            print('Interrupt AP detected!')
            led.value(1)
            ssid, passw = ap_mode()
            while switch_ap:
                Blinky_LED(led)
        else:
            print('Modo cliente')
            led.value(1)
            if (ssid and passw):
                Connect_wifi_client(ssid, passw)
                download_and_install_update_if_available(url, ssid, passw)
                Adjustment_Time_RTC(-5)
                data = Read_PZEM(uart, 0, 1)
                while (data == None):
                    time.sleep(1)
                    data = Read_PZEM(uart, 0, 1)
                energy = data[3]
                energy_init = energy
                while (not switch_ap):
                    if check_time_update_github(time_last_update):
                        try:
                            o.check_for_update_to_install_during_next_reboot()
                            time_last_update = time.mktime(time.localtime())
                        except:
                            print(
                                "NO SE PUEDE CONECTAR PARA VER SI HAY ACTUALIZACION"
                            )
                    seg = 1
                    while ({
                            RTC().datetime()[4] % 12: RTC().datetime()[5]
                    } != time_to_send) and (not switch_ap):
                        led.value(seg % 2)
                        data = Read_PZEM(uart, seg, 1)
                        sleep(time_sleep_across_measure)
                        if seg == 60:
                            Save_watt_comsumption(data[3] - energy_init)
                            energy_init = data[3]
                        seg = seg % 60 + 1
                    if (not switch_ap):
                        print("Message ready to ship to SMS")
                        f = open('datos_client.txt', 'r')
                        data_client = f.read()
                        f.close()
                        data_client = json.loads(data_client)
                        sms_men = {
                            'From':
                            '+14805265762',
                            'To':
                            '+525560060230',
                            'Body':
                            'Consumo del periodo es: %s KW. Lectura contador %s'
                            % ((data[3] - energy) / 1000,
                               data_client["lectura_contador"])
                        }
                        try:
                            sms.create(sms_men['Body'], sms_men['From'],
                                       sms_men['To'])
                        except:
                            print("No se pudo mandar el sms")
                        letter = data
                        letter.append((data[3] - energy) / 1000)
                        print(letter)
                        try:
                            send_mail(letter, parametros,
                                      data_client["lectura_contador"],
                                      data_client["email"])
                        except:
                            print("No se pudo mandar el email")
                        energy = data[3]
                        time.sleep(60)
            else:
                sleep(1)