@Override public String toString() { return MoreObjects.toStringHelper(this) .add("timestamp", getTimestamp()) .add("command", getCommand()) .add("status", getStatus()) .add("message", getMessage()) .add("extras", getExtras()) .toString(); }
@Override public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); out.writeSerializable(getCommand()); out.writeInt(getStatus() ? 1 : 0); out.writeString(getMessage()); }
/** * Send a command request to the vehicle that does not require any metadata. * * @param type The command request type to send to the VI. * @return The message returned by the VI in response to this command or * null if none was received. */ public String requestCommandMessage(CommandType type) { VehicleMessage message = request(new Command(type)); String value = null; if(message != null) { // Because we use the same key and value for commands and command // responses, if for some reason a Command is echoed back to the // device instead of a CommandResponse, you could get a casting // exception when trying to cast this message here. If we got a // Command, just ignore it and assume no response - I wasn't able to // reproduce it but we did have a few Bugsnag reports about it. try { CommandResponse response = message.asCommandResponse(); if(response.getStatus()) { value = response.getMessage(); } } catch(ClassCastException e) { Log.w(TAG, "Expected a command response but got " + message + " -- ignoring, assuming no response"); } } return value; }
messageBuilder.setMessage(message.getMessage());