Пример #1
0
def features(on=None):
    if on is None:
        print("heartbeat   ", pycom.heartbeat_on_boot())
        print("lte         ", pycom.lte_modem_en_on_boot())
        try:
            print("pybytes     ", pycom.pybytes_on_boot())
        except:
            pass
        try:
            print("smart_config", pycom.smart_config_on_boot())
        except:
            pass
        print("wdt         ", pycom.wdt_on_boot())
        print("wifi        ", pycom.wifi_on_boot())
    else:
        print("configure all features as", on)
        pycom.heartbeat_on_boot(on)
        pycom.lte_modem_en_on_boot(on)
        try:
            pycom.pybytes_on_boot(on)
        except:
            pass
        try:
            pycom.smart_config_on_boot(on)
        except:
            pass
        pycom.wdt_on_boot(on)
        pycom.wifi_on_boot(on)
        features(None)
Пример #2
0
 def smart_config(self, status=None, reset_ap=False):
     if status is None:
         return self.__smart_config
     if status:
         if reset_ap:
             pycom.wifi_ssid_sta(None)
             pycom.wifi_pwd_sta(None)
         if self.__pybytes_connection is not None:
             if self.isconnected():
                 print('Disconnecting current connection!')
                 self.disconnect()
             self.__pybytes_connection = None
         if not self.__smart_config:
             pycom.smart_config_on_boot(True)
             self.__smart_config = True
             self.__smart_config_setup()
     else:
         self.__smart_config = False
         pycom.smart_config_on_boot(False)
Пример #3
0
    def __init__(self, config, activation=False, autoconnect=False):
        self.__frozen = globals().get('__name__') == '_pybytes'
        self.__activation = activation
        self.__custom_message_callback = None
        self.__config_updated = False
        self.__pybytes_connection = None
        self.__smart_config = False
        self.__conf = {}

        if not self.__activation:
            self.__conf = config
            pycom.wifi_on_boot(False, True)

            self.__check_dump_ca()
            self.__create_pybytes_connection(self.__conf)
            self.start(autoconnect)
            if autoconnect:
                self.print_cfg_msg()
        else:
            if (hasattr(pycom, 'smart_config_on_boot')
                    and pycom.smart_config_on_boot()):
                self.smart_config(True)
Пример #4
0
# Copyright 2021, Teus Hagen, ver. Behoud de Parel, GPLV3
# $Id: boot.py,v 6.3 2021/01/14 19:51:40 teus Exp teus $

# disable pybytes and smart config
import pycom
try:
    if pycom.pybytes_on_boot(): pycom.pybytes_on_boot(False)
    if pycom.smart_config_on_boot(): pycom.smart_config_on_boot(False)
except:
    pass


def set_wifi():
    from network import WLAN
    # if WLAN.isconnected(): return
    from machine import unique_id
    import binascii
    ssid = 'MySense-' + binascii.hexlify(
        unique_id()).decode('utf-8')[-4:].lower()
    pwd = 'www.pycom.io'
    try:
        WLAN().scan()
    except:  # mode AP, need a compare length
        # if (pycom.wifi_ssid_ap() == ssid) and (pycom.wifi_pwd_ap() == pwd): return
        pass
    from time import sleep
    try:
        WLAN().deinit()
        sleep(1)
    except:
        pass
Пример #5
0
import pycom

pycom.smart_config_on_boot(False)
pycom.pybytes_on_boot(False)
Пример #6
0
    import binascii
    import machine
    uid = binascii.hexlify(machine.unique_id()).decode("utf-8")
    name = os.uname().sysname.lower() + '-' + uid[-4:]
    print(name, uid)

    features()
    if False:
        features(True)  # turn everything on
        features(False)  # turn everything off
        # print
        import pycom
        print('heartbeat', pycom.heartbeat_on_boot())
        print('lte', pycom.lte_modem_en_on_boot())
        print('pybytes', pycom.pybytes_on_boot())
        print('smart_config', pycom.smart_config_on_boot())
        print('wdt', pycom.wdt_on_boot())
        print('wifi', pycom.wifi_on_boot())
        # off
        pycom.heartbeat_on_boot(False)
        import pycom
        pycom.lte_modem_en_on_boot(False)
        pycom.wdt_on_boot(False)
        pycom.wifi_on_boot(False)
        pycom.smart_config_on_boot(False)
        pycom.pybytes_on_boot(False)
        # on
        pycom.heartbeat_on_boot(True)
        pycom.lte_modem_en_on_boot(True)
        pycom.pybytes_on_boot(True)
        pycom.smart_config_on_boot(True)
Пример #7
0
    print(pycom.bootmgr()[2]) # safeboot
    print(pycom.bootmgr()[3]) # status
    print("ota_slot", hex(pycom.ota_slot()))
    if (pycom.ota_slot() == 0x210000):
        print("ota_slot is", "'ota_0' in 'new' 8MB layout")
    elif (pycom.ota_slot() == 0x1A0000):
        print("ota_slot is", "'ota_0' in 'old' 4MB layout")
    elif (pycom.ota_slot() == 0x10000):
        print("ota_slot is", "'Factory'")
    else:
        raise Exception("Unkown ota_slot"+ str(pycom.ota_slot()))
except:
    pass

try:
    print("smart_config_on_boot", pycom.smart_config_on_boot())
except:
    pass
try:
    print("pybytes_on_boot", pycom.pybytes_on_boot())
except:
    pass

try:
    print("wifi_on_boot", pycom.wifi_on_boot())
except:
    pass
from network import WLAN
try:
    m = pycom.wifi_mode_on_boot()
    print("wifi_mode_on_boot", m, end=" ")