Пример #1
0
    def __init__(self, parent=None, **kwargs):
        QWidget.__init__(self, parent, **kwargs)

        self.setWindowTitle("Server")

        self._running = False
        self._server = HttpServer(self)

        l = QGridLayout(self)
        l.addWidget(
            QPushButton("Start", self, checkable=True, clicked=self.startStop),
            0, 0)

        sgb = QGroupBox("Settings", self)
        sl = QFormLayout(sgb)
        l.addWidget(sgb, 1, 0)

        self._host = QLineEdit('127.0.0.1', self)
        sl.addRow("Host:", self._host)

        self._port = QSpinBox(self, value=8080, minimum=1024, maximum=99999)
        sl.addRow("Port:", self._port)

        rdl = QHBoxLayout()
        rdl.setContentsMargins(0, 0, 0, 0)
        self._rootDir = QLineEdit(QDir('./www').absolutePath(), self)
        rdl.addWidget(self._rootDir)
        rdl.addWidget(QPushButton("Browse...", self, clicked=self.setRootDir))
        sl.addRow("Root Directory:", rdl)
Пример #2
0
def make_server(server_address, application):

    server = HttpServer(server_address)

    server.add_app(application)
    return server
Пример #3
0
        logger.debug('STA IP address: ' + sta_ip_addr)
# print current local date & time
logger.debug('Date: ' + rtc.get_localdate())
logger.debug('Time: ' + rtc.get_localtime())

# initialize the MQTT module
logger.debug('Initializing MQTT...')
mqtt = MQTT(settings)

# initialize the fermentation process
logger.debug('Initializing main process logic...')
main_process = Process(fermenter_temp_ctrl, process_tim, recovery, wifi, mqtt)

# Set up HTTP server
logger.debug('Initializing Web server...')
web = HttpServer(main_process, wifi, rtc, settings)
web.start()
utime.sleep(3)
if web.is_started():
    logger.debug('HTTP service has started.')
led.set_color('green')  # 初始化全部完成后设置为绿色,表示处于待机状态

# Set up DNS Server
logger.debug('Initializing DNS...')
if MicroDNSSrv.Create({'*': '192.168.4.1'}):
    logger.debug("DNS service has started.")
else:
    logger.debug("Failed to start DNS service...")

# Check if the crash recovery is needed
if recovery.is_needed():
Пример #4
0
        # 3. Measure tilt angle every 3s in the background
        import _thread

        def measure_tilt():
            while True:
                try:
                    gy521.get_smoothed_angles()
                except Exception:
                    print('Error occurs when measuring tilt angles')
                gc.collect()
                utime.sleep_ms(3000)

        tilt_th = _thread.start_new_thread(measure_tilt, ())
        # 4. Set up HTTP Server
        from httpserver import HttpServer
        web = HttpServer(gy521, wifi, settings)
        print('HTTP server initialized')
        web.start()
        utime.sleep(3)
        if web.is_started():
            print('HTTP service started')
        print('--------------------')
# 工作模式
elif machine.reset_cause() == machine.DEEPSLEEP_RESET:
    from microWebCli import MicroWebCli
    # Unhold the pins to allow those pins to be used
    unhold_pins()
    # Turn on VPP to supply power for GY521 and allow battery voltage measurement
    vpp.on()
    # Initialize the peripherals
    gy521, ds18, battery, wifi = initialization(init_gy521=True,
Пример #5
0
# 	'reca': 5,
# 	'recb': 23,
# 	'ctrl': 27
# }
# led = Pin(2, Pin.OUT)

## Cheap ESP32 WROOM-32 board with no spi RAM
pinmap = {
    'lpwm': 13,
    'ldir': 12,
    'lslp': 14,
    'leca': 26,
    'lecb': 27,
    'rpwm': 25,
    'rdir': 33,
    'rslp': 32,
    'reca': 34,
    'recb': 35,
    'ctrl': 15
}
led = Pin(2, Pin.OUT)

romp = RomiPlatform(pinmap)

# A suitable index.html file should be put in /www on the ESP32 internal storage
hsrv = HttpServer()  # Create the HTTP server on port 80
wsrv = RomiServer(romp, 8080,
                  debug=False)  # Create the web socket server on port 8080
print("Point your browser at:", hsrv.start())  # Start the HTTP server
print("Web socket URL:", wsrv.start())  # Start the web socket server