Commit d77666c0 authored by sergio's avatar sergio Committed by Terry Ellison
Browse files

trailing spaces cleanup (#2659)

parent d7583040
......@@ -8,11 +8,11 @@ function M.run()
print("Running component triangle...")
local m
disp:setColor(0, 0, 80, 20)
disp:setColor(1, 60, 80, 20)
disp:setColor(2, 60, 120, 0)
disp:setColor(3, 0, 140, 30)
disp:setColor(3, 0, 140, 30)
disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight())
disp:setColor(255, 255, 255)
......@@ -23,7 +23,7 @@ function M.run()
while millis() < m do
disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127)+64)
disp:drawTriangle(
bit.rshift(lcg_rnd() * (disp:getWidth()), 8),
bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20,
......
......@@ -67,7 +67,7 @@ function set_clip_range()
h = h + 25
x = bit.rshift(lcg_rnd() * (disp:getWidth() - w), 8)
y = bit.rshift(lcg_rnd() * (disp:getHeight() - h), 8)
disp:setClipRange(x, y, w, h)
end
......
......@@ -64,7 +64,7 @@ function ic_body(x, y)
disp:setColor(2, 48, 48, 48)
disp:setColor(3, 30, 30, 30)
disp:drawGradientBox(x, y, w, h)
disp:setColor(0, 255, 168, 0)
--disp:setColor(0, 225, 168, 30)
disp:drawDisc(x+w-1, y+h/2-1, 7, bit.bor(ucg.DRAW_UPPER_LEFT, ucg.DRAW_LOWER_LEFT))
......@@ -79,16 +79,16 @@ end
function draw_ucg_logo()
local a, b
--ucg_Init(ucg, ucg_sdl_dev_cb, ucg_ext_none, (ucg_com_fnptr)0)
disp:setFont(ucg.font_ncenB24_tr)
--disp:setRotate270()
--disp:setClipRange(10,5,40,20)
a = 2
b = 3
disp:setColor(0, 135*a/b,206*a/b,250*a/b)
disp:setColor(1, 176*a/b,226*a/b,255*a/b)
disp:setColor(2, 25*a/b,25*a/b,112*a/b)
......@@ -118,7 +118,7 @@ function draw_ucg_logo()
upper_pin(7+1*14, 4)
upper_pin(7+2*14, 4)
upper_pin(7+3*14, 4)
ic_body(2, 10)
lower_pin(7+0*14, 41)
......
......@@ -6,7 +6,7 @@
--
-- MIT license, http://opensource.org/licenses/MIT
-- ***************************************************************************
local moduleName = ...
local moduleName = ...
local M = {}
_G[moduleName] = M
--I2C slave address of GY-30
......
......@@ -24,7 +24,7 @@ tmr.alarm(0, 60000, 1, function()
PostData = "[{\"Name\":\"T\",\"Value\":\"" ..(l / 100).."."..(l % 100).."\"}]"
--创建一个TCP连接 Create a TCP Connection
socket=net.createConnection(net.TCP, 0)
--域名解析IP地址并赋值 DNS...it
--域名解析IP地址并赋值 DNS...it
socket:dns("www.lewei50.com", function(conn, ip)
ServerIP = ip
print("Connection IP:" .. ServerIP)
......
......@@ -21,24 +21,24 @@ t:enable_debug()
file.remove("ds18b20_save.lc") -- remove saved addresses
print("=============================================", node.heap())
print("first call, no addresses in flash, search is performed")
t:read_temp(readout, pin, t.C)
t:read_temp(readout, pin, t.C)
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
print("=============================================", node.heap())
print("second readout, no new search, found addresses are used")
t:read_temp(readout, pin)
t:read_temp(readout, pin)
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
print("=============================================", node.heap())
print("force search again")
t:read_temp(readout, pin, nil, true)
t:read_temp(readout, pin, nil, true)
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
print("=============================================", node.heap())
print("save search results")
t:read_temp(readout, pin, nil, false, true)
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
tmr.create():alarm(2000, tmr.ALARM_SINGLE, function()
print("=============================================", node.heap())
print("use saved addresses")
t.sens={}
......
......@@ -7,10 +7,10 @@
local modname = ...
-- Used modules and functions
local table, string, ow, tmr, print, type, tostring, pcall, ipairs =
local table, string, ow, tmr, print, type, tostring, pcall, ipairs =
table, string, ow, tmr, print, type, tostring, pcall, ipairs
-- Local functions
local ow_setup, ow_search, ow_select, ow_read, ow_read_bytes, ow_write, ow_crc8, ow_reset, ow_reset_search, ow_skip, ow_depower =
local ow_setup, ow_search, ow_select, ow_read, ow_read_bytes, ow_write, ow_crc8, ow_reset, ow_reset_search, ow_skip, ow_depower =
ow.setup, ow.search, ow.select, ow.read, ow.read_bytes, ow.write, ow.crc8, ow.reset, ow.reset_search, ow.skip, ow.depower
local node_task_post, node_task_LOW_PRIORITY = node.task.post, node.task.LOW_PRIORITY
local string_char, string_dump = string.char, string.dump
......@@ -44,7 +44,7 @@ local function to_string(addr, esc)
if type(addr) == 'string' and #addr == 8 then
return ( esc == true and
'"\\%u\\%u\\%u\\%u\\%u\\%u\\%u\\%u"' or
'%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8))
'%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8))
else
return tostring(addr)
end
......@@ -65,21 +65,21 @@ local function readout(self)
local t=(data:byte(1)+data:byte(2)*256)
-- t is actually signed so process the sign bit and adjust for fractional bits
-- the DS18B20 family has 4 fractional bits and the DS18S20s, 1 fractional bit
t = ((t <= 32767) and t or t - 65536) *
((addr:byte(1) == DS18B20FAMILY) and 625 or 5000)
t = ((t <= 32767) and t or t - 65536) *
((addr:byte(1) == DS18B20FAMILY) and 625 or 5000)
if 1/2 == 0 then
-- integer version
if unit == 'F' then
t = (t * 18)/10 + 320000
elseif unit == 'K' then
t = t + 2731500
end
end
local sgn = t<0 and -1 or 1
local tA = sgn*t
local tH=tA/10000
local tL=(tA%10000)/1000 + ((tA%1000)/100 >= 5 and 1 or 0)
if tH and (t~=850000) then
temp[addr]=(sgn<0 and "-" or "")..tH.."."..tL
debugPrint(to_string(addr),(sgn<0 and "-" or "")..tH.."."..tL)
......@@ -94,7 +94,7 @@ local function readout(self)
t = t * 18/10 + 32
elseif unit == 'K' then
t = t + 27315/100
end
end
self.temp[addr]=t
debugPrint(to_string(addr), t)
status[i] = 2
......@@ -104,12 +104,12 @@ local function readout(self)
end
next = next or status[i] == 0
end
if next then
if next then
node_task_post(node_task_LOW_PRIORITY, function() return conversion(self) end)
else
--sens = {}
if cb then
node_task_post(node_task_LOW_PRIORITY, function() return cb(temp) end)
node_task_post(node_task_LOW_PRIORITY, function() return cb(temp) end)
end
end
end
......@@ -144,20 +144,20 @@ local function _search(self, lcb, lpin, search, save)
self.temp = {}
if search then self.sens = {}; status = {} end
local temp = self.temp
local sens = self.sens
local sens = self.sens
pin = lpin or pin
local addr
if not search and #sens == 0 then
-- load addreses if available
debugPrint ("geting addreses from flash")
local s,check,a = pcall(dofile, "ds18b20_save.lc")
if s and check == "ds18b20" then
if s and check == "ds18b20" then
for i = 1, #a do sens[i] = a[i] end
end
debugPrint (#sens, "addreses found")
end
ow_setup(pin)
if search or #sens == 0 then
ow_reset_search(pin)
......@@ -188,13 +188,13 @@ local function _search(self, lcb, lpin, search, save)
-- save sensor addreses
if save then
debugPrint ("saving addreses to flash")
local addr_list = {}
for i =1, #sens do
for i =1, #sens do
local s = sens[i]
addr_list[i] = to_string(s:sub(1,8), true)..('.."\\%u"'):format(s:byte(9))
end
local save_statement = 'return "ds18b20", {' .. table_concat(addr_list, ',') .. '}'
local save_statement = 'return "ds18b20", {' .. table_concat(addr_list, ',') .. '}'
debugPrint (save_statement)
local save_file = file_open("ds18b20_save.lc","w")
save_file:write(string_dump(loadstring(save_statement)))
......@@ -211,7 +211,7 @@ local function read_temp(self, lcb, lpin, lunit, force_search, save_search)
cb, unit = lcb, lunit or unit
_search(self, function() return conversion(self) end, lpin, force_search, save_search)
end
-- Set module name as parameter of require and return module table
local M = {
sens = {},
......
---
-- Working Example: https://www.youtube.com/watch?v=PDxTR_KJLhc
-- IMPORTANT: run node.compile("imap.lua") after uploading this script
-- IMPORTANT: run node.compile("imap.lua") after uploading this script
-- to create a compiled module. Then run file.remove("imap.lua")
-- @name imap
-- @description An IMAP 4rev1 module that can be used to read email.
-- @description An IMAP 4rev1 module that can be used to read email.
-- Tested on NodeMCU 0.9.5 build 20150213.
-- @date March 12, 2015
-- @author Miguel
-- GitHub: https://github.com/AllAboutEE
-- @author Miguel
-- GitHub: https://github.com/AllAboutEE
-- YouTube: https://www.youtube.com/user/AllAboutEE
-- Website: http://AllAboutEE.com
--
......@@ -15,11 +15,11 @@
-- "How to test an IMAP server by using telnet" http://www.anta.net/misc/telnet-troubleshooting/imap.shtml
-- "RFC 2060 - Internet Message Access Protocol - Version 4rev1" http://www.faqs.org/rfcs/rfc2060.html
-------------------------------------------------------------------------------------------------------------
local moduleName = ...
local moduleName = ...
local M = {}
_G[moduleName] = M
_G[moduleName] = M
local USERNAME = ""
local USERNAME = ""
local PASSWORD = ""
local SERVER = ""
......@@ -44,7 +44,7 @@ end
---
-- @name display
-- @description A generic IMAP response processing function.
-- @description A generic IMAP response processing function.
-- Can disply the IMAP response if DEBUG is set to true.
-- Sets the reponse processed variable to true when the string "complete"
-- is found in the IMAP reply/response
......@@ -55,7 +55,7 @@ local function display(socket, response)
print(response)
end
-- Some IMAP responses are long enough that they will cause the display
-- Some IMAP responses are long enough that they will cause the display
-- function to be called several times. One thing is certain, IMAP will replay with
-- "<tag> OK <command> complete" when it's done sending data back.
if(string.match(response,'complete') ~= nil) then
......@@ -64,7 +64,7 @@ local function display(socket, response)
end
---
---
-- @name config
-- @description Initiates the IMAP settings
function M.config(username,password,tag,debug)
......@@ -78,7 +78,7 @@ end
-- @name login
-- @descrpiton Logs into a new email session
function M.login(socket)
response_processed = false -- we are sending a new command
response_processed = false -- we are sending a new command
-- which means that the response for it has not been processed
socket:send(TAG .. " LOGIN " .. USERNAME .. " " .. PASSWORD .. "\r\n")
socket:on("receive",display)
......@@ -92,7 +92,7 @@ function M.get_most_recent_num()
end
---
-- @name set_most_recent_num
-- @name set_most_recent_num
-- @description Gets the most recent email number from the EXAMINE command.
-- i.e. if EXAMINE returns "* 4 EXISTS" this means that there are 4 emails,
-- so the latest/newest will be identified by the number 4
......@@ -105,7 +105,7 @@ local function set_most_recent_num(socket,response)
local _, _, num = string.find(response,"([0-9]+) EXISTS(\.)") -- the _ and _ keep the index of the string found
-- but we don't care about that.
if(num~=nil) then
if(num~=nil) then
most_recent_num = num
end
......@@ -133,7 +133,7 @@ end
---
-- @name set_header
-- @description Records the IMAP header field response in a variable
-- @description Records the IMAP header field response in a variable
-- so that it may be read later
local function set_header(socket,response)
if(DEBUG) then
......@@ -162,14 +162,14 @@ end
---
-- @name get_body
-- @return The last email read's body
-- @return The last email read's body
function M.get_body()
return body
end
---
-- @name set_body
-- @description Records the IMAP body response in a variable
-- @description Records the IMAP body response in a variable
-- so that it may be read later
local function set_body(socket,response)
......
......@@ -7,19 +7,19 @@
me to bias towards clarity of coding over brevity. It includes extra logic
to handle some of the edge case issues more robustly. It also uses a
standard forward reference coding pattern to allow the code to be laid out
in main routine, subroutine order.
in main routine, subroutine order.
The app will only call one FTP.open() or FTP.createServer() at any time,
with any multiple calls requected, so FTP is a singleton static object.
However there is nothing to stop multiple clients connecting to the FTP
listener at the same time, and indeed some FTP clients do use multiple
connections, so this server can accept and create multiple CON objects.
The app will only call one FTP.open() or FTP.createServer() at any time,
with any multiple calls requected, so FTP is a singleton static object.
However there is nothing to stop multiple clients connecting to the FTP
listener at the same time, and indeed some FTP clients do use multiple
connections, so this server can accept and create multiple CON objects.
Each CON object can also have a single DATA connection.
Note that FTP also exposes a number of really private properties (which
Note that FTP also exposes a number of really private properties (which
could be stores in local / upvals) as FTP properties for debug purposes.
]]
local file,net,wifi,node,string,table,tmr,pairs,print,pcall, tostring =
local file,net,wifi,node,string,table,tmr,pairs,print,pcall, tostring =
file,net,wifi,node,string,table,tmr,pairs,print,pcall, tostring
local post = node.task.post
local FTP, cnt = {client = {}}, 0
......@@ -33,13 +33,13 @@ local processDataCmds -- function(cxt, cmd, arg)
local dataServer -- function(cxt, n)
local ftpDataOpen -- function(dataSocket)
-- Note these routines all used hoisted locals such as table and debug as
-- Note these routines all used hoisted locals such as table and debug as
-- upvals for performance (ROTable lookup is slow on NodeMCU Lua), but
-- data upvals (e.g. FTP) are explicitly list is -- "upval:" comments.
-- Note that the space between debug and the arglist is there for a reason
-- so that a simple global edit " debug(" -> "-- debug(" or v.v. to
-- toggle debug compiled into the module.
-- so that a simple global edit " debug(" -> "-- debug(" or v.v. to
-- toggle debug compiled into the module.
local function debug (fmt, ...) -- upval: cnt (, print, node, tmr)
if not FTP.debug then return end
......@@ -50,7 +50,7 @@ local function debug (fmt, ...) -- upval: cnt (, print, node, tmr)
end
--------------------------- Set up the FTP object ----------------------------
-- FTP has three static methods: open, createServer and close
-- FTP has three static methods: open, createServer and close
------------------------------------------------------------------------------
-- optional wrapper around createServer() which also starts the wifi session
......@@ -82,9 +82,9 @@ function FTP.createServer(user, pass, dbgFlag) -- upval: FTP (, debug, tostring
FTP.server:listen(21, function(sock) -- upval: FTP (, debug, pcall, type, processCommand)
-- since a server can have multiple connections, each connection
-- has a CNX table to store connection-wide globals.
local client = FTP.client
local client = FTP.client
local CNX; CNX = {
validUser = false,
validUser = false,
cmdSocket = sock,
send = function(rec, cb) -- upval: CNX (,debug)
-- debug("Sending: %s", rec)
......@@ -107,11 +107,11 @@ function FTP.createServer(user, pass, dbgFlag) -- upval: FTP (, debug, tostring
-- debug("Authorising: %s", data)
local cmd, arg = data:match('([A-Za-z]+) *([^\r\n]*)')
local msg = "530 Not logged in, authorization required"
cmd = cmd:upper()
cmd = cmd:upper()
if cmd == 'USER' then
CNX.validUser = (arg == FTP.user)
msg = CNX.validUser and
msg = CNX.validUser and
"331 OK. Password required" or
"530 user not found"
......@@ -133,7 +133,7 @@ function FTP.createServer(user, pass, dbgFlag) -- upval: FTP (, debug, tostring
return CNX.send(msg)
end
local port,ip = sock:getpeer()
-- debug("Connection accepted: (userdata) %s client %s:%u", tostring(sock), ip, port)
sock:on("receive", validateUser)
......@@ -162,17 +162,17 @@ function FTP.close() -- upval: FTP (, debug, post, tostring)
FTP,_G.FTP = nil, nil -- the upval FTP can only be zeroed once FTP.client is cleared.
end
end
if svr then rollupClients(FTP.client, svr) end
package.loaded.ftpserver=nil
end -- FTP.close()
----------------------------- Process Command --------------------------------
-- This splits the valid commands into one of three categories:
-- This splits the valid commands into one of three categories:
-- * bare commands (which take no arg)
-- * simple commands (which take) a single arg; and
-- * data commands which initiate data transfer to or from the client and
-- * simple commands (which take) a single arg; and
-- * data commands which initiate data transfer to or from the client and
-- hence need to use CBs.
--
-- Find strings are used do this lookup and minimise long if chains.
......@@ -184,9 +184,9 @@ processCommand = function(cxt, sock, data) -- upvals: (, debug, processBareCmds,
local cmd, arg = data:match('([a-zA-Z]+) *(.*)')
cmd = cmd:upper()
local _cmd_ = '_'..cmd..'_'
if ('_CDUP_NOOP_PASV_PWD_QUIT_SYST_'):find(_cmd_) then
processBareCmds(cxt, cmd)
processBareCmds(cxt, cmd)
elseif ('_CWD_DELE_MODE_PORT_RNFR_RNTO_SIZE_TYPE_'):find(_cmd_) then
processSimpleCmds(cxt, cmd, arg)
elseif ('_LIST_NLST_RETR_STOR_'):find(_cmd_) then
......@@ -212,15 +212,15 @@ processBareCmds = function(cxt, cmd) -- upval: (dataServer)
-- This FTP implementation ONLY supports PASV mode, and the passive port
-- listener is opened on receipt of the PASV command. If any data xfer
-- commands return an error if the PASV command hasn't been received.
-- Note the listener service is closed on receipt of the next PASV or
-- quit.
-- Note the listener service is closed on receipt of the next PASV or
-- quit.
local ip, port, pphi, pplo, i1, i2, i3, i4, _
_,ip = cxt.cmdSocket:getaddr()
port = 2121
pplo = port % 256
pphi = (port-pplo)/256
i1,i2,i3,i4 = ip:match("(%d+).(%d+).(%d+).(%d+)")
dataServer(cxt, port)
dataServer(cxt, port)
return send(
('227 Entering Passive Mode(%d,%d,%d,%d,%d,%d)'):format(
i1,i2,i3,i4,pphi,pplo))
......@@ -230,16 +230,16 @@ processBareCmds = function(cxt, cmd) -- upval: (dataServer)
elseif cmd == 'QUIT' then
send("221 Goodbye", function() cxt.close(cxt.cmdSocket) end)
return
return
elseif cmd == 'SYST' then
-- return send("215 UNKNOWN")
return send("215 UNIX Type: L8") -- must be Unix so ls is parsed correctly
else
error('Oops. Missed '..cmd)
error('Oops. Missed '..cmd)
end
end -- processBareCmds(cmd, send)
end -- processBareCmds(cmd, send)
------------------------- Process Simple Commands ----------------------------
local from -- needs to persist between simple commands
......@@ -264,11 +264,11 @@ processSimpleCmds = function(cxt, cmd, arg) -- upval: from (, file, tostring, d
return send("200 TYPE is now 8-bit binary")
else
return send("504 Unknown TYPE")
end
end
end
-- The remaining commands take a filename as an arg. Strip off leading / and ./
arg = arg:gsub('^%.?/',''):gsub('^%.?/','')
arg = arg:gsub('^%.?/',''):gsub('^%.?/','')
debug("Filename is %s",arg)
if cmd == 'CWD' then
......@@ -279,7 +279,7 @@ processSimpleCmds = function(cxt, cmd, arg) -- upval: from (, file, tostring, d
elseif cmd == 'DELE' then
if file.exists(arg) then
file.remove(arg)
file.remove(arg)
if not file.exists(arg) then return send("250 Deleted "..arg) end
end
return send("550 Requested action not taken")
......@@ -297,11 +297,11 @@ processSimpleCmds = function(cxt, cmd, arg) -- upval: from (, file, tostring, d
"550 Requested action not taken")
elseif cmd == "SIZE" then
local st = file.stat(arg)
return send(st and ("213 "..st.size) or
return send(st and ("213 "..st.size) or
"550 Could not get file size.")
else
error('Oops. Missed '..cmd)
error('Oops. Missed '..cmd)
end
end -- processSimpleCmds(cmd, arg, send)
......@@ -318,12 +318,12 @@ processDataCmds = function(cxt, cmd, arg) -- upval: FTP (, pairs, file, tostrin
cxt.getData, cxt.setData = nil, nil
arg = arg:gsub('^%.?/',''):gsub('^%.?/','')
arg = arg:gsub('^%.?/',''):gsub('^%.?/','')
if cmd == "LIST" or cmd == "NLST" then
-- There are
if cmd == "LIST" or cmd == "NLST" then
-- There are
local fileSize, nameList, pattern = file.list(), {}, '.'
arg = arg:gsub('^-[a-z]* *', '') -- ignore any Unix style command parameters
arg = arg:gsub('^/','') -- ignore any leading /
......@@ -332,26 +332,26 @@ processDataCmds = function(cxt, cmd, arg) -- upval: FTP (, pairs, file, tostrin
end
for k,v in pairs(fileSize) do
if k:match(pattern) then
nameList[#nameList+1] = k
if k:match(pattern) then
nameList[#nameList+1] = k
else
fileSize[k] = nil
end
end
table.sort(nameList)
function cxt.getData() -- upval: cmd, fileSize, nameList (, table)
local list, user, v = {}, FTP.user
for i = 1,10 do
if #nameList == 0 then break end
local f = table.remove(nameList, 1)
list[#list+1] = (cmd == "LIST") and
list[#list+1] = (cmd == "LIST") and
("-rw-r--r-- 1 %s %s %6u Jan 1 00:00 %s\r\n"):format(user, user, fileSize[f], f) or
(f.."\r\n")
end
return table.concat(list)
end
elseif cmd == "RETR" then
local f = file.open(arg, "r")
if f then -- define a getter to read the file
......@@ -379,7 +379,7 @@ processDataCmds = function(cxt, cmd, arg) -- upval: FTP (, pairs, file, tostrin
send((cxt.getData or cxt.setData) and "150 Accepted data connection" or
"451 Can't open/create "..arg)
if cxt.getData and cxt.dataSocket then
if cxt.getData and cxt.dataSocket then
debug ("poking sender to initiate first xfer")
post(function() cxt.sender(cxt.dataSocket) end)
end
......@@ -389,17 +389,17 @@ end -- processDataCmds(cmd, arg, send)
----------------------------- Data Port Routines -----------------------------
-- These are used to manage the data transfer over the data port. This is
-- set up lazily either by a PASV or by the first LIST NLST RETR or STOR
-- set up lazily either by a PASV or by the first LIST NLST RETR or STOR
-- command that uses it. These also provide a sendData / receiveData cb to
-- handle the actual xfer. Also note that the sending process can be primed in
--
---------------- Open a new data server and port ---------------------------
dataServer = function(cxt, n) -- upval: (pcall, net, ftpDataOpen, debug, tostring)
local dataServer = cxt.dataServer
if dataServer then -- close any existing listener
pcall(dataServer.close, dataServer)
if dataServer then -- close any existing listener
pcall(dataServer.close, dataServer)
end
if n then
if n then
-- Open a new listener if needed. Note that this is only used to establish
-- a single connection, so ftpDataOpen closes the server socket
cxt.dataServer = net.createServer(net.TCP, 300)
......@@ -423,7 +423,7 @@ ftpDataOpen = function(cxt, dataSocket) -- upval: (debug, tostring, post, pcall)
cxt.dataServer:close()
cxt.dataServer = nil
local function cleardown(skt,type) -- upval: cxt (, debug, tostring, post, pcall)
type = type==1 and "disconnection" or "reconnection"
local which = cxt.setData and "setData" or (cxt.getData and cxt.getData or "neither")
......@@ -431,7 +431,7 @@ ftpDataOpen = function(cxt, dataSocket) -- upval: (debug, tostring, post, pcall)
if cxt.setData then
cxt.fileClose()
cxt.setData = nil
cxt.setData = nil
cxt.send("226 Transfer complete.")
else
cxt.getData, cxt.sender = nil, nil
......@@ -453,12 +453,12 @@ ftpDataOpen = function(cxt, dataSocket) -- upval: (debug, tostring, post, pcall)
if not on_hold then
-- Cludge to stop the client flooding the ESP SPIFFS on an upload of a
-- large file. As soon as a record arrives assert a flow control hold.
-- large file. As soon as a record arrives assert a flow control hold.
-- This can take up to 5 packets to come into effect at which point the
-- low priority unhold task is executed releasing the flow again.
-- debug("Issuing hold on data socket %s", tostring(skt))
skt:hold(); on_hold = true
post(node.task.LOW_PRIORITY,
post(node.task.LOW_PRIORITY,
function() -- upval: skt, on_hold (, debug, tostring))
-- debug("Issuing unhold on data socket %s", tostring(skt))
pcall(skt.unhold, skt); on_hold = false
......@@ -484,7 +484,7 @@ ftpDataOpen = function(cxt, dataSocket) -- upval: (debug, tostring, post, pcall)
-- debug("Send of data completed")
skt:close()
cxt.send("226 Transfer complete.")
cxt.getData, cxt.dataSocket = nil, nil
cxt.getData, cxt.dataSocket = nil, nil
end
end
......@@ -496,7 +496,7 @@ ftpDataOpen = function(cxt, dataSocket) -- upval: (debug, tostring, post, pcall)
if cxt.getData then cxt.sender(cxt.dataSocket) end
end -- ftpDataOpen(socket)
------------------------------------------------ -----------------------------
return FTP
-------------------------------------------------------
-- This library was written for the Texas Instruments
-- HDC1000 temperature and humidity sensor.
-- This library was written for the Texas Instruments
-- HDC1000 temperature and humidity sensor.
-- It should work for the HDC1008 too.
-- Written by Francesco Truzzi (francesco@truzzi.me)
-- Released under GNU GPL v2.0 license.
......
......@@ -3,7 +3,7 @@
--
-- Written by Levente Tamas <levente.tamas@navicron.com>
--
-- modify by Garberoglio Leonardo <leogarberoglio@gmail.com>
-- modify by Garberoglio Leonardo <leogarberoglio@gmail.com>
--
-- GNU LGPL, see https://www.gnu.org/copyleft/lesser.html
-- ******************************************************
......@@ -38,7 +38,7 @@ local function read_reg(reg_addr, len)
end
i2c.stop(id)
return ret
end
end
--write reg with data table
local function write_reg(reg_addr, data)
......@@ -47,7 +47,7 @@ local function write_reg(reg_addr, data)
i2c.write(id, reg_addr)
i2c.write(id, data)
i2c.stop(id)
end
end
--write comparison reg with 2 bytes
local function write_comp_reg(reg_addr, msb, lsb)
......@@ -55,9 +55,9 @@ local function write_comp_reg(reg_addr, msb, lsb)
i2c.address(id, address, i2c.TRANSMITTER)
i2c.write(id, reg_addr)
i2c.write(id, msb)
i2c.write(id, lsb)
i2c.write(id, lsb)
i2c.stop(id)
end
end
-- initialize i2c
-- a: i2c addr 0x48|A1<<1|A0 (A0-A1: chip pins)
function M.setup(a)
......@@ -70,7 +70,7 @@ function M.setup(a)
print("device not found")
return nil
end
else
else
print("wrong i2c address") return nil
end
end
......
......@@ -3,15 +3,15 @@
-- MCP23008 Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21919e.pdf
-- Tested on NodeMCU 0.9.5 build 20150213.
-- @date March 02, 2015
-- @author Miguel
-- GitHub: https://github.com/AllAboutEE
-- @author Miguel
-- GitHub: https://github.com/AllAboutEE
-- YouTube: https://www.youtube.com/user/AllAboutEE
-- Website: http://AllAboutEE.com
--------------------------------------------------------------------------------
local moduleName = ...
local moduleName = ...
local M = {}
_G[moduleName] = M
_G[moduleName] = M
-- Constant device address.
local MCP23008_ADDRESS = 0x20
......@@ -84,10 +84,10 @@ end
---
--! @name begin
--! @description Sets the MCP23008 device address's last three bits.
-- Note: The address is defined as binary 0100[A2][A1][A0] where
-- A2, A1, and A0 are defined by the connection of the pins,
-- e.g. if the pins are connected all to GND then the paramter address
--! @description Sets the MCP23008 device address's last three bits.
-- Note: The address is defined as binary 0100[A2][A1][A0] where
-- A2, A1, and A0 are defined by the connection of the pins,
-- e.g. if the pins are connected all to GND then the paramter address
-- will need to be 0x0.
-- @param address The 3 least significant bits (LSB) of the address
-- @param pinSDA The pin to use for SDA
......@@ -140,8 +140,8 @@ end
---
-- @name writeGPPU The byte to write to the GPPU
-- @description Writes a byte of data to the
-- PULL-UP RESISTOR CONFIGURATION (GPPU)REGISTER
-- @description Writes a byte of data to the
-- PULL-UP RESISTOR CONFIGURATION (GPPU)REGISTER
-- @param databyte the value to write to the GPPU register.
-- each bit in this byte is assigned to an individual GPIO pin
-- @return void
......
......@@ -17,9 +17,9 @@ yeelink.init(23333,23333,"You api-key",function() --Step3: Register the callbac
print("Yeelink Init OK...")
tmr.alarm(1,60000,1,function() --Step4: Have fun~ (Update your data)
dht.read(4)
yeelink.update(dht.getTemperature())
end)
end)
......@@ -34,7 +34,7 @@ if wifi.sta.getip() == nil then
tmr.alarm(1,1000,1,function ()
if wifi.sta.getip() ~= nil then
tmr.stop(1)
sk:dns("api.yeelink.net",function(conn,ip)
sk:dns("api.yeelink.net",function(conn,ip)
dns=ip
print("DNS YEELINK OK... IP: "..dns)
end)
......@@ -42,7 +42,7 @@ if wifi.sta.getip() == nil then
end)
end
sk:dns("api.yeelink.net",function(conn,ip)
sk:dns("api.yeelink.net",function(conn,ip)
dns=ip
......@@ -74,8 +74,8 @@ end
--========Check the DNS Status===========
--if DNS success, return the address(string)
--if DNS fail(or processing), return nil
--
--
--
--
--========================================
function M.getDNS()
......@@ -96,11 +96,11 @@ function M.update(_datapoint)
datapoint = tostring(_datapoint)
sk:on("connection", function(conn)
sk:on("connection", function(conn)
print("connect OK...")
print("connect OK...")
local a=[[{"value":]]
local b=[[}]]
......@@ -116,10 +116,10 @@ function M.update(_datapoint)
end)
sk:on("receive", function(sck, content)
sk:on("receive", function(sck, content)
if debug then
print("\r\n"..content.."\r\n")
print("\r\n"..content.."\r\n")
else
print("Date Receive")
end
......
#################################################################
# This file is configured in RTD -> Admin -> Advanced Settings! #
#################################################################
# Enforce a specific MkDocs version by using the standard pip requirements.txt syntax
# Enforce a specific MkDocs version by using the standard pip requirements.txt syntax
# mkdocs >= 0.16.3, < 0.17
......@@ -6,7 +6,7 @@ FSSOURCE ?= ../local/fs
LUASOURCE ?= ../local/lua
FLASHSIZE ?= 4mb 32mb 8mb
FLASH_SW = -S
SUBDIRS =
SUBDIRS =
OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump)
......@@ -25,14 +25,14 @@ FLASH_FS_SIZE := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPI
ifneq ($(strip $(FLASH_FS_SIZE)),)
FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
FLASH_SW = -c
endif
endif
FLASH_FS_LOC := $(shell $(CC) -E -dM - <../app/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
ifeq ($(strip $(FLASH_FS_LOC)),)
FLASH_FS_LOC := $(shell printf "0x%x" $$((0x$(shell $(OBJDUMP) -t ../app/.output/eagle/debug/image/eagle.app.v6.out |grep " _flash_used_end" |cut -f1 -d" ") - 0x40200000)))
else
else
FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
endif
endif
LFSSOURCES := $(wildcard $(LUASOURCE)/*.lua)
......@@ -58,7 +58,7 @@ TEST:
@echo $(FLASH_FS_LOC)
@echo $(FLASH_USED_END)
spiffsimg/spiffsimg:
spiffsimg/spiffsimg:
.PHONY: spiffsimg
......@@ -67,8 +67,8 @@ spiffsimg/spiffsimg:
spiffsimg: spiffsimg/spiffsimg
@echo Built spiffsimg in spiffsimg/spiffsimg
spiffsimg/spiffsimg:
@$(MAKE) -C spiffsimg
spiffsimg/spiffsimg:
@$(MAKE) -C spiffsimg
spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
rm -f ./spiffsimg/spiffs.lst
......@@ -81,7 +81,7 @@ ifneq ($(LFSSOURCES),)
LFSimage: $(LFSSOURCES)
$(LUAC_CROSS) -f -o $(FSSOURCE)/LFS.img $(LFSSOURCES)
else
LFSimage:
LFSimage:
rm -f $(FSSOURCE)/LFS.img
endif
......
......@@ -7,7 +7,7 @@ class Cert(object):
self.len = len(buff)
self.buff = buff
pass
def __str__(self):
out_str = ['\0']*32
for i in range(len(self.name)):
......
......@@ -11,7 +11,7 @@ class Cert(object):
self.len = len(buff)
self.buff = buff
pass
def __str__(self):
out_str = ['\0']*32
for i in range(len(self.name)):
......@@ -26,11 +26,11 @@ class Cert(object):
def main():
parser = argparse.ArgumentParser(description='Convert PEM file(s) into C source file.')
parser.add_argument('--section',
parser.add_argument('--section',
default='.servercert.flash',
help='specify the section for the data (default is .servercert.flash)')
parser.add_argument('--name',
parser.add_argument('--name',
default='tls_server_cert_area',
help='specify the variable name for the data (default is tls_server_cert_area)')
......
......@@ -4,12 +4,12 @@
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
......@@ -22,7 +22,7 @@
PROJECT_NAME="Nodemcu Project"
# Generate the openssl configuration files.
cat > ca_cert.conf << EOF
cat > ca_cert.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
......@@ -31,7 +31,7 @@ prompt = no
O = $PROJECT_NAME Dodgy Certificate Authority
EOF
cat > certs.conf << EOF
cat > certs.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
......@@ -41,7 +41,7 @@ prompt = no
CN = Nodemcu Client cert
EOF
cat > device_cert.conf << EOF
cat > device_cert.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
......@@ -61,7 +61,7 @@ openssl rsa -in TLS.key_2048.pem -out TLS.key_2048 -outform DER
openssl req -out TLS.ca_x509.req -sha256 -key TLS.ca_key.pem -new \
-config ./ca_cert.conf
openssl req -out TLS.x509_2048.req -sha256 -key TLS.key_2048.pem -new \
-config ./certs.conf
-config ./certs.conf
# generate the actual certs.
openssl x509 -req -in TLS.ca_x509.req -sha256 -out TLS.ca_x509.pem \
......
......@@ -143,7 +143,7 @@ static void import (char *src, char *dst)
if (SPIFFS_write (&fs, fh, buff, n) < 0)
die ("spiffs_write");
if (SPIFFS_close (&fs, fh) < 0)
if (SPIFFS_close (&fs, fh) < 0)
die("spiffs_close");
close (fd);
}
......@@ -199,7 +199,7 @@ void syntax (void)
exit (1);
}
static size_t getsize(const char *s)
static size_t getsize(const char *s)
{
char *end = 0;
size_t val = strtoul(s, &end, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment