|
楼主 |
发表于 2018-12-11 11:27
|
显示全部楼层
本帖最后由 白云纷飞 于 2018-12-11 11:29 编辑
还有个so文件,估计处理代码都在里面
主要代码如下
- --[[
- **********************************************************************************
- * Copyright (c) 2016 Shanghai Feixun Communication Co.,Ltd.
- * All rights reserved.
- *
- * FILE NAME : device_mng_plt.lua
- * VERSION : 1.0
- * DESCRIPTION: 平台相关的终端管理回调函数
- *
- * AUTHOR : LiGuanghua <liguanghua@phicomm.com>
- * CREATE DATE: 12/12/2016
- *
- * HISTORY :
- * 01 12/12/2016 LiGuanghua Create.
- * 02 07/12/2017 MengQingru Modified.剥离平台无关代码
- **********************************************************************************
- --]]
- local err = require("luci.phicomm.error")
- local dbg = require("luci.phicomm.debug")
- module("luci.controller.admin.device_mng_plt", package.seeall)
- function index()
- end
- function data_get_convert(src, key)
- local cjson = require("cjson")
- local data = cjson.decode(src)
- local obj = {}
- local t_src = {}
- for j=1, #(data.Objects) do
- local t_key = {}
- -- convert src data to json data
- for i, w in ipairs(data.Objects[j].Param) do
- t_src[w.ParamName] = w.ParamValue
- end
- if t_src['alias'] ~= "" then
- t_src['hostname'] = t_src['alias']
- end
- for k, v in pairs(key) do
- t_key[k] = t_src[v]
- end
- t_key["id"] = data.Objects[j].ObjName
- obj[j] = t_key
- end
- return obj
- end
- function get_client_list_plt(args, uciname, secname)
- local clients_obj = [[{
- "Device.Clients.Client" : null}]]
- local clients_key = {
- id = "",
- mac = "MAC",
- ip = "IP",
- name = "hostname",
- brand = "brand",
- internet_enable = "acc_enable",
- upload_limit = "tx_speed",
- download_limit = "rx_speed",
- upload_speed = "rt_tx_rate",
- download_speed = "rt_rx_rate",
- online_status = "is_online",
- online_time = "online_period",
- device_type = "if_type"
- }
- local errcode, result, data
- local libphi_cgi = require("luci.adapter.libphi_cgi")
- errcode, data = libphi_cgi.get_conf(clients_obj)
- if data == nil then
- return errcode, data
- end
- if errcode == err.E_NONE then
- -- convert cgi data to ui data
- result = data_get_convert(data, clients_key)
- end
- return errcode, result
- end
- function get_device_num_plt(args, uciname, secname)
- local online_num = {}
- local file = io.open("/tmp/online_num", "r")
- if file ~= nil then
- local data = file:read("*a")
- local colon_index = string.find(data, ':')
- local bar_index = string.find(data, '|')
- local minus_index = string.find(data, '-')
- if colon_index and bar_index and minus_index then
- online_num.online_lan = string.sub(data, 1, colon_index-1)
- online_num.online_24G = string.sub(data, colon_index+1, bar_index-1)
- online_num.online_5G = string.sub(data, bar_index+1, minus_index-1)
- online_num.online_guest = string.sub(data, minus_index+1, string.len(data)-1)
- else
- online_num.online_lan = 0
- online_num.online_24G = 0
- online_num.online_5G = 0
- online_num.online_guest = 0
- end
- file:close()
- end
- return err.E_NONE, online_num
- end
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|