diff --git a/docs/tools/pubber.md b/docs/tools/pubber.md index 8669c76db..b3ff10437 100644 --- a/docs/tools/pubber.md +++ b/docs/tools/pubber.md @@ -28,10 +28,16 @@ The following parameters are currently supported from the CLI: * `extraPoint=` - adds an extra point with the given name to the device which does not exist in device's metadata with a random value (will trigger validation additional point error) +* `missingPoint=` - removes the point with the given name (if exists) from + the device's active pointset at initialization (will trigger validation + missing point) * `extraField=` - adds an extra schema invalidating field to pointset events (will trigger validation schema error) -* `no_hardware` - omits the `system.hardware` field from state messages (will +* `noHardware` - omits the `system.hardware` field from state messages (will trigger validation error, missing required field) +* `noConfigAck` - subscribes to the `config` topic with a QoS of 0, therefore + will not send PUBACK's for config messages + More advanced options can be set by by calling pubber directly with the path a configuration file: `pubber/bin/run path/to/config.json` diff --git a/pubber/src/main/java/daq/pubber/ConfigurationOptions.java b/pubber/src/main/java/daq/pubber/ConfigurationOptions.java index 822f8f15f..057f46593 100644 --- a/pubber/src/main/java/daq/pubber/ConfigurationOptions.java +++ b/pubber/src/main/java/daq/pubber/ConfigurationOptions.java @@ -5,7 +5,9 @@ */ public class ConfigurationOptions { public Boolean noHardware; + public Boolean noConfigAck; public String extraPoint; + public String missingPoint; public String extraField; } diff --git a/pubber/src/main/java/daq/pubber/MqttPublisher.java b/pubber/src/main/java/daq/pubber/MqttPublisher.java index 93666efbe..0d02dff0e 100644 --- a/pubber/src/main/java/daq/pubber/MqttPublisher.java +++ b/pubber/src/main/java/daq/pubber/MqttPublisher.java @@ -286,7 +286,10 @@ private String getMessageTopic(String deviceId, String topic) { } private void subscribeToUpdates(MqttClient client, String deviceId) { - subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), QOS_AT_LEAST_ONCE); + boolean noConfigAck = (configuration.options.noConfigAck != null + && configuration.options.noConfigAck); + int configQos = noConfigAck ? QOS_AT_MOST_ONCE : QOS_AT_LEAST_ONCE; + subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), configQos); subscribeTopic(client, String.format(ERRORS_TOPIC_FMT, deviceId), QOS_AT_MOST_ONCE); info("Updates subscribed"); } diff --git a/pubber/src/main/java/daq/pubber/Pubber.java b/pubber/src/main/java/daq/pubber/Pubber.java index 99bef948a..114c0414e 100644 --- a/pubber/src/main/java/daq/pubber/Pubber.java +++ b/pubber/src/main/java/daq/pubber/Pubber.java @@ -301,6 +301,15 @@ private void processDeviceMetadata(Metadata metadata) { Map points = metadata.pointset == null ? DEFAULT_POINTS : metadata.pointset.points; + + if (configuration.options.missingPoint != null) { + if (points.containsKey(configuration.options.missingPoint)) { + points.remove(configuration.options.missingPoint); + } else { + throw new RuntimeException("missingPoint not in pointset"); + } + } + points.forEach((name, point) -> addPoint(makePoint(name, point))); }