コード例 #1
0
 private static JSONObject __addNecessaryElements(
     JSONObject json, String router, String deviceBssid, String localInetAddress, int port) {
   log.debug("__addNecessaryElements()");
   if (json == null) {
     json = new JSONObject();
   }
   try {
     json.put(ROUTER, router);
     // deviceBssid!=null means the command is about to ask topology,
     // otherwise, we don't need to add TOPOLOGH
     if (deviceBssid != null) {
       json.put(TOPOLOGH, MeshUtil.getMacAddressForMesh(deviceBssid));
     }
     json.put(SIP, MeshUtil.getIpAddressForMesh(localInetAddress));
     json.put(PORT, MeshUtil.getPortForMesh(port));
   } catch (JSONException e) {
     throw new IllegalArgumentException();
   }
   return json;
 }