示例#1
0
def webserver_init():
    printLog("simple web server")
    print(ver)
    printFree()

    try:
        import usocket as socket
    except:
        import socket

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('', 80))
    s.listen(5)
    printFree()

    return s
示例#2
0
def webconn(s):
  printLog("> webconn ")
  led.blink(50)
  global wnum, web_info, ssidTemp, passTemp, web_wifi
  
  conn, addr = s.accept()
  print('Got a connection from %s' % str(addr))
  request = conn.recv(1024)
  request = str(request)

  try:
    rs = request.split(" ")[1]
    rs = (rs[2:]).split("&")
    ssidTemp = rs[0].split("=")
    passTemp = rs[1].split("=")

    if ssidTemp[0] == "ssid": 
      ssidTemp = ssidTemp[1]
      print("ssid.ok")
      if len(ssidTemp) > 1:
        web_info = "<i>last ssid from form: " + ssidTemp + "</i><hr />"

    if passTemp[0] == "pass": 
      passTemp = passTemp[1]
      print("pass.ok")

  except:
    rs = "err"
    
  print()
  print('Content = ' + str(rs))
  
  # led_on = request.find('/?led=on')
  print()
  print("wifi_config: ")
  from util.wifi_connect import WiFiConnect
  wc = WiFiConnect()

  webWc = "<hr /><b>Saved networks: </b><br />"
  for k, v in wc.config['networks'].items():
      webWc += k + "<br />"

  try:
    print("try save new netw.")
    print("ssid: " + str(ssidTemp) + " | pass: "******"ok")
        led.blink(1000)
        led.blink(1000)
  except:
      print("err")  

  wnum += 1
  web_wifi = webnets + webWc + "<br /> refresh (" + str(wnum) + ")"

  response = web_page()
  conn.send('HTTP/1.1 200 OK\n')
  conn.send('Content-Type: text/html\n')
  conn.send('Connection: close\n\n')
  conn.sendall(response)
  conn.close()
示例#3
0
def webserver_run(s):
    printLog("> web server run:")
    while trySetup:
        webconn(s)
示例#4
0
def webserver_run(s):
    printLog("> run:")
    while True:
        webconn(s)
示例#5
0
def check_point(num, mess):
    printLog(num, mess)
    displMessage(mess)
    getFree(True)
示例#6
0
ampy -p /COM6 put ./hydroponics/iot_hydrop2.py main.py
"""

from time import sleep, sleep_ms
from urandom import randint
from machine import Pin, UART, RTC, Timer
from util.pinout import set_pinout
from util.octopus import getFree, map, printLog, printTitle, oled_init, time_init, getVer, get_hhmm, w
from hydroponics.send_data import send_data_post

ver = 0.51  # int(*100) > db
# last update 20.10.2019
getFree(True)

# --------------------------------
printLog(1, "boot device >")
pinout = set_pinout()
led_numpin = pinout.BUILT_IN_LED  # BUILT_IN_LED
dspin = Pin(pinout.ONE_WIRE_PIN)  # Dallas temperature
button3 = Pin(pinout.BUTT3_PIN, Pin.IN, Pin.PULL_UP)
#button3 = Pin(0, Pin.IN, Pin.PULL_UP) # test - boot pin
rtc = RTC()  # real time
tim1 = Timer(0)  # for main 10 sec timer
Debug = True

print("sensor_log2 - version: " + str(ver))
print(getVer())
#print(getGardenLibVer())
#deviceID = str(get_eui())

startLight = 0
示例#7
0
from time import sleep, sleep_ms
from math import log10
from urandom import randint
from machine import Pin, UART, RTC, Timer
from util.pinout import set_pinout
from util.octopus import getFree, map, printLog, printTitle, i2c_init, oled_init, time_init, getVer, get_hhmm, w
from hydroponics.hydroponic_database import HydroponicsDatabase
import _thread

ver = 0.56  # int(*100) > db
# last update 3.11.2019
getFree(True)

# --------------------------------
printLog(1, "boot device >")
pinout = set_pinout()
led_numpin = pinout.BUILT_IN_LED  # BUILT_IN_LED
dspin = Pin(pinout.ONE_WIRE_PIN)  # Dallas temperature
button3 = Pin(pinout.BUTT3_PIN, Pin.IN, Pin.PULL_UP)
#button3 = Pin(0, Pin.IN, Pin.PULL_UP) # test - boot pin
rtc = RTC()  # real time
tim1 = Timer(0)  # for main 10 sec timer
Debug = True

print("sensor_log2 - version: " + str(ver))
print(getVer())
#print(getGardenLibVer())
#deviceID = str(get_eui())

startLight = 0