Exemple #1
0
def deepsleep_now():
    """ prepare scripts for graceful exit, deepsleeps if case """
    mesh.timer_kill()
    watchdog.timer_kill()
    rx_worker.timer_kill()
    ble_comm.close()
    Gps.terminate()
    mesh.statistics.save_all()
    print('Cleanup code, all Alarms cb should be stopped')
    if deepsleep_timeout > 0:
        print('Going to deepsleep for %d seconds' % deepsleep_timeout)
        time.sleep(1)
        machine.deepsleep(deepsleep_timeout * 1000)
Exemple #2
0
def deepsleep_now():
    """ prepare scripts for graceful exit, deepsleeps if case """
    mesh.timer_kill()
    watchdog.timer_kill()
    rx_worker.timer_kill()
    ble_comm.close()
    Gps.terminate()
    mesh.statistics.save_all()
    print('Cleanup code, all Alarms cb should be stopped')
    if new_lora_mac:
        fo = open("/flash/sys/lpwan.mac", "wb")
        mac_write = bytes([
            0, 0, 0, 0, 0, 0, (new_lora_mac >> 8) & 0xFF, new_lora_mac & 0xFF
        ])
        fo.write(mac_write)
        fo.close()
        print("Really LoRa MAC set to", new_lora_mac)
    if deepsleep_timeout > 0:
        print('Going to deepsleep for %d seconds' % deepsleep_timeout)
        time.sleep(1)
        machine.deepsleep(deepsleep_timeout * 1000)
Exemple #3
0
                filename = input('(filename, Enter for dog.jpg)<')
                if len(filename) == 0:
                    filename = 'dog.jpg'
                ip = mesh.mesh.mesh.ip_mac_unique(to)
            except:
                continue
            mesh.send_file(ip, packsize, filename)

        elif cmd == 'exit':
            print('exit!')
            break

        elif cmd == "rst":
            print("Mesh Reset... ")
            mesh.mesh.mesh.mesh.deinit()
            #mesh.mesh.lora.Mesh()
            machine.reset()
        pass

except KeyboardInterrupt:
    print('Got Ctrl-C')
except Exception as e:
    sys.print_exception(e)
finally:
    mesh.timer_kill()
    watchdog.timer_kill()
    rx_worker.timer_kill()
    ble_comm.close()
    Gps.terminate()
    print('Cleanup code, all Alarms cb should be stopped')