ac与ap同步分析

1 ApStatusRequest : ap把自己的状态发过来做请求  就相当于自我介绍

网关上抓包 : tcpdump -ni br-lan tcp port 8090   -Avv / -w portal.pcap   tcp协议 端口8090 可以分析

/etc/init.d/nigx restart 重启服务  

ApStatusRequest:new(cjson.decode(json))数据解压 创建对象    

http://192.168.156.1:8090/wacs-mana/status.ac

User-Agent: ac 1.0.0
Host: 192.168.156.1:8090
Content-Type: application/x-www-form-urlencoded
Connection: Keep-Alive
Content-Length: 2099

{

  • "gw_id": "28450FE01F32",         // SN 
  • "vendor_id": "XX",                       //供应商
  • "device_type": "S826D0",                
  • "product_type": "WAP5230",      
  • "fm_name": "XX-WAP5230-WAP5120-4.3.0.2468-DEV",  // 软件详细信息
  • "soft_ver": "4.3.0.2468",
  • "sys_load": 100,
  • "status_interval": 2,                     // 状态间隔2分钟
  • "station_agingtime": 10,
  • "timer_reboot": 0,
  • "ipaddr_release": 5,
  • "auth_server": "10.10.10.248",
  • "auth_path": "/",
  • "auth_port": 8080,
  • "ac_server": "xxxxxxxx",
  • "ac_path": "/wacs-mana/",
  • "ac_port": 8090,
  • "ac_name": "2",
  • "ac_outer_ip": "2",
  • "ac_bak_hostname": "xxxxxxxxxxx",
  • "ac_bak_path": "/wacs-mana/",
  • "ac_bak_port": 8090,
  • "ac_bak_sync_interval": 30,
  • "acdisc_enable": 1,            // 自动发现
  • "auth_enable": 1,               //自动注册
  • "apple_auto_portal": 0,
  • "escape_mode_enable": 0,
  • "auth_protocol": "cmcc-portal",//授权模式
  • "nas_ip": "1",           
  • "nas_id": "2",                  
  • "sys_time": 1743,
  • "sys_memory": 128692224,
  • "sys_memfree": 64143360,
  • "work_mode": 0,
  • "lan_ip": "192.168.2.1",
  • "wan_type": 1,
  • "wan_mac": "24:05:0f:e0:1f:35",
  • "wan_ip": "192.168.156.138",
  • "lan_mac": "24:05:0F:E0:1F:34",
  • "kick_threshold": -85,
  • "band_select_enable": 1,
  • "total_users": 0,
  • -
    "radio24g": {
    • "channel": 0,
    • "turn_on": 1,
    • "freq_bandwidth": 1,
    • "wireless_mode": 0,
    • "tx_power": 27
    },
  • -
    "radio5g": {
    • "channel": 0,
    • "turn_on": 1,
    • "freq_bandwidth": 2,
    • "wireless_mode": 2,
    • "tx_power": 23
    },
  • -
    "ssids": [
    • -
      {
      • "ssid": "zkliulin89898",
      • "vlanEnable": 0,
      • "vlanId": 0,
      • "bssid": "24:05:0f:e0:1f:36",
      • "auth_mode": 0,
      • "encryption_type": 0,
      • "password": "",
      • "coding_type": 0,
      • "hide_ssid": 0,
      • "max_users": -1,
      • "download_speed": -1,
      • "upload_speed": -1,
      • "station_count": 0,
      • "station_list": [ ],
      • "auth_enable": 1
      }
    ],
  • -
    "ssids_5g": [
    • -
      {
      • "ssid": "zk_5g",
      • "vlanEnable": 0,
      • "vlanId": 0,
      • "bssid": "24:05:0f:e0:1f:36",
      • "auth_mode": 0,
      • "encryption_type": 0,
      • "password": "",
      • "coding_type": 0,
      • "hide_ssid": 0,
      • "max_users": -1,
      • "download_speed": -1,
      • "upload_speed": -1,
      • "station_count": 0,
      • "station_list": [ ],
      • "auth_enable": 1
      }
    ],
  • -
    "qos": {
    • "enable": 0,
    • "upload_bw": 128,
    • "download_bw": 51200
    },
  • -
    "sta_scan": {
    • "enable": 0,
    • "building_id": "ZK-PROBE-001002",
    • "interval": 5,
    • "server_ip": "120.76.116.73",
    • "server_port": 8100
    },
  • -
    "mac_white_black": {
    • "mac_black_list_md5": "0",
    • "mac_white_list_md5": "0"
    }

}

if useEnable == "1" and useReg == "1" and wacSn ~= devSn then  自动注册判断

DBHelper.count("nas_device", {["device_sn = "] = deviceSN}) 数据库查询 找到了就是已经添加的数据

DBHelper.insert("nas_device", saveData) 插入到数据库

local apPara = acMaintService.statusToConfig(apStatusRequest);  参数是个对象, 得到的是ap的配置详细对象  

local acStatus = AcStatus:new(); 创建一个ac的状态  

[

第一:dao层操作单表,不涉及复杂逻辑,主要是表的增删改查操作,完全根据domain的要求来查询数据。        // 数据接口,  就是通过这儿能拿到数据                                           

第二:domain层考虑业务逻辑,例如过滤条件,放行或者返回,以及数据的处理,为调用dao层做好准备,一个domain可以调用一个或者一组相关的dao层   // 这里定义对象, 

第三:service层调用一个或者一组domain层,主要是展现需要开放出去的接口,其中domain层不是所有的接口都要再service层体现的,可能仅在service层开放几个接口出去,此外,主要接口需要对接受的参数要尽量的扩大化,也就是说可以容纳各种类型的参数的接入(Object),然后需要在service层做好转换,以备domain层使用。   // 这里处理逻辑  

正确的设计应该是,一个领域活动会聚合对应一个或一组DAO ,来完成一个领域活动。而一个服务可能包含两个领域活动,比如一个转账的业务,对应两个领域活动。两个帐户的金额分别发生变化,需要操作一组领域活动,而每个活动需要操作很多表(调用多个DAO )

]有点像计算机分层原理  , 每层进行数据的交互,逻辑上就比较清晰 

{"reboot":0,"update_firmware":0,"firmware_path":"","status_error":"OK","update_config":0}

首先把这个参数设置为 0   ---   >  apStatusResponse:setUpdate_config(0);

到一个文件后把这个代码折叠起来,方便阅读

通过sn查询设备的配置 ,从数据库中去除数据   local row = DBHelper.selectOne("ac_config", "*", _where)

查询结果返回的是个对象  return AcConfig:new(row)  这种方法可以

1  M.applyTempletPara(templetId)

  通过模板id,从数据库中查找

原文地址:https://www.cnblogs.com/xiaohuamao/p/8034298.html