@chendbdb
2018-03-19T10:48:15.000000Z
字数 10972
阅读 9881
XXTouch中控 XXTouch
请访问XXT 局域网中控进行获取最新版本以及更新的提示
Q:脚本启动后提示“中控访问超时”?
A:设备端无法连接中控锁监听的端口引起的问题。
R:确保使用中控启动且加入通讯API,且检查电脑端防火墙是否关闭。
Q:中控出现错误提示“基础链接已关闭,无法链接到远程服务器”?
A:一些用户在安装一些软件或是系统做某些修改后,采集器就没无登录或是无法获取到网页。
R:在开始键入 cmd,右键单击“cmd.exe”,单击“以管理员身份运行”,然后按“继续”。
在命令提示符处键入 netsh winsock reset,然后按 Enter。
Q:为什么有些电脑无法启动中控?
A:因为中控的开发使用 .NET 基础库,所以需使用中控也要同样的运行库。
R:请下载 .NET 4.0 版本,此处是下载地址。
Q:点击“搜索设备”特别卡?
A:网络环境搭建有问题。
R:可以考虑点击“搜索设备”旁的小三角“网段扫描”,点选“IP段列表”内对应IP,之后点击“TCP扫描”等待设备刷新出来进行解决。
PS:避免每次启动中控都需要扫描,当扫描妥当后,可勾选所有设备,点击“中控功能”内“导出勾选IP地址”项,下次重启中控后使用虑点击“搜索设备”旁的小三角“IP地址扫描”针对性添加设备。
Q:扫描设备扫描不全?
A:当设备没有点亮屏幕时,设备很有可能 Wifi 处于休眠状态。
R:请确保设备点亮屏幕。
Q:打开中控出现“配置系统未能初始化”错误提示框?
A:程序相对的配置文件“user.config”损坏引发的问题。
R:删除“C:\Users[用户名]\AppData\Local\XXTouch团队”或“C:\Documents and Settings[用户名]\Local Settings\Application Data\XXTouch团队”解决。
在无数据库的情况下会提示创建数据库与配置文件
| 目录或文件 | 类型 | 用途 |
|---|---|---|
| 1ferver | 目录 | 项目目录用于与设备端“1ferver”目录进行同步 |
| data | 目录 | 存放与设备进行交互的文件 |
| CC.mdb | 文件 | 数据库操作API进行访问对应数据库文件 |
| config.ini | 文件 | 缓存中控相关配置文件 |
- 结构例子会在以后中控中内置
- 针对目录的同步进行适配的文件夹.
- 脚本选择位置针对 "根目录" 相对的 "\1ferver\lua\scripts\" 文件夹下的脚本文件进行遍历,结构以 "项目名\main.xxt" 或 "项目名\main.lua" , 方可在中控端地址栏中进行点击 "地址栏" 中小三角进行选择为 "项目:项目名" 的脚本文件,启动统一按照 "main.xxt" 或 "main.lua" 为准.
- 可使用 "发送脚本" 旁小三角内菜单内 "同步目录" 按钮进行触发单向同步目录操作.
- 当选择 "根目录" 相对的 "\1ferver\lua\scripts\" 文件夹下项目脚本时(以"项目:"为开头的选择脚本的结构), "发送脚本" 按钮即改为 "同步文件" 此时点击也可以触发单向同步目录操作.
- 当点击发送脚本旁小三角内的同步目录后,此目录会和设备端的 "/1ferver" 目录进行同步,同步以中控端的结构为准.
- 同步规则如下:
| 设备端文件 | 中控端文件 | 同步规则 |
|---|---|---|
| 存在 | 存在 | 检测 "文件修改时间" 决定是否同步 |
| 存在 | 不存在 | 不同步且不删除 |
| 不存在 | 存在 | 同步 |
- 数据库是Access 数据库(如无操作过数据库经验不推荐折腾).
- 表结构需要以第一项"ID"为递增值,其他项为字符串(长度限制255).
- 以下是操作数据库的相关介绍.
- 根据自己需要进行调整.
- 新版中控默认会隐藏数据表("[Hide] Db_Tab=true").
[Hide]Db_Tab=true;用于隐藏数据表API_Tab=false;用于隐藏API表MadeUI_Tab=false;用于隐藏UI制作UI=false;用于隐藏UI功能
| 命令 | 解释 | 返回 | 示例 |
|---|---|---|---|
| CC.log(data) | 中控日志 | 无 |
|
| CC.web_file.update_file(CCfile, localfile) | 上传文件 | 无 |
|
| CC.web_file.down_file(CCfile, localfile) | 下载文件 | 无 |
|
| data = CC.web_file.take_line(CCfile) | 获取中控端文件第一行数据并删除 | 获取的第一行数据 |
|
| info = CC.web_file.exists(CCfile) | 用于判断一个路径是文件还是目录还是不存在 | "file" 或 "directory" 或 nil |
|
| success = CC.web_file.delete(CCfile) | 删除中控端文件 | 布尔型 成功:true 失败:false |
|
| list = CC.web_file.list(CCpath) | 获取中控端目录所有文件名列表 | 顺序表型 | nil 成功:目录文件列表 失败:nil |
|
| fsize = CC.web_file.size(CCfile) | 获得中控端一个文件的尺寸 | 整数型 | nil 成功:文件尺寸(单位: 字节) 失败:nil |
|
| data = CC.web_file.reads(CCfile) | 获得中控端一个文件中所有数据 | 字符串型 | nil 成功:文件的数据 失败:nil |
|
| success = CC.web_file.writes(CCfile, data) | 将数据覆盖写入到中控端文件 | 布尔型 成功:true 失败:false |
|
| success = CC.web_file.appends(CCfile, data) | 将数据追加写入到中控端文件 | 布尔型 成功:true 失败:false |
|
| linecount = CC.web_file.line_count(CCfile) | 统计一个文本文件的总行数 | 整数型 | nil 成功:文件总行数 失败:nil |
|
| line = CC.web_file.get_line(CCfile, line_number) | 获取一个文本文件指定行的数据 | 字符串型 | nil 成功:内容 失败:nil |
|
| success = CC.web_file.set_line(CCfile, line_number, data) | 设置文本文件指定行的内容 | 布尔型 成功:true 失败:false |
|
| success = CC.web_file.insert_line(CCfile, line_number, data) | 在文本文件指定行前插入内容 | 布尔型 成功:true 失败:false |
|
| success = CC.web_file.remove_line(CCfile, line_number) | 移除文件中指定行 | 布尔型 成功:true 失败:false |
|
| lines = CC.web_file.get_lines(CCfile) | 获取一个文本文件的所有行 | 顺序表型 | nil 返回一个顺序表,文件不存在返回 nil |
|
| success = CC.web_file.appends(CCfile, line_number, lines) | 将一个顺序表转换逐行插入到文件指定行前 | 布尔型 成功:true 失败:false |
|
| info = CC.web_directory.exists(CCdirectory) | 判断文件夹是否存在 | 布尔型 成功:true 失败:false |
|
| success = CC.web_directory.create(CCdirectory) | 在中控端创建一个文件夹 | 布尔型 成功:true 失败:false |
|
| success = CC.web_directory.delete(CCdirectory) | 在中控端删除一个文件夹 | 布尔型 成功:true 失败:false |
|
| CC.getui() | 获取当前中控UI的配置信息 | string |
|
| CC.db.add(table_name, {table_data}) | 添加数据库数据 | table |
|
| CC.db.del(table_name, {table_data}) | 删除数据库数据 | table |
|
| CC.db.edit(table_name, {table_data}) | 修改数据库内项 | table |
|
| CC.db.list(table_name, {select_table}) | 获取当前中控UI的配置信息 | table |
|
| CC.db.get(table_name, {select_table}) | 获取数据库数据(一项) | table |
|
local CC = {}doserver_ip = ''server_port = 0log_list = {}local post = function(_mode, mode, data)while true dolocal code, header, body = http.post(string.format('http://%s:%s/%s/%s',server_ip, server_port, _mode, mode),30,{},((type(data) == 'table' and json.encode(data)) or data))if code == 200 thenreturn ((type(json.decode(body) == 'table') and json.decode(body)) or body)elseif code ~= -1 thensys.toast('中控异常提示:' .. body)elsesys.toast('中控访问超时')endendendlocal encodeURI = function(s)return string.gsub(string.gsub(s, '([^%w%.%- ])', function(c) return string.format('%%%02X', string.byte(c)) end), ' ', '+')endlocal send_cc = function(db,m,t)local r = post('db', m, json.encode({db=db, data=t}))if r.state == 0 then return r.data;else sys.alert(r.message,5);return r.data;endendCC.set_server_ip = function(...)local ip_list = {}if type(select(1,...)) == 'table' thenip_list = select(1, ...)elseif type(select(1,...)) == 'string' thenip_list = {select(1, ...)}elseerror('提交的服务器IP不正确',2)endserver_port = select(2, ...) or 27010local socket = require('socket')local s = socket.tcp()s:settimeout(2)for k,v in ipairs(ip_list) dolocal s = socket.tcp()s:settimeout(2)if s:connect(string.format('%s',v), server_port) == 1 thenserver_ip = vendendif server_ip == '' thenerror('尝试提交的列表中未找到可连接的中控服务',2)endendCC.set_sever_ip = CC.set_server_ipCC.log = function(t)if type(t) == 'string' thenlog_list['日志'] = telseif type(t) == 'table' thenfor key, value in pairs(t) dolog_list[key] = valueendendhttp.post(string.format('http://%s:%s/log',server_ip,server_port),5,{},json.encode(log_list))endCC.getui = function()while true dolocal r = {http.get(string.format('http://%s:%s/getui', server_ip, server_port))}if r[1] == 200 then return json.decode(r[3]) endsys.sleep(2)sys.toast('中控访问超时')endendCC.db = {add = (function(db,t)return send_cc(db,'add',t)end),del = (function(db,t)return send_cc(db,'del',t)end),edit = (function(db,t)return send_cc(db,'edit',t)end),get = (function(db,t)return send_cc(db,'get',t)end),list = (function(db,t)return send_cc(db,'list',t or {})end)}CC.web_file = {take_line = (function(path)return post('file','take_line',{path=path}).dataend),exists = function(path)local r = post('file','exists',{path=path})if type(r.info) == 'userdata' thenreturn falseelsereturn r.infoendend,list = (function(path)return post('file','list',{path=path}).listend),size = (function(path)return post('file','size',{path=path}).fsizeend),delete = (function(path)return post('file','delete',{path=path}).successend),reads = (function(path)local r = post('file','reads',{path=path})if r.success thenreturn r.data:base64_decode()elsereturn nilendend),writes = (function(path,data)return post('file','writes',{path=path,data=data:base64_encode()}).successend),appends = (function(path,data)return post('file','appends',{path=path,data=data:base64_encode()}).successend),line_count = (function(path)return post('file','line_count',{path=path}).linecountend),get_line = (function(path,line_number)return post('file','get_line',{path=path,line_number=line_number}).lineend),set_line = (function(path,line_number,data)return post('file','set_line',{path=path,line_number=line_number,data=data}).successend),insert_line = (function(path,line_number,data)return post('file','insert_line',{path=path,line_number=line_number,data=data}).successend),remove_line = (function(path,line_number)return post('file','remove_line',{path=path,line_number=line_number}).successend),get_lines = (function(path)return post('file','get_lines',{path=path}).linesend),insert_lines = (function(path,line_number,lines)return post('file','insert_lines',{path=path,line_number=line_number,lines=lines}).successend),update_file = (function(file,path)local f, err = io.open(path,'rb')if not f then error(err,2) endlocal s = f:read('*a')f:close()return post('file-byte','update?file=' .. encodeURI(file), s) == 'ok'end),down_file = (function(file,path)local code, header, bodywhile true docode, header, body = http.get('http://' .. server_ip .. ':' .. server_port .. '/file-byte/down?file=' .. encodeURI(file),30,{})if code == 200 or code == 404 then break endendif code == 404 thenerror('文件不存在',2)elselocal f = io.open(path,'wb')f:write(body)f:close()return trueendend),}CC.web_directory = {exicts = function(path)local r = post('directory','exicts',{path=path})if type(r.info) == 'userdata' thenreturn falseelsereturn r.infoendend,exists = function(path)local r = post('directory','exists',{path=path})if type(r.info) == 'userdata' thenreturn falseelsereturn r.infoendend,create = (function(path)return post('directory','create',{path=path}).successend),delete = (function(path,data)return post('directory','delete',{path=path}).successend),}endreturn CC
- 让设备闪光灯以及屏幕进行闪烁,并发出声音。
- 此功能主要用于在大批设备中进行定位设备的位置。
now_screen_level=device.brightness();____lalala____={}setmetatable(____lalala____,{__gc=function()webview.destroy();device.set_brightness(now_screen_level);end});device.unlock_screen();device.set_brightness(1);device.set_volume(1);for i=0,25 do;if i%2==0 then;device.vibrator();webview.show{};device.flash_on();else;webview.hide();device.flash_off();end;if i%15==0 then;device.play_sound('/System/Library/Audio/UISounds/sms-received3.caf');end;sys.msleep(200);end
- 设备写入数据库、获取数据库数据、删除数据库数据。
local CC = require('CC')dolocal args = ((proc_take('spawn_args') ~= "") and proc_take('spawn_args')) or proc_take('CC_args')proc_put('spawn_args', args);proc_put('CC_args', args)local _, args_json = pcall(json.decode, args)if _ and type(args_json) == 'table' thenCC.set_server_ip(args_json['server_ip'],args_json['server_port'])elseerror('请检测启动参数')endendCC.log({['脚本'] = "数据库访问"})CC.log('开始操作')-- 添加10条数据for i = 1, 10 dolocal v = CC.db.add('账号表',{{['账号'] = '测试用的内容 ' .. i .. ' ' .. device.name(), ['密码'] = '假装有内容' .. i, ['区'] = '实际没卵用'}})if v[1].state thenCC.log({['添加账号'] = '测试用的内容 ' .. i .. ' ' .. device.name()})elseCC.log('数据库添加失败')endsys.sleep(1)endCC.log({['添加账号'] = ''})while true dolocal v = CC.db.get('账号表', {{['区'] = '实际没卵用'}, {['区'] = '万一有点用呢'}})if #v == 0 thenbreakelseCC.log({['得到账号'] = v[1]['账号']})endsys.sleep(1)endCC.log('结束操作')