Exemple #1
0
        //构造函数,用于上层状态机
        public LogData(LOGDLL.LogResult State, int type)
        {
            //此时,该类只用于上层状态
            switch (type)
            {
            case 0x09:
                this.wifiOpenCLose = State;
                break;

            case 0x11:
                this.wifiFrameworkState = State;
                break;

            case 0x12:
                this.screenState = State;
                break;

            case 0x13:
                this.wifiSettingState = State;
                break;

            case 0x14:
                this.wifiConnectedState = State;
                break;
            }
        }
Exemple #2
0
 //添加扫描结果
 public void addWpsScanResults(LOGDLL.LogResult log)
 {
     scanResultsArray      = LOGDLL.getScanResults(log);
     scanResultButton      = new Button();
     scanResultButton.Text = "scan_bss:" + scanResultsArray.Length;
     //添加点击事件
     scanResultButton.Click += new EventHandler(scanResultButton_click);
 }
Exemple #3
0
 //添加状态机
 public void addWpsState(LOGDLL.LogResult log)
 {
     wpsState        = log;
     stateChangeTime = wpsState.time;
     stateCurrent    = wpsState.cmd.Substring(0, wpsState.cmd.IndexOf('-') - 1);
     stateNext       = wpsState.cmd.Substring(wpsState.cmd.IndexOf('>') + 2);
     //Console.WriteLine("wps state: " + wpsState.cmd + " current:" + stateCurrent + " next:" + stateNext + "cmd:"+  wpsState.cmd + "<<<");
 }
