/** * Creates the JSON string of the configuration as used in the Hyperion daemon configfile * * @return The JSON string of this DeviceConfig */ public String toJsonString() { StringBuffer strBuf = new StringBuffer(); strBuf.append("\t/// Device configuration contains the following fields: \n"); strBuf.append( "\t/// * 'name' : The user friendly name of the device (only used for display purposes)\n"); strBuf.append( "\t/// * 'type' : The type of the device or leds (known types for now are\n" + "\t/// " + DeviceType.listTypes() + ")\n"); strBuf.append("\t/// * [device type specific configuration]\n"); strBuf.append( "\t/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).\n"); strBuf.append("\t\"device\" :\n"); strBuf.append("\t{\n"); strBuf.append("\t\t\"name\" : \"").append(mName).append("\",\n"); strBuf.append("\t\t\"type\" : \"").append(mType.getTypeId()).append("\",\n"); for (Object key : mDeviceProperties.keySet()) { Object value = mDeviceProperties.get(key); if (value instanceof String) { strBuf.append(String.format("\t\t\"%s\" : \"%s\",\n", key, value)); } else { strBuf.append(String.format("\t\t\"%s\" : %s,\n", key, value.toString())); } } strBuf .append("\t\t\"colorOrder\" : \"") .append(mColorByteOrder.name().toLowerCase()) .append("\"\n"); strBuf.append("\t}"); return strBuf.toString(); }