Added edge update config handler

This commit is contained in:
Volodymyr Babak 2020-09-25 17:29:33 +03:00
parent 8f5fefa0a0
commit 7644aa4342
3 changed files with 15 additions and 7 deletions

View File

@ -83,6 +83,7 @@ import org.thingsboard.server.gen.edge.DeviceUpdateMsg;
import org.thingsboard.server.gen.edge.DownlinkMsg; import org.thingsboard.server.gen.edge.DownlinkMsg;
import org.thingsboard.server.gen.edge.DownlinkResponseMsg; import org.thingsboard.server.gen.edge.DownlinkResponseMsg;
import org.thingsboard.server.gen.edge.EdgeConfiguration; import org.thingsboard.server.gen.edge.EdgeConfiguration;
import org.thingsboard.server.gen.edge.EdgeUpdateMsg;
import org.thingsboard.server.gen.edge.EntityDataProto; import org.thingsboard.server.gen.edge.EntityDataProto;
import org.thingsboard.server.gen.edge.EntityViewUpdateMsg; import org.thingsboard.server.gen.edge.EntityViewUpdateMsg;
import org.thingsboard.server.gen.edge.RelationRequestMsg; import org.thingsboard.server.gen.edge.RelationRequestMsg;
@ -244,12 +245,11 @@ public final class EdgeGrpcSession implements Closeable {
void onConfigurationUpdate(Edge edge) { void onConfigurationUpdate(Edge edge) {
try { try {
this.edge = edge; this.edge = edge;
// TODO: voba - push edge configuration update to edge EdgeUpdateMsg edgeConfig = EdgeUpdateMsg.newBuilder()
// sendResponseMsg(org.thingsboard.server.gen.integration.ResponseMsg.newBuilder() .setConfiguration(constructEdgeConfigProto(edge)).build();
// .setIntegrationUpdateMsg(IntegrationUpdateMsg.newBuilder() outputStream.onNext(ResponseMsg.newBuilder()
// .setConfiguration(constructIntegrationConfigProto(configuration, defaultConverterProto, downLinkConverterProto)) .setEdgeUpdateMsg(edgeConfig)
// .build()) .build());
// .build());
} catch (Exception e) { } catch (Exception e) {
log.error("Failed to construct proto objects!", e); log.error("Failed to construct proto objects!", e);
} }

View File

@ -114,6 +114,9 @@ public class EdgeGrpcClient implements EdgeRpcClient {
} }
onError.accept(new EdgeConnectionException("Failed to establish the connection! Response code: " + connectResponseMsg.getResponseCode().name())); onError.accept(new EdgeConnectionException("Failed to establish the connection! Response code: " + connectResponseMsg.getResponseCode().name()));
} }
} else if (responseMsg.hasEdgeUpdateMsg()) {
log.debug("[{}] Edge update message received {}", edgeKey, responseMsg.getEdgeUpdateMsg());
onEdgeUpdate.accept(responseMsg.getEdgeUpdateMsg().getConfiguration());
} else if (responseMsg.hasUplinkResponseMsg()) { } else if (responseMsg.hasUplinkResponseMsg()) {
log.debug("[{}] Uplink response message received {}", edgeKey, responseMsg.getUplinkResponseMsg()); log.debug("[{}] Uplink response message received {}", edgeKey, responseMsg.getUplinkResponseMsg());
onUplinkResponse.accept(responseMsg.getUplinkResponseMsg()); onUplinkResponse.accept(responseMsg.getUplinkResponseMsg());

View File

@ -44,6 +44,7 @@ message ResponseMsg {
ConnectResponseMsg connectResponseMsg = 1; ConnectResponseMsg connectResponseMsg = 1;
UplinkResponseMsg uplinkResponseMsg = 2; UplinkResponseMsg uplinkResponseMsg = 2;
DownlinkMsg downlinkMsg = 3; DownlinkMsg downlinkMsg = 3;
EdgeUpdateMsg edgeUpdateMsg = 4;
} }
enum RequestMsgType { enum RequestMsgType {
@ -52,6 +53,10 @@ enum RequestMsgType {
SYNC_REQUEST_RPC_MESSAGE = 2; SYNC_REQUEST_RPC_MESSAGE = 2;
} }
message EdgeUpdateMsg {
EdgeConfiguration configuration = 1;
}
message ConnectRequestMsg { message ConnectRequestMsg {
string edgeRoutingKey = 1; string edgeRoutingKey = 1;
string edgeSecret = 2; string edgeSecret = 2;