Skip to content

Commit 1640c2b

Browse files
authored
add pubber missingPoint and noConfigAck options (#368)
1 parent 9236a70 commit 1640c2b

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

docs/tools/pubber.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ The following parameters are currently supported from the CLI:
2828
* `extraPoint=<name>` - adds an extra point with the given name to the device
2929
which does not exist in device's metadata with a random value (will trigger
3030
validation additional point error)
31+
* `missingPoint=<name>` - removes the point with the given name (if exists) from
32+
the device's active pointset at initialization (will trigger validation
33+
missing point)
3134
* `extraField=<name>` - adds an extra schema invalidating field to pointset events
3235
(will trigger validation schema error)
33-
* `no_hardware` - omits the `system.hardware` field from state messages (will
36+
* `noHardware` - omits the `system.hardware` field from state messages (will
3437
trigger validation error, missing required field)
38+
* `noConfigAck` - subscribes to the `config` topic with a QoS of 0, therefore
39+
will not send PUBACK's for config messages
40+
3541

3642
More advanced options can be set by by calling pubber directly with the path a
3743
configuration file: `pubber/bin/run path/to/config.json`

pubber/src/main/java/daq/pubber/ConfigurationOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
public class ConfigurationOptions {
1313
public Boolean noHardware;
14+
public Boolean noConfigAck;
1415
public String extraPoint;
16+
public String missingPoint;
1517
public String extraField;
1618

1719
/**

pubber/src/main/java/daq/pubber/MqttPublisher.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ private String getMessageTopic(String deviceId, String topic) {
286286
}
287287

288288
private void subscribeToUpdates(MqttClient client, String deviceId) {
289-
subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), QOS_AT_LEAST_ONCE);
289+
boolean noConfigAck = (configuration.options.noConfigAck != null
290+
&& configuration.options.noConfigAck);
291+
int configQos = noConfigAck ? QOS_AT_MOST_ONCE : QOS_AT_LEAST_ONCE;
292+
subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), configQos);
290293
subscribeTopic(client, String.format(ERRORS_TOPIC_FMT, deviceId), QOS_AT_MOST_ONCE);
291294
info("Updates subscribed");
292295
}

pubber/src/main/java/daq/pubber/Pubber.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ private void processDeviceMetadata(Metadata metadata) {
301301

302302
Map<String, PointPointsetModel> points =
303303
metadata.pointset == null ? DEFAULT_POINTS : metadata.pointset.points;
304+
305+
if (configuration.options.missingPoint != null) {
306+
if (points.containsKey(configuration.options.missingPoint)) {
307+
points.remove(configuration.options.missingPoint);
308+
} else {
309+
throw new RuntimeException("missingPoint not in pointset");
310+
}
311+
}
312+
304313
points.forEach((name, point) -> addPoint(makePoint(name, point)));
305314
}
306315

0 commit comments

Comments
 (0)