示例#1
0
  /** { “retCode”:”00000”, “retInfo”:”操作成功”, “transactionId”:”12345” } */
  @Override
  public boolean parseBooleanResult(String result) {
    // TODO Auto-generated method stub
    if (result == null) return false;
    try {
      JSONObject job = new JSONObject(result);
      if (Const.R3RESULT_OK.equals(job.optString(JsonConst.RETCODE))) return true;

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }
    return false;
  }
示例#2
0
  /**
   * {JsonConst.RETCODE:"00000","retInfo":"操作成功" ,"devices":[{"id":"0007A889EBB3","mac":
   * "0007A889EBB3","name":"test","attrs" :null,"type":{"type":"06","subType":"02"
   * ,"specialCode":"0041800123","typeIdentifier"
   * :"101c120024000810060200418001230000000000000000000000000000000000" },"version"
   * :{"eProtocolVer":"2.00","smartlink":{"smartLinkSoftwareVersion" :"e_0.1.21"
   * ,"smartLinkHardwareVersion":"G_1.0.00","smartLinkDevfileVersion" :"0.0.0","smartLinkPlatform"
   * :"UDISCOVERY_UWT"}},"location":null,"status":{"online":false}}]}
   */
  @Override
  public HashMap<String, uSDKDevice> parseFetchAllDevResult(String result) {
    // TODO Auto-generated method stub
    HashMap<String, uSDKDevice> uSDKDeviceMap = new HashMap<String, uSDKDevice>();
    if (result != null) {

      try {
        JSONObject job = new JSONObject(result);
        if (Const.R3RESULT_OK.equals(job.optString(JsonConst.RETCODE))) {
          JSONArray jArray = job.optJSONArray("devices");
          for (int i = 0; i < jArray.length(); i++) {
            JSONObject uJob = jArray.optJSONObject(i);
            String mac = uJob.optString("mac");
            String name = uJob.optString("name");
            JSONObject typeJob = uJob.optJSONObject("type");
            String typeIdentifier = typeJob.optString("typeIdentifier");
            JSONObject statusJob = uJob.optJSONObject("status");
            boolean isOnline = statusJob.optBoolean("online");
            JSONObject versionJob = uJob.optJSONObject("version");
            JSONObject smartlinkJob = versionJob.optJSONObject("smartlink");
            String smartLinkSoftwareVersion = smartlinkJob.optString("smartLinkSoftwareVersion");
            String smartLinkPlatform = smartlinkJob.optString("smartLinkPlatform");
            uSDKDevice device =
                uSDKDevice.newRemoteDeviceInstance(
                    mac,
                    typeIdentifier,
                    uSDKDeviceStatusConst.getInstance(isOnline),
                    smartLinkSoftwareVersion,
                    smartLinkPlatform);
            // device.setType(uSDKDeviceTypeConst.getInstance(Integer.valueOf(type)));
            // device.setType(Util.getType(name));
            uSDKDeviceMap.put(mac, device);
          }
          return uSDKDeviceMap;
        }

      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return null;
  }
示例#3
0
 /** { JsonConst.RETCODE:"00000", "retInfo":"登录UHOME云平台成功。", “userId”:”100013957366151422” } */
 @Override
 public HomeUser parseLoginResult(String result, Context context) {
   // TODO Auto-generated method stub
   if (TextUtils.isEmpty(result)) {
     return null;
   }
   HomeUser homeUser = new HomeUser();
   try {
     JSONObject job = new JSONObject(result);
     homeUser.error = job.optString(JsonConst.RETCODE);
     homeUser.id = job.optString("userId");
     homeUser.error_info = job.optString("retInfo");
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (Const.R3RESULT_OK.equals(homeUser.error)) {
     String assResult =
         NetWorkFactory.getInstance(context).assignAdapter(homeUser.id); // 动态获取接入网关地址
     parseAssignAdapter(assResult, homeUser);
   }
   return homeUser;
 }