Browse Source

added sparkplug

pull/8938/head
YevhenBondarenko 3 years ago
parent
commit
329a24c019
  1. 4
      application/src/test/java/org/thingsboard/server/controller/DeviceConnectivityControllerTest.java
  2. 15
      dao/src/main/java/org/thingsboard/server/dao/device/DeviceConnectivityServiceImpl.java

4
application/src/test/java/org/thingsboard/server/controller/DeviceConnectivityControllerTest.java

@ -295,7 +295,7 @@ public class DeviceConnectivityControllerTest extends AbstractControllerTest {
}
@Test
public void testFetchPublishTelemetryCommandsForСoapDevice() throws Exception {
public void testFetchPublishTelemetryCommandsForCoapDevice() throws Exception {
Device device = new Device();
device.setName("My device");
device.setDeviceProfileId(coapDeviceProfileId);
@ -317,7 +317,7 @@ public class DeviceConnectivityControllerTest extends AbstractControllerTest {
}
@Test
public void testFetchPublishTelemetryCommandsForСoapDeviceWithX509Creds() throws Exception {
public void testFetchPublishTelemetryCommandsForCoapDeviceWithX509Creds() throws Exception {
Device device = new Device();
device.setName("My device");
device.setDeviceProfileId(coapDeviceProfileId);

15
dao/src/main/java/org/thingsboard/server/dao/device/DeviceConnectivityServiceImpl.java

@ -91,10 +91,17 @@ public class DeviceConnectivityServiceImpl implements DeviceConnectivityService
case MQTT:
MqttDeviceProfileTransportConfiguration transportConfiguration =
(MqttDeviceProfileTransportConfiguration) deviceProfile.getProfileData().getTransportConfiguration();
String topicName = transportConfiguration.getDeviceTelemetryTopic();
Optional.ofNullable(getMqttTransportPublishCommands(baseUrl, topicName, creds))
.ifPresent(v -> commands.set(MQTT, v));
//TODO: add sparkplug command with emulator (check SSL)
if (transportConfiguration.isSparkplug()) {
ObjectNode sparkplug = JacksonUtil.newObjectNode();
sparkplug.put("sparkplug", CHECK_DOCUMENTATION);
commands.set(MQTT, sparkplug);
} else {
String topicName = transportConfiguration.getDeviceTelemetryTopic();
Optional.ofNullable(getMqttTransportPublishCommands(baseUrl, topicName, creds))
.ifPresent(v -> commands.set(MQTT, v));
}
break;
case COAP:
Optional.ofNullable(getCoapTransportPublishCommands(baseUrl, creds))

Loading…
Cancel
Save