コード例 #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
ファイル: boot.py プロジェクト: dbuos/MySense
# 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
コード例 #3
0
ファイル: boot.py プロジェクト: askpatrickw/pycom-stubs
import pycom

pycom.smart_config_on_boot(False)
pycom.pybytes_on_boot(False)
コード例 #4
0
import pycom
pycom.pybytes_on_boot(True)

import usocket
import _thread
import time


# Thread for handling a client
def client_thread(clientsocket, n):
    # Receive maxium of 12 bytes from the client
    r = clientsocket.recv(12)

    # If recv() returns with 0 the other end closed the connection
    if len(r) == 0:
        clientsocket.close()
        return
    else:
        # Do something wth the received data...
        print("Received: {}".format(str(r)))

    # Sends back some data
    clientsocket.send(str(n))

    # Close the socket and terminate the thread
    clientsocket.close()


# Set up server socket
serversocket = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
serversocket.setsockopt(usocket.SOL_SOCKET, usocket.SO_REUSEADDR, 1)
コード例 #5
0
self_config = config.get(name)


def cfg(key=None):
    if key is None:
        return self_config
    else:
        if self_config:
            v = self_config.get(key)
            if v is not None:
                return v
        # otherwise return default
        return def_config[key]


if cfg('pybytes_on_boot') != pycom.pybytes_on_boot():
    b = cfg('pybytes_on_boot')
    print('fix pybytes_on_boot config ({}) and reboot'.format(b))
    pycom.pybytes_on_boot(b)
    time.sleep(1)
    machine.reset()

board_ver = cfg('v')
board = cfg('b')
py = None
if board == 'Pygate':
    board_ver_str = ''
else:
    if board_ver == 1:
        from pycoproc_1 import Pycoproc
        if board == 'Pytrack':
コード例 #6
0
if __name__ == '__main__':
    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)
コード例 #7
0
ファイル: boot.py プロジェクト: peter-pycom/pybytes
import time
boot0_t = time.time()
import machine
cpu_temp0_f = machine.temperature()
import pycom
print('boot.py', boot0_t, time.ticks_ms(), 'pybytes_on_boot=',
      pycom.pybytes_on_boot())
pycom.heartbeat(False)
pycom.rgbled(0x030300)  # yellow
コード例 #8
0
        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=" ")
    print_wifi_mode(m)
    print()
except:
    pass
コード例 #9
0
import pycom
import machine

if pycom.pybytes_on_boot():
    print("Pybytes is currently turned on ... turning it off now")
    pycom.pybytes_on_boot(False)
else:
    print("Pybytes is currently turned off ... turning it on now")
    pycom.pybytes_on_boot(True)

if False:
    machine.reset()

    import _thread
    _thread.start_new_thread(pybytes.start, )