Abhinav Sinha 10 лет назад
Родитель
Сommit
3915b09aa2
3 измененных файлов с 26 добавлено и 5 удалено
  1. 1 5
      init.lua
  2. 11 0
      interrupt.lua
  3. 14 0
      sendYo.lua

+ 1 - 5
init.lua

@@ -1,5 +1 @@
---This code assumes that the WIFI AP has already been set up
-sk=net.createConnection(net.TCP,0)
-sk:on("receive", function(sck, c) print(c) end )
-sk:connect(80, "api.justyo.co")
-sk:send("POST /yo/ HTTP/1.1\r\nHost: api.justyo.co\r\nConnection: close\r\nContent-Length: 63\r\nAccept: */*\r\nContent-type: application/x-www-form-urlencoded\r\n\r\napi_token=5f9f-99c680b7-48fd-9459-46cda7e1c8fa&username=EPUKAZA")
+dofile("interrupt.lua")

+ 11 - 0
interrupt.lua

@@ -0,0 +1,11 @@
+gpio.mode(3, gpio.INT, gpio.FLOAT)
+delay = 0
+
+function sendYo(level)
+   x = tmr.now()
+   if x > delay then
+      delay = tmr.now()+250000
+      dofile("sendYo.lua")
+      end
+   end
+gpio.trig(3, "down",sendYo)

+ 14 - 0
sendYo.lua

@@ -0,0 +1,14 @@
+--This code assumes that the WIFI AP has already been set up
+sk = nil
+sk = net.createConnection(net.TCP,0)
+sk:on("receive", function(sck, c) print(c) end )
+sk:on("connection", function(sk, payload)
+						sk:send("POST /yo/ HTTP/1.1\r\n"
+							.."Host: api.justyo.co\r\n"
+							.."Connection: close\r\n"
+							.."Content-Length: 63\r\n"
+							.."Accept: */*\r\n"
+							.."Content-type: application/x-www-form-urlencoded\r\n\r\n"
+							.."api_token=99c680b7-5f9f-48fd-9459-46cda7e1c8fa&username=EPUKAZA")
+					end)
+sk:connect(80, "api.justyo.co")