Search in sources :

Example 21 with DownlinkMsg

use of org.thingsboard.server.gen.edge.v1.DownlinkMsg in project thingsboard by thingsboard.

the class AdminSettingsEdgeProcessor method processAdminSettingsToEdge.

public DownlinkMsg processAdminSettingsToEdge(EdgeEvent edgeEvent) {
    AdminSettings adminSettings = mapper.convertValue(edgeEvent.getBody(), AdminSettings.class);
    AdminSettingsUpdateMsg adminSettingsUpdateMsg = adminSettingsMsgConstructor.constructAdminSettingsUpdateMsg(adminSettings);
    return DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addAdminSettingsUpdateMsg(adminSettingsUpdateMsg).build();
}
Also used : AdminSettingsUpdateMsg(org.thingsboard.server.gen.edge.v1.AdminSettingsUpdateMsg) AdminSettings(org.thingsboard.server.common.data.AdminSettings)

Example 22 with DownlinkMsg

use of org.thingsboard.server.gen.edge.v1.DownlinkMsg in project thingsboard by thingsboard.

the class AssetEdgeProcessor method processAssetToEdge.

public DownlinkMsg processAssetToEdge(Edge edge, EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
    AssetId assetId = new AssetId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(action) {
        case ADDED:
        case UPDATED:
        case ASSIGNED_TO_EDGE:
        case ASSIGNED_TO_CUSTOMER:
        case UNASSIGNED_FROM_CUSTOMER:
            Asset asset = assetService.findAssetById(edgeEvent.getTenantId(), assetId);
            if (asset != null) {
                CustomerId customerId = getCustomerIdIfEdgeAssignedToCustomer(asset, edge);
                AssetUpdateMsg assetUpdateMsg = assetMsgConstructor.constructAssetUpdatedMsg(msgType, asset, customerId);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addAssetUpdateMsg(assetUpdateMsg).build();
            }
            break;
        case DELETED:
        case UNASSIGNED_FROM_EDGE:
            AssetUpdateMsg assetUpdateMsg = assetMsgConstructor.constructAssetDeleteMsg(assetId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addAssetUpdateMsg(assetUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) AssetUpdateMsg(org.thingsboard.server.gen.edge.v1.AssetUpdateMsg) Asset(org.thingsboard.server.common.data.asset.Asset) CustomerId(org.thingsboard.server.common.data.id.CustomerId) AssetId(org.thingsboard.server.common.data.id.AssetId)

Aggregations

DownlinkMsg (org.thingsboard.server.gen.edge.v1.DownlinkMsg)16 CustomerId (org.thingsboard.server.common.data.id.CustomerId)7 DeviceId (org.thingsboard.server.common.data.id.DeviceId)3 Device (org.thingsboard.server.common.data.Device)2 RuleChainId (org.thingsboard.server.common.data.id.RuleChainId)2 RuleChain (org.thingsboard.server.common.data.rule.RuleChain)2 DeviceUpdateMsg (org.thingsboard.server.gen.edge.v1.DeviceUpdateMsg)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 NettyChannelBuilder (io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder)1 SslContextBuilder (io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder)1 StreamObserver (io.grpc.stub.StreamObserver)1 UUID (java.util.UUID)1 SSLException (javax.net.ssl.SSLException)1 EdgeConnectionException (org.thingsboard.edge.exception.EdgeConnectionException)1 AdminSettings (org.thingsboard.server.common.data.AdminSettings)1 Customer (org.thingsboard.server.common.data.Customer)1 Dashboard (org.thingsboard.server.common.data.Dashboard)1 DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)1 EntityView (org.thingsboard.server.common.data.EntityView)1 User (org.thingsboard.server.common.data.User)1