Exemple #4
0
        //区分log类别添加到链表中
        private void InitWpsLayout()
        {
            //两个链表,存储上层和下层事件,遇到状态机变化,则生成新链表与LogData类
            List <LOGDLL.LogResult> HalEventList    = new List <LOGDLL.LogResult>();
            List <LOGDLL.LogResult> DriverEventList = new List <LOGDLL.LogResult>();

            //对log数组中的每一个元素分类,加入链表,生成LogData类

            /*
             * 上层状态机
             * 0x11----上层状态机状态
             * 0x12----屏幕状态
             * 0x13----wifi设置状态
             * 0x14----当前连接wifi状态
             * 0x09----wifi开启关闭状态
             *
             **底层共有6种类型
             **0x01----monitor_command,上层下发到wps的命令
             **0x02----monitor_reback,wps返回上层的事件
             **0x03----driver_command,wps发送到驱动的命令
             **0x04----driver_reback,wps从驱动收到的事件
             **0x05----wps_sta,底层状态机
             **0x06----收到扫描结果的信号强度,加密方式,SSID,BSSID信息,存储到链表里,以BSSID匹配
             * 0x07----wps打算associate 的bssid,通过
             * 0x08----dhcp 分配到的ip地址
             */

            //存储扫描结果,每一个状态之内只有一个扫描结果
            LOGDLL.LogResult scanLogResult = null;

            //存储selected bssid
            String selectBssid = null;
            //存储dhcp获取的IP地址
            String dhcpIp = null;

            for (int i = 0; i < myLog.Length; i++)
            {
                switch (myLog[i].type)
                {
                case 0x01:
                    HalEventList.Add(myLog[i]);
                    break;

                case 0x02:
                    HalEventList.Add(myLog[i]);
                    break;

                case 0x03:
                    DriverEventList.Add(myLog[i]);
                    break;

                case 0x04:
                    DriverEventList.Add(myLog[i]);
                    break;

                case 0x05:
                    //状态机消息,一轮结束
                    LogData logData = new LogData(HalEventList, DriverEventList);
                    //添加状态机消息
                    logData.addWpsState(myLog[i]);
                    //添加扫描结果
                    if (scanLogResult != null)
                    {
                        logData.addWpsScanResults(scanLogResult);
                        scanLogResult = null;
                    }
                    //添加select bssid
                    if (selectBssid != null)
                    {
                        logData.selectBssid = selectBssid;
                        selectBssid         = null;
                    }
                    //添加dhcp IP信息
                    //为空表示错误
                    if (dhcpIp == null && logData.stateCurrent.Contains("COMPLETED"))
                    {
                        logData.dhcpIP = "error no dhcp";
                    }
                    //正确
                    else
                    {
                        logData.dhcpIP = dhcpIp;
                        dhcpIp         = null;
                    }

                    LogDataList.Add(logData);

                    HalEventList    = new List <LOGDLL.LogResult>();
                    DriverEventList = new List <LOGDLL.LogResult>();
                    break;

                case 0x06:
                    //扫描结果,需要做类型转换
                    if (myLog[i].scanResultList.Count > 0)
                    {
                        scanLogResult = myLog[i];
                    }
                    break;

                case 0x07:
                    selectBssid = myLog[i].cmd;
                    //Console.WriteLine("selected bssid : " + selectBssid);
                    break;

                case 0x08:
                    dhcpIp = myLog[i].cmd;
                    break;

                //上层状态
                case 0x09:
                    LogDataList.Add(new LogData(myLog[i], 0x09));
                    break;

                case 0x11:
                    LogDataList.Add(new LogData(myLog[i], 0x11));
                    break;

                case 0x12:
                    LogDataList.Add(new LogData(myLog[i], 0x12));
                    break;

                case 0x13:
                    LogDataList.Add(new LogData(myLog[i], 0x13));
                    break;

                case 0x14:
                    LogDataList.Add(new LogData(myLog[i], 0x14));
                    break;

                default:
                    break;
                }
            }
            //结束后,尾部数据处理,防止最后没有状态机变化
            LogData logData2 = new LogData(HalEventList, DriverEventList);

            if (scanLogResult != null)
            {
                logData2.addWpsScanResults(scanLogResult);
                scanLogResult = null;
            }
            //添加最后一个状态
            LOGDLL.LogResult wps_state = new LOGDLL.LogResult();

            //反向查找最后一个wps状态的信息
            int index = 0;

            for (index = LogDataList.Count - 1; index >= 0; index--)
            {
                if (LogDataList[index].wpsState != null)
                {
                    break;
                }
            }
            if (index > 0)
            {
                wps_state.cmd = LogDataList[index].stateNext + " -> " + LogDataList[index].stateNext;
            }
            else
            {
                wps_state.cmd = "&&&&&&&&&" + " -> " + "&&&&&&&&&";
            }

            wps_state.time = "0";
            logData2.addWpsState(wps_state);

            LogDataList.Add(logData2);


            //调试信息
            Console.WriteLine("数据链表长度:" + LogDataList.Count);
        }
 //添加状态机
 public void addWpsState(LOGDLL.LogResult log)
 {
     wpsState = log;
     stateChangeTime = wpsState.time;
     stateCurrent = wpsState.cmd.Substring(0, wpsState.cmd.IndexOf('-')-1);
     stateNext = wpsState.cmd.Substring(wpsState.cmd.IndexOf('>') + 2);
     //Console.WriteLine("wps state: " + wpsState.cmd + " current:" + stateCurrent + " next:" + stateNext + "cmd:"+  wpsState.cmd + "<<<");
 }
 //构造函数,用于上层状态机
 public LogData(LOGDLL.LogResult State, int type)
 {
     //此时,该类只用于上层状态
     switch(type)
     {
         case 0x09:
             this.wifiOpenCLose = State;
             break;
         case 0x11:
             this.wifiFrameworkState = State;
             break;
         case 0x12:
             this.screenState = State;
             break;
         case 0x13:
             this.wifiSettingState = State;
             break;
         case 0x14:
             this.wifiConnectedState = State;
             break;
     }
 }
        //区分log类别添加到链表中
        private void InitWpsLayout()
        {
            //两个链表,存储上层和下层事件,遇到状态机变化,则生成新链表与LogData类
            List<LOGDLL.LogResult> HalEventList = new List<LOGDLL.LogResult>();
            List<LOGDLL.LogResult> DriverEventList = new List<LOGDLL.LogResult>();

            //对log数组中的每一个元素分类,加入链表,生成LogData类
            /*
             * 上层状态机
             * 0x11----上层状态机状态
             * 0x12----屏幕状态
             * 0x13----wifi设置状态
             * 0x14----当前连接wifi状态
             * 0x09----wifi开启关闭状态
             *
            **底层共有6种类型
            **0x01----monitor_command,上层下发到wps的命令
            **0x02----monitor_reback,wps返回上层的事件
            **0x03----driver_command,wps发送到驱动的命令
            **0x04----driver_reback,wps从驱动收到的事件
            **0x05----wps_sta,底层状态机
            **0x06----收到扫描结果的信号强度,加密方式,SSID,BSSID信息,存储到链表里,以BSSID匹配
             *0x07----wps打算associate 的bssid,通过
             *0x08----dhcp 分配到的ip地址
             */

            //存储扫描结果,每一个状态之内只有一个扫描结果
            LOGDLL.LogResult scanLogResult = null;

            //存储selected bssid
            String selectBssid = null;
            //存储dhcp获取的IP地址
            String dhcpIp = null;

            for (int i = 0; i < myLog.Length; i++)
            {
                switch (myLog[i].type)
                {
                    case 0x01:
                        HalEventList.Add(myLog[i]);
                        break;
                    case 0x02:
                        HalEventList.Add(myLog[i]);
                        break;
                    case 0x03:
                        DriverEventList.Add(myLog[i]);
                        break;
                    case 0x04:
                        DriverEventList.Add(myLog[i]);
                        break;
                    case 0x05:
                        //状态机消息,一轮结束
                        LogData logData = new LogData(HalEventList, DriverEventList);
                        //添加状态机消息
                        logData.addWpsState(myLog[i]);
                        //添加扫描结果
                        if (scanLogResult != null)
                        {
                            logData.addWpsScanResults(scanLogResult);
                            scanLogResult = null;
                        }
                        //添加select bssid
                        if (selectBssid != null)
                        {
                            logData.selectBssid = selectBssid;
                            selectBssid = null;
                        }
                        //添加dhcp IP信息
                        //为空表示错误
                        if (dhcpIp == null && logData.stateCurrent.Contains("COMPLETED"))
                        {
                            logData.dhcpIP = "error no dhcp";
                        }
                        //正确
                        else
                        {
                            logData.dhcpIP = dhcpIp;
                            dhcpIp = null;
                        }

                        LogDataList.Add(logData);

                        HalEventList = new List<LOGDLL.LogResult>();
                        DriverEventList = new List<LOGDLL.LogResult>();
                        break;
                    case 0x06:
                        //扫描结果,需要做类型转换
                        if (myLog[i].scanResultList.Count > 0)
                            scanLogResult = myLog[i];
                        break;
                    case 0x07:
                        selectBssid = myLog[i].cmd;
                        //Console.WriteLine("selected bssid : " + selectBssid);
                        break;
                    case 0x08:
                        dhcpIp = myLog[i].cmd;
                        break;

                    //上层状态
                    case 0x09:
                        LogDataList.Add(new LogData(myLog[i], 0x09));
                        break;
                    case 0x11:
                        LogDataList.Add(new LogData(myLog[i], 0x11));
                        break;
                    case 0x12:
                        LogDataList.Add(new LogData(myLog[i], 0x12));
                        break;
                    case 0x13:
                        LogDataList.Add(new LogData(myLog[i], 0x13));
                        break;
                    case 0x14:
                        LogDataList.Add(new LogData(myLog[i], 0x14));
                        break;

                    default:
                        break;
                }

            }
            //结束后,尾部数据处理,防止最后没有状态机变化
            LogData logData2 = new LogData(HalEventList, DriverEventList);
            if (scanLogResult != null)
            {
                logData2.addWpsScanResults(scanLogResult);
                scanLogResult = null;
            }
            //添加最后一个状态
            LOGDLL.LogResult wps_state = new LOGDLL.LogResult();

            //反向查找最后一个wps状态的信息
            int index = 0;
            for (index = LogDataList.Count - 1; index >= 0; index--)
            {
                if (LogDataList[index].wpsState != null)
                    break;
            }
            if(index > 0)
            {
                wps_state.cmd = LogDataList[index].stateNext + " -> " + LogDataList[index].stateNext;
            }
            else
            {
                wps_state.cmd = "&&&&&&&&&" + " -> " + "&&&&&&&&&";
            }

            wps_state.time = "0";
            logData2.addWpsState(wps_state);

            LogDataList.Add(logData2);

            //调试信息
            Console.WriteLine("数据链表长度:" + LogDataList.Count);
        }