<repo_name>lishaodan/ESP8266<file_sep>/wifi_net/script2.lua
test git

commit

append text 2 1242342
asfdafsd

test the git
<file_sep>/wifi_net/init.lua
pin1 = 4
gpio.mode(pin1, gpio.OUTPUT)
pin2 = 3
gpio.mode(pin2, gpio.OUTPUT)

wifi.setmode(wifi.STATIONAP)
cfg={}
cfg.ssid="DANBAO"
cfg.pwd="<PASSWORD>"
wifi.ap.config(cfg)

sv = net.createServer(net.TCP, 30)

if sv then
  sv:listen(9000, function(conn)
    print(conn:getaddr())
    conn:on("receive", function(sck, data)
        print(data)
        --conn:send(data)
        --print(a)
        if (data == "open\n") then
            print("pin is open")
            conn:send("ECHO： pin is open\n")
            gpio.write(pin1, gpio.HIGH)
            gpio.write(pin2, gpio.HIGH)
        elseif (data == "close\n") then
            print("pin is close")
            conn:send("ECHO： pin is close\n")
            gpio.write(pin1, gpio.LOW)
            gpio.write(pin2, gpio.LOW)
        end
    end)
    conn:send("hello world")
  end)
end
<file_sep>/dht11/init.lua
wifi.setmode(wifi.STATIONAP)
cfg={}
cfg.ssid="DANBAO"
cfg.pwd="<PASSWORD>"
wifi.ap.config(cfg)

pin = 4
sv = net.createServer(net.TCP, 30)

if sv then
  sv:listen(9000, function(conn)
    print(conn:getaddr())
    conn:on("receive", function(sck, data)
        print(data)
        conn:send(data)
        if (data == "send\n") then
        -------------------------------------
            status, temp, humi, temp_dec, humi_dec = dht.read(pin)
            if status == dht.OK then
                -- Integer firmware using this example
                text_data=string.format("DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n",
                      math.floor(temp),
                      temp_dec,
                      math.floor(humi),
                      humi_dec
                      )    
                print(text_data)
            elseif status == dht.ERROR_CHECKSUM then
                print( "DHT Checksum error." )
            elseif status == dht.ERROR_TIMEOUT then
                print( "DHT timed out." )
            end
            ------------------------------------------     
            conn:send(text_data)
        end
    end)
    conn:send("hello world")
  end)
end
