Search in sources :

Example 16 with DownlinkMsg

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

the class WidgetTypeEdgeProcessor method processWidgetTypeToEdge.

public DownlinkMsg processWidgetTypeToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
    WidgetTypeId widgetTypeId = new WidgetTypeId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(edgeEdgeEventActionType) {
        case ADDED:
        case UPDATED:
            WidgetTypeDetails widgetTypeDetails = widgetTypeService.findWidgetTypeDetailsById(edgeEvent.getTenantId(), widgetTypeId);
            if (widgetTypeDetails != null) {
                WidgetTypeUpdateMsg widgetTypeUpdateMsg = widgetTypeMsgConstructor.constructWidgetTypeUpdateMsg(msgType, widgetTypeDetails);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetTypeUpdateMsg(widgetTypeUpdateMsg).build();
            }
            break;
        case DELETED:
            WidgetTypeUpdateMsg widgetTypeUpdateMsg = widgetTypeMsgConstructor.constructWidgetTypeDeleteMsg(widgetTypeId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetTypeUpdateMsg(widgetTypeUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : WidgetTypeUpdateMsg(org.thingsboard.server.gen.edge.v1.WidgetTypeUpdateMsg) DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) WidgetTypeDetails(org.thingsboard.server.common.data.widget.WidgetTypeDetails)

Example 17 with DownlinkMsg

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

the class DashboardEdgeProcessor method processDashboardToEdge.

public DownlinkMsg processDashboardToEdge(Edge edge, EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
    DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(action) {
        case ADDED:
        case UPDATED:
        case ASSIGNED_TO_EDGE:
        case ASSIGNED_TO_CUSTOMER:
        case UNASSIGNED_FROM_CUSTOMER:
            Dashboard dashboard = dashboardService.findDashboardById(edgeEvent.getTenantId(), dashboardId);
            if (dashboard != null) {
                CustomerId customerId = null;
                if (!edge.getCustomerId().isNullUid() && dashboard.isAssignedToCustomer(edge.getCustomerId())) {
                    customerId = edge.getCustomerId();
                }
                DashboardUpdateMsg dashboardUpdateMsg = dashboardMsgConstructor.constructDashboardUpdatedMsg(msgType, dashboard, customerId);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDashboardUpdateMsg(dashboardUpdateMsg).build();
            }
            break;
        case DELETED:
        case UNASSIGNED_FROM_EDGE:
            DashboardUpdateMsg dashboardUpdateMsg = dashboardMsgConstructor.constructDashboardDeleteMsg(dashboardId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDashboardUpdateMsg(dashboardUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) Dashboard(org.thingsboard.server.common.data.Dashboard) DashboardId(org.thingsboard.server.common.data.id.DashboardId) CustomerId(org.thingsboard.server.common.data.id.CustomerId) DashboardUpdateMsg(org.thingsboard.server.gen.edge.v1.DashboardUpdateMsg)

Example 18 with DownlinkMsg

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

the class DeviceProfileEdgeProcessor method processDeviceProfileToEdge.

public DownlinkMsg processDeviceProfileToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
    DeviceProfileId deviceProfileId = new DeviceProfileId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(action) {
        case ADDED:
        case UPDATED:
            DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(edgeEvent.getTenantId(), deviceProfileId);
            if (deviceProfile != null) {
                DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileMsgConstructor.constructDeviceProfileUpdatedMsg(msgType, deviceProfile);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceProfileUpdateMsg(deviceProfileUpdateMsg).build();
            }
            break;
        case DELETED:
            DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileMsgConstructor.constructDeviceProfileDeleteMsg(deviceProfileId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceProfileUpdateMsg(deviceProfileUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DeviceProfileUpdateMsg(org.thingsboard.server.gen.edge.v1.DeviceProfileUpdateMsg) DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) DeviceProfileId(org.thingsboard.server.common.data.id.DeviceProfileId)

Example 19 with DownlinkMsg

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

the class EntityEdgeProcessor method processCredentialsRequestMessageToEdge.

public DownlinkMsg processCredentialsRequestMessageToEdge(EdgeEvent edgeEvent) {
    DownlinkMsg downlinkMsg = null;
    if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) {
        DeviceId deviceId = new DeviceId(edgeEvent.getEntityId());
        DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = DeviceCredentialsRequestMsg.newBuilder().setDeviceIdMSB(deviceId.getId().getMostSignificantBits()).setDeviceIdLSB(deviceId.getId().getLeastSignificantBits()).build();
        DownlinkMsg.Builder builder = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceCredentialsRequestMsg(deviceCredentialsRequestMsg);
        downlinkMsg = builder.build();
    }
    return downlinkMsg;
}
Also used : DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) DeviceCredentialsRequestMsg(org.thingsboard.server.gen.edge.v1.DeviceCredentialsRequestMsg) DeviceId(org.thingsboard.server.common.data.id.DeviceId)

Example 20 with DownlinkMsg

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

the class EntityEdgeProcessor method processEntityMergeRequestMessageToEdge.

public DownlinkMsg processEntityMergeRequestMessageToEdge(Edge edge, EdgeEvent edgeEvent) {
    DownlinkMsg downlinkMsg = null;
    if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) {
        DeviceId deviceId = new DeviceId(edgeEvent.getEntityId());
        Device device = deviceService.findDeviceById(edge.getTenantId(), deviceId);
        CustomerId customerId = getCustomerIdIfEdgeAssignedToCustomer(device, edge);
        String conflictName = null;
        if (edgeEvent.getBody() != null) {
            conflictName = edgeEvent.getBody().get("conflictName").asText();
        }
        DeviceUpdateMsg deviceUpdateMsg = deviceMsgConstructor.constructDeviceUpdatedMsg(UpdateMsgType.ENTITY_MERGE_RPC_MESSAGE, device, customerId, conflictName);
        downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceUpdateMsg(deviceUpdateMsg).build();
    }
    return downlinkMsg;
}
Also used : DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) DeviceId(org.thingsboard.server.common.data.id.DeviceId) Device(org.thingsboard.server.common.data.Device) DeviceUpdateMsg(org.thingsboard.server.gen.edge.v1.DeviceUpdateMsg) CustomerId(org.thingsboard.server.common.data.id.CustomerId)

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