Merge branch 'publishTelemetryCommands' of github.com:dashevchenko/thingsboard into feature/check-connectivity-device
This commit is contained in:
commit
1916e56ee5
@ -213,11 +213,11 @@ public class DeviceConnectivityControllerTest extends AbstractControllerTest {
|
|||||||
credentials.getCredentialsId()));
|
credentials.getCredentialsId()));
|
||||||
|
|
||||||
|
|
||||||
JsonNode linuxMqttCommands = commands.get(MQTT);
|
JsonNode mqttCommands = commands.get(MQTT);
|
||||||
assertThat(linuxMqttCommands.get(MQTT).asText()).isEqualTo(String.format("mosquitto_pub -d -q 1 -h localhost -p 1883 -t v1/devices/me/telemetry " +
|
assertThat(mqttCommands.get(MQTT).asText()).isEqualTo(String.format("mosquitto_pub -d -q 1 -h localhost -p 1883 -t v1/devices/me/telemetry " +
|
||||||
"-u %s -m \"{temperature:25}\"",
|
"-u %s -m \"{temperature:25}\"",
|
||||||
credentials.getCredentialsId()));
|
credentials.getCredentialsId()));
|
||||||
assertThat(linuxMqttCommands.get(MQTTS).asText()).isEqualTo(String.format("mosquitto_pub -d -q 1 --cafile pathToFile/tb-server-chain.pem -h localhost -p 8883 " +
|
assertThat(mqttCommands.get(MQTTS).asText()).isEqualTo(String.format("mosquitto_pub -d -q 1 --cafile pathToFile/tb-server-chain.pem -h localhost -p 8883 " +
|
||||||
"-t v1/devices/me/telemetry -u %s -m \"{temperature:25}\"",
|
"-t v1/devices/me/telemetry -u %s -m \"{temperature:25}\"",
|
||||||
credentials.getCredentialsId()));
|
credentials.getCredentialsId()));
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ public class DeviceConnectivityControllerTest extends AbstractControllerTest {
|
|||||||
doGetTyped("/api/device-connectivity/" + savedDevice.getId().getId(), new TypeReference<>() {});
|
doGetTyped("/api/device-connectivity/" + savedDevice.getId().getId(), new TypeReference<>() {});
|
||||||
assertThat(commands).hasSize(1);
|
assertThat(commands).hasSize(1);
|
||||||
assertThat(commands.get(MQTT).get(MQTTS).asText()).isEqualTo(CHECK_DOCUMENTATION);
|
assertThat(commands.get(MQTT).get(MQTTS).asText()).isEqualTo(CHECK_DOCUMENTATION);
|
||||||
assertThat(commands.get(MQTT).get(DOCKER).get(MQTTS).asText()).isEqualTo(CHECK_DOCUMENTATION);
|
assertThat(commands.get(MQTT).get(DOCKER)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@ -161,7 +161,9 @@ public class DeviceСonnectivityServiceImpl implements DeviceConnectivityService
|
|||||||
Optional.ofNullable(getDockerMqttPublishCommand(MQTTS, defaultHostname, topic, deviceCredentials))
|
Optional.ofNullable(getDockerMqttPublishCommand(MQTTS, defaultHostname, topic, deviceCredentials))
|
||||||
.ifPresent(v -> dockerMqttCommands.put(MQTTS, v));
|
.ifPresent(v -> dockerMqttCommands.put(MQTTS, v));
|
||||||
|
|
||||||
|
if (!dockerMqttCommands.isEmpty()) {
|
||||||
mqttCommands.set(DOCKER, dockerMqttCommands);
|
mqttCommands.set(DOCKER, dockerMqttCommands);
|
||||||
|
}
|
||||||
return mqttCommands.isEmpty() ? null : mqttCommands;
|
return mqttCommands.isEmpty() ? null : mqttCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +181,6 @@ public class DeviceСonnectivityServiceImpl implements DeviceConnectivityService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDockerMqttPublishCommand(String protocol, String defaultHostname, String deviceTelemetryTopic, DeviceCredentials deviceCredentials) {
|
private String getDockerMqttPublishCommand(String protocol, String defaultHostname, String deviceTelemetryTopic, DeviceCredentials deviceCredentials) {
|
||||||
if (MQTTS.equals(protocol) && deviceCredentials.getCredentialsType() == DeviceCredentialsType.X509_CERTIFICATE) {
|
|
||||||
return CHECK_DOCUMENTATION;
|
|
||||||
}
|
|
||||||
DeviceConnectivityInfo properties = deviceConnectivityConfiguration.getConnectivity().get(protocol);
|
DeviceConnectivityInfo properties = deviceConnectivityConfiguration.getConnectivity().get(protocol);
|
||||||
if (properties == null || !properties.getEnabled()) {
|
if (properties == null || !properties.getEnabled()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user