/** * Copyright © 2016-2020 The Thingsboard Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto3"; option java_package = "org.thingsboard.server.gen.edge"; option java_multiple_files = true; option java_outer_classname = "EdgeProtos"; import "queue.proto"; package edge; // Interface exported by the ThingsBoard Edge Transport. service EdgeRpcService { rpc handleMsgs(stream RequestMsg) returns (stream ResponseMsg) {} } /** * Data Structures; */ message RequestMsg { RequestMsgType msgType = 1; ConnectRequestMsg connectRequestMsg = 2; UplinkMsg uplinkMsg = 3; DownlinkResponseMsg downlinkResponseMsg = 4; } message ResponseMsg { ConnectResponseMsg connectResponseMsg = 1; UplinkResponseMsg uplinkResponseMsg = 2; DownlinkMsg downlinkMsg = 3; } enum RequestMsgType { CONNECT_RPC_MESSAGE = 0; UPLINK_RPC_MESSAGE = 1; SYNC_REQUEST_RPC_MESSAGE = 2; } message ConnectRequestMsg { string edgeRoutingKey = 1; string edgeSecret = 2; } enum ConnectResponseCode { ACCEPTED = 0; BAD_CREDENTIALS = 1; SERVER_UNAVAILABLE = 2; } message ConnectResponseMsg { ConnectResponseCode responseCode = 1; string errorMsg = 2; EdgeConfiguration configuration = 3; } message EdgeConfiguration { int64 edgeIdMSB = 1; int64 edgeIdLSB = 2; int64 tenantIdMSB = 3; int64 tenantIdLSB = 4; string name = 5; string routingKey = 6; string type = 7; string edgeLicenseKey = 8; string cloudEndpoint = 9; string cloudType = 10; } enum UpdateMsgType { ENTITY_CREATED_RPC_MESSAGE = 0; ENTITY_UPDATED_RPC_MESSAGE = 1; ENTITY_DELETED_RPC_MESSAGE = 2; ALARM_ACK_RPC_MESSAGE = 3; ALARM_CLEAR_RPC_MESSAGE = 4; DEVICE_CONFLICT_RPC_MESSAGE = 5; } message EntityDataProto { int64 entityIdMSB = 1; int64 entityIdLSB = 2; string entityType = 3; transport.PostTelemetryMsg postTelemetryMsg = 4; transport.PostAttributeMsg postAttributesMsg = 5; string postAttributeScope = 6; AttributeDeleteMsg attributeDeleteMsg = 7; // transport.ToDeviceRpcRequestMsg ??? } message AttributeDeleteMsg { string scope = 1; repeated string attributeNames = 2; } message RuleChainUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; string name = 4; int64 firstRuleNodeIdMSB = 5; int64 firstRuleNodeIdLSB = 6; bool root = 7; bool debugMode = 8; string configuration = 9; } message RuleChainMetadataUpdateMsg { UpdateMsgType msgType = 1; int64 ruleChainIdMSB = 2; int64 ruleChainIdLSB = 3; int32 firstNodeIndex = 4; repeated RuleNodeProto nodes = 5; repeated NodeConnectionInfoProto connections = 6; repeated RuleChainConnectionInfoProto ruleChainConnections = 7; } message RuleNodeProto { int64 idMSB = 1; int64 idLSB = 2; string type = 3; string name = 4; bool debugMode = 5; string configuration = 6; string additionalInfo = 7; } message NodeConnectionInfoProto { int32 fromIndex = 1; int32 toIndex = 2; string type = 3; } message RuleChainConnectionInfoProto { int32 fromIndex = 1; int64 targetRuleChainIdMSB = 2; int64 targetRuleChainIdLSB = 3; string type = 4; string additionalInfo = 5; } message DashboardUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; int64 customerIdMSB = 4; int64 customerIdLSB = 5; string title = 6; string configuration = 7; } message DeviceUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; int64 customerIdMSB = 4; int64 customerIdLSB = 5; string name = 6; string type = 7; string label = 8; string additionalInfo = 9; } message DeviceCredentialsUpdateMsg { int64 deviceIdMSB = 1; int64 deviceIdLSB = 2; string credentialsType = 3; string credentialsId = 4; string credentialsValue = 5; } message AssetUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; int64 customerIdMSB = 4; int64 customerIdLSB = 5; string name = 6; string type = 7; string label = 8; string additionalInfo = 9; } message EntityViewUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; int64 customerIdMSB = 4; int64 customerIdLSB = 5; string name = 6; string type = 7; int64 entityIdMSB = 8; int64 entityIdLSB = 9; EdgeEntityType entityType = 10; string additionalInfo = 11; } message AlarmUpdateMsg { UpdateMsgType msgType = 1; string name = 2; string type = 3; string originatorType = 4; string originatorName = 5; string severity = 6; string status = 7; int64 startTs = 8; int64 endTs = 9; int64 ackTs = 10; int64 clearTs = 11; string details = 12; bool propagate = 13; } message CustomerUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; string title = 4; string country = 5; string state = 6; string city = 7; string address = 8; string address2 = 9; string zip = 10; string phone = 11; string email = 12; string additionalInfo = 13; } message RelationUpdateMsg { UpdateMsgType msgType = 1; int64 fromIdMSB = 2; int64 fromIdLSB = 3; string fromEntityType = 4; int64 toIdMSB = 5; int64 toIdLSB = 6; string toEntityType = 7; string type = 8; string typeGroup = 9; string additionalInfo = 10; } message UserUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; int64 customerIdMSB = 4; int64 customerIdLSB = 5; string email = 6; string authority = 7; string firstName = 8; string lastName = 9; string additionalInfo = 10; } message WidgetsBundleUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; string title = 4; string alias = 5; bytes image = 6; bool isSystem = 7; } message WidgetTypeUpdateMsg { UpdateMsgType msgType = 1; int64 idMSB = 2; int64 idLSB = 3; string bundleAlias = 4; string alias = 5; string name = 6; string descriptorJson = 7; bool isSystem = 8; } message AdminSettingsUpdateMsg { bool isSystem = 1; string key = 2; string jsonValue = 3; } message UserCredentialsUpdateMsg { int64 userIdMSB = 1; int64 userIdLSB = 2; bool enabled = 3; string password = 4; } message RuleChainMetadataRequestMsg { int64 ruleChainIdMSB = 1; int64 ruleChainIdLSB = 2; } message AttributesRequestMsg { int64 entityIdMSB = 1; int64 entityIdLSB = 2; string entityType = 3; } message RelationRequestMsg { int64 entityIdMSB = 1; int64 entityIdLSB = 2; string entityType = 3; } message UserCredentialsRequestMsg { int64 userIdMSB = 1; int64 userIdLSB = 2; } message DeviceCredentialsRequestMsg { int64 deviceIdMSB = 1; int64 deviceIdLSB = 2; } message DeviceRpcCallMsg { int64 deviceIdMSB = 1; int64 deviceIdLSB = 2; int64 requestIdMSB = 3; int64 requestIdLSB = 4; int64 expirationTime = 5; bool oneway = 6; string originServiceId = 7; RpcRequestMsg requestMsg = 8; RpcResponseMsg responseMsg = 9; } message RpcRequestMsg { string method = 1; string params = 2; } message RpcResponseMsg { string response = 1; string error = 2; } enum EdgeEntityType { DEVICE = 0; ASSET = 1; } /** * Main Messages; */ message UplinkMsg { int32 uplinkMsgId = 1; repeated EntityDataProto entityData = 2; repeated DeviceUpdateMsg deviceUpdateMsg = 3; repeated DeviceCredentialsUpdateMsg deviceCredentialsUpdateMsg = 4; repeated AlarmUpdateMsg alarmUpdateMsg = 5; repeated RelationUpdateMsg relationUpdateMsg = 6; repeated RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg = 7; repeated AttributesRequestMsg attributesRequestMsg = 8; repeated RelationRequestMsg relationRequestMsg = 9; repeated UserCredentialsRequestMsg userCredentialsRequestMsg = 10; repeated DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = 11; repeated DeviceRpcCallMsg deviceRpcCallMsg = 12; } message UplinkResponseMsg { bool success = 1; string errorMsg = 2; } message DownlinkResponseMsg { bool success = 1; string errorMsg = 2; } message DownlinkMsg { int32 downlinkMsgId = 1; repeated EntityDataProto entityData = 2; repeated DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = 3; repeated DeviceUpdateMsg deviceUpdateMsg = 4; repeated DeviceCredentialsUpdateMsg deviceCredentialsUpdateMsg = 5; repeated RuleChainUpdateMsg ruleChainUpdateMsg = 6; repeated RuleChainMetadataUpdateMsg ruleChainMetadataUpdateMsg = 7; repeated DashboardUpdateMsg dashboardUpdateMsg = 8; repeated AssetUpdateMsg assetUpdateMsg = 9; repeated EntityViewUpdateMsg entityViewUpdateMsg = 10; repeated AlarmUpdateMsg alarmUpdateMsg = 11; repeated UserUpdateMsg userUpdateMsg = 12; repeated UserCredentialsUpdateMsg userCredentialsUpdateMsg = 13; repeated CustomerUpdateMsg customerUpdateMsg = 14; repeated RelationUpdateMsg relationUpdateMsg = 15; repeated WidgetsBundleUpdateMsg widgetsBundleUpdateMsg = 16; repeated WidgetTypeUpdateMsg widgetTypeUpdateMsg = 17; repeated AdminSettingsUpdateMsg adminSettingsUpdateMsg = 18; repeated DeviceRpcCallMsg deviceRpcCallMsg = 19; }