def print_bootscreen(self):
        """
        Print bootscreen.

        This contains important details about your device
        and the operating system running on it.
        """

        if not self.settings.get('main.logging.enabled', False):
            return

        # Todo: Maybe refactor to TerkinDatalogger.
        from uio import StringIO
        buffer = StringIO()

        def add(item=''):
            buffer.write(item)
            buffer.write('\n')

        # Program name and version.
        title = '{} {}'.format(self.name, self.version)

        add()
        add('=' * len(title))
        add(title)
        add('=' * len(title))

        # Machine runtime information.
        add('CPU freq     {} MHz'.format(machine.freq() / 1000000))
        add('Device id    {}'.format(self.device_id))
        add()

        # System memory info (in bytes)
        if hasattr(machine, 'info'):
            machine.info()
            add()

        # TODO: Python runtime information.
        add('{:8}: {}'.format('Python', sys.version))
        """
        >>> import os; os.uname()
        (sysname='FiPy', nodename='FiPy', release='1.20.0.rc7', version='v1.9.4-2833cf5 on 2019-02-08', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1')
        """
        runtime_info = os.uname()
        for key in dir(runtime_info):
            if key == '__class__':
                continue
            value = getattr(runtime_info, key)
            #print('value:', value)
            add('{:8}: {}'.format(key, value))
        add()
        add()

        # Todo: Add program authors, contributors and credits.

        log.info('\n' + buffer.getvalue())
Esempio n. 2
0
def print_system_info():
    os_info = uos.uname()

    print("os info:")
    print("  node: %s" % os_info.nodename)
    print("  release: %s, version: %s" % (os_info.release, os_info.version))
    print("  cpu freq: %d MHz" % int(machine.freq() / (1000**2)))
    print("")

    # print stack and heap info
    machine.info()
Esempio n. 3
0
def boot_wifi(ssid, password):
    import machine
    import network
    import time
    import gc
    import pycom

    print(">> boot.py: START")

    wlan = network.WLAN(mode=network.WLAN.STA)

    pycom.heartbeat(False)
    pycom.rgbled(0x090000)

    wlan_timeout = time.time() + 15

    if not wlan.isconnected():
        wlan.connect(ssid, auth=(network.WLAN.WPA2, password), timeout=10000)

    colors = [ 0x000009, 0x000900, 0x090000 ]

    while not wlan.isconnected() and time.time() < wlan_timeout:
        pycom.rgbled(colors[time.time() % len(colors)])
        time.sleep(1)

    try:
        print(">> boot.py: IP: {:,}".format(wlan.ifconfig()[0]))
    except:
        pass

    rtc = machine.RTC()

    if not rtc.synced():
        rtc.ntp_sync("pool.ntp.org", 3600)

        for _ in range(5, 0, -1):
            if not rtc.synced():
                time.sleep(1)

    print(">> boot.py: Time: %04d/%02d/%02d %02d:%02d:%02d UTC" % time.localtime()[:6])

    pycom.heartbeat(False)

    gc.collect()

    print(">> boot.py: gc.mem_free = {}".format(gc.mem_free()))

    machine.info()
    gc.collect()

    print(">> boot.py: END")
Esempio n. 4
0
SFX_TEST_MODE_RX_SENSI = 4
SFX_TEST_MODE_TX_SYNTH = 5

# WLAN().deinit()
# Server().deinit()
#### changing the following needs a reset of the device to take effect!
# pybytes.smart_config(False)
# pybytes.set_config("pybytes_autostart","true")
# pycom.wifi_on_boot(False)
# pycom.wdt_on_boot(False)

print("sys.platform:", sys.platform)
print("machine.unique_id:", ubinascii.hexlify(machine.unique_id()))
print("machine.freq:", machine.freq())
print("machine.info:")
machine.info()

print("pycom.wifi_on_boot:", pycom.wifi_on_boot())
print("pycom.wdt_on_boot:", pycom.wdt_on_boot())
# print("pycom.smart_config_on_boot:", pycom.smart_config_on_boot())

sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=RCZ)
print("sigfox version:", sigfox.version())
print("sigfox ID:", ubinascii.hexlify(sigfox.id()))
print("sigfox PAC:", ubinascii.hexlify(sigfox.pac()))
print("sigfox region:", RCZ)
print("sigfox frequencies:", sigfox.frequencies())
print("sigfox rssi offset:", sigfox.rssi_offset())
# sigfox config
rcz3_config_test_mode = (
    1, 0x2ee0, 0x100
Esempio n. 5
0
 def meminfodump(self):
     with log_lock:
         machine.info()