Showing
1 changed file
with
22 additions
and
0 deletions
... | ... | @@ -61,6 +61,7 @@ import org.thingsboard.server.common.data.relation.EntityRelation; |
61 | 61 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
62 | 62 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
63 | 63 | import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; |
64 | +import org.thingsboard.server.common.data.yunteng.enums.TkScriptFunctionType; | |
64 | 65 | import org.thingsboard.server.common.msg.EncryptionUtil; |
65 | 66 | import org.thingsboard.server.common.msg.TbMsg; |
66 | 67 | import org.thingsboard.server.common.msg.TbMsgDataType; |
... | ... | @@ -182,6 +183,12 @@ public class DefaultTransportApiService implements TransportApiService { |
182 | 183 | result = handle(transportApiRequestMsg.getOtaPackageRequestMsg()); |
183 | 184 | } |
184 | 185 | |
186 | + //Thingskit function | |
187 | + else if (transportApiRequestMsg.hasScript()) { | |
188 | + result = handle(transportApiRequestMsg.getScript()); | |
189 | + } | |
190 | + | |
191 | + | |
185 | 192 | return Futures.transform(Optional.ofNullable(result).orElseGet(this::getEmptyTransportApiResponseFuture), |
186 | 193 | value -> new TbProtoQueueMsg<>(tbProtoQueueMsg.getKey(), value, tbProtoQueueMsg.getHeaders()), |
187 | 194 | MoreExecutors.directExecutor()); |
... | ... | @@ -662,4 +669,19 @@ public class DefaultTransportApiService implements TransportApiService { |
662 | 669 | private Long checkLong(Long l) { |
663 | 670 | return l != null ? l : 0; |
664 | 671 | } |
672 | + | |
673 | + | |
674 | + | |
675 | + //Thingskit function | |
676 | + private ListenableFuture<TransportApiResponseMsg> handle(TransportProtos.ScriptProto requestMsg) { | |
677 | + | |
678 | + int type = requestMsg.getFunctionType(); | |
679 | + DeviceId deviceId = new DeviceId(new UUID(requestMsg.getScriptIdMSB(), requestMsg.getScriptIdLSB())); | |
680 | + DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(TenantId.SYS_TENANT_ID, deviceId); | |
681 | + | |
682 | + return Futures.immediateFuture(TransportApiResponseMsg.newBuilder() | |
683 | + .setDeviceCredentialsResponseMsg(TransportProtos.GetDeviceCredentialsResponseMsg.newBuilder() | |
684 | + .setDeviceCredentialsData(ByteString.copyFrom(dataDecodingEncodingService.encode(deviceCredentials)))) | |
685 | + .build()); | |
686 | + } | |
665 | 687 | } | ... | ... |