Showing
1 changed file
with
12 additions
and
8 deletions
... | ... | @@ -291,21 +291,25 @@ public class DefaultTransportApiService implements TransportApiService { |
291 | 291 | Lock deviceCreationLock = deviceCreationLocks.computeIfAbsent(requestMsg.getDeviceName(), id -> new ReentrantLock()); |
292 | 292 | deviceCreationLock.lock(); |
293 | 293 | try { |
294 | - Device device = deviceService.findDeviceByTenantIdAndName(gateway.getTenantId(), requestMsg.getDeviceName()); | |
295 | 294 | |
296 | - if (device == null) { | |
297 | - | |
298 | - | |
299 | - | |
300 | - //Thingskit function | |
301 | - if(gateway.getDeviceData().getTransportConfiguration().getType() == DeviceTransportType.TCP) { | |
295 | + //Thingskit function | |
296 | + String slaveName = requestMsg.getDeviceName(); | |
297 | + if(gateway.getDeviceData().getTransportConfiguration().getType() == DeviceTransportType.TCP) { | |
298 | + DeviceDTO iotDev = ytDeviceService.findSlaveDevice(gateway.getTenantId().getId().toString() | |
299 | + , gateway.getId().getId().toString() | |
300 | + ,slaveName); | |
301 | + if(iotDev == null ){ | |
302 | 302 | GetOrCreateDeviceFromGatewayResponseMsg.Builder builder = GetOrCreateDeviceFromGatewayResponseMsg.newBuilder(); |
303 | 303 | return TransportApiResponseMsg.newBuilder() |
304 | 304 | .setGetOrCreateDeviceResponseMsg(builder.build()) |
305 | 305 | .build(); |
306 | - } | |
306 | + } | |
307 | + slaveName = iotDev.getName(); | |
308 | + } | |
307 | 309 | |
310 | + Device device = deviceService.findDeviceByTenantIdAndName(gateway.getTenantId(), slaveName); | |
308 | 311 | |
312 | + if (device == null) { | |
309 | 313 | TenantId tenantId = gateway.getTenantId(); |
310 | 314 | device = new Device(); |
311 | 315 | device.setTenantId(tenantId); | ... | ... |