public Gateway getCurrGatewayCheck(byte[] SSID) {
    if (SSID == null) {
      return null;
    }
    ArrayList<Gateway> mGatewayList = DatabaseManager.getInstance().SelectGatewayInfo1();
    System.out.println("*** gateway size " + mGatewayList.size());
    int i = 0;
    while (i < mGatewayList.size()) {
      System.out.println("*** gateway index " + i + " is " + mGatewayList.get(i));
      if (SSID != null && Arrays.equals(SSID, ((Gateway) mGatewayList.get(i)).getSSID())) {
        Gateway gateway = (Gateway) mGatewayList.get(i);
        System.out.println("*** gateway dns is " + gateway.getDNS());
        System.out.println("*** gateway ip is " + gateway.getIP());
        System.out.println("*** gateway macaddress is " + gateway.getMacAddress());
        return (Gateway) mGatewayList.get(i);
      }
      i++;
    }

    return null;
  }
 public CommonsNet JudgeConnWay(
     byte[] MacAddress, Gateway curGateway, boolean bolcheckwifi, boolean bolisNetworkConnected) {
   CommonsNet mCommonsNet;
   UnsupportedEncodingException e;
   CommonsNet mCommonsNet2 = null;
   if (bolcheckwifi || bolisNetworkConnected) {
     Gateway mDevGateway = getGatewayMac(MacAddress);
     if (curGateway != null) {
       try {
         if (Arrays.equals(curGateway.getSSID(), mDevGateway.getSSID())) {
           mCommonsNet = new CommonsNet();
           try {
             mCommonsNet.init(
                 new String(FormatStringForByte(curGateway.getIP()), "UTF-8"),
                 50000,
                 curGateway.getMacAddress(),
                 curGateway.getPassWord());
             mCommonsNet.setmConnWay((byte) 1);
             mCommonsNet2 = mCommonsNet;
             return mCommonsNet;
           } catch (UnsupportedEncodingException e2) {
             e = e2;
             mCommonsNet2 = mCommonsNet;
             e.printStackTrace();
             return mCommonsNet2;
           }
         }
         mCommonsNet = new CommonsNet();
         mCommonsNet.init(
             new String(FormatStringForByte(mDevGateway.getIP()), "UTF-8"),
             50000,
             mDevGateway.getMacAddress(),
             mDevGateway.getPassWord());
         mCommonsNet.setmConnWay((byte) 3);
         mCommonsNet2 = mCommonsNet;
         return mCommonsNet;
       } catch (UnsupportedEncodingException e3) {
         e = e3;
         e.printStackTrace();
         return mCommonsNet2;
       }
     } else if (bolisNetworkConnected) {
       try {
         if (new String(mDevGateway.getSSID(), "UTF-8").indexOf("iLightsIn") == -1) {
           mCommonsNet = new CommonsNet();
           mCommonsNet.init(
               new String(FormatStringForByte(mDevGateway.getDNS()), "UTF-8"),
               mDevGateway.getPort(),
               mDevGateway.getMacAddress(),
               mDevGateway.getPassWord());
           mCommonsNet.setmConnWay((byte) 3);
           mCommonsNet2 = mCommonsNet;
           return mCommonsNet;
         }
       } catch (Exception e2) {
       }
     }
   }
   Log.i(
       "\u6ca1\u6709\u7f51\u7edc\uff0c\u8fde\u63a5\u5931\u8d25",
       "\u6ca1\u6709\u7f51\u7edc\uff0c\u8fde\u63a5\u5931\u8d25");
   return mCommonsNet2;
 }
 public void SysdeleteGatewayOfCurrGateway(Gateway gateway) {
   DatabaseManager.getInstance().deleteGatewayOfCurrGateway(gateway.getGateWayInfoIndex());
 }