Commit edcad249a313fc3c69f833efe43d6a654edd058a

Authored by rodrigoabella
Committed by Andrew Shvayka
1 parent 0a668d0a

deviceName added to attribute response message

@@ -139,11 +139,11 @@ public class JsonMqttAdaptor implements MqttTransportAdaptor { @@ -139,11 +139,11 @@ public class JsonMqttAdaptor implements MqttTransportAdaptor {
139 } 139 }
140 140
141 @Override 141 @Override
142 - public Optional<MqttMessage> convertToGatewayPublish(MqttDeviceAwareSessionContext ctx, TransportProtos.GetAttributeResponseMsg responseMsg) throws AdaptorException { 142 + public Optional<MqttMessage> convertToGatewayPublish(MqttDeviceAwareSessionContext ctx, String deviceName, TransportProtos.GetAttributeResponseMsg responseMsg) throws AdaptorException {
143 if (!StringUtils.isEmpty(responseMsg.getError())) { 143 if (!StringUtils.isEmpty(responseMsg.getError())) {
144 throw new AdaptorException(responseMsg.getError()); 144 throw new AdaptorException(responseMsg.getError());
145 } else { 145 } else {
146 - JsonObject result = JsonConverter.getJsonObjectForGateway(responseMsg); 146 + JsonObject result = JsonConverter.getJsonObjectForGateway(deviceName, responseMsg);
147 return Optional.of(createMqttPublishMsg(ctx, MqttTopics.GATEWAY_ATTRIBUTES_RESPONSE_TOPIC, result)); 147 return Optional.of(createMqttPublishMsg(ctx, MqttTopics.GATEWAY_ATTRIBUTES_RESPONSE_TOPIC, result));
148 } 148 }
149 } 149 }
@@ -48,7 +48,7 @@ public interface MqttTransportAdaptor { @@ -48,7 +48,7 @@ public interface MqttTransportAdaptor {
48 48
49 Optional<MqttMessage> convertToPublish(MqttDeviceAwareSessionContext ctx, GetAttributeResponseMsg responseMsg) throws AdaptorException; 49 Optional<MqttMessage> convertToPublish(MqttDeviceAwareSessionContext ctx, GetAttributeResponseMsg responseMsg) throws AdaptorException;
50 50
51 - Optional<MqttMessage> convertToGatewayPublish(MqttDeviceAwareSessionContext ctx, GetAttributeResponseMsg responseMsg) throws AdaptorException; 51 + Optional<MqttMessage> convertToGatewayPublish(MqttDeviceAwareSessionContext ctx, String deviceName, GetAttributeResponseMsg responseMsg) throws AdaptorException;
52 52
53 Optional<MqttMessage> convertToPublish(MqttDeviceAwareSessionContext ctx, AttributeUpdateNotificationMsg notificationMsg) throws AdaptorException; 53 Optional<MqttMessage> convertToPublish(MqttDeviceAwareSessionContext ctx, AttributeUpdateNotificationMsg notificationMsg) throws AdaptorException;
54 54
@@ -65,7 +65,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple @@ -65,7 +65,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple
65 @Override 65 @Override
66 public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg response) { 66 public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg response) {
67 try { 67 try {
68 - parent.getAdaptor().convertToGatewayPublish(this, response).ifPresent(parent::writeAndFlush); 68 + parent.getAdaptor().convertToGatewayPublish(this, getDeviceInfo().getDeviceName(), response).ifPresent(parent::writeAndFlush);
69 } catch (Exception e) { 69 } catch (Exception e) {
70 log.trace("[{}] Failed to convert device attributes response to MQTT msg", sessionId, e); 70 log.trace("[{}] Failed to convert device attributes response to MQTT msg", sessionId, e);
71 } 71 }
@@ -257,9 +257,10 @@ public class JsonConverter { @@ -257,9 +257,10 @@ public class JsonConverter {
257 return result; 257 return result;
258 } 258 }
259 259
260 - public static JsonObject getJsonObjectForGateway(TransportProtos.GetAttributeResponseMsg responseMsg) { 260 + public static JsonObject getJsonObjectForGateway(String deviceName, TransportProtos.GetAttributeResponseMsg responseMsg) {
261 JsonObject result = new JsonObject(); 261 JsonObject result = new JsonObject();
262 result.addProperty("id", responseMsg.getRequestId()); 262 result.addProperty("id", responseMsg.getRequestId());
  263 + result.addProperty(DEVICE_PROPERTY, deviceName);
263 if (responseMsg.getClientAttributeListCount() > 0) { 264 if (responseMsg.getClientAttributeListCount() > 0) {
264 addValues(result, responseMsg.getClientAttributeListList()); 265 addValues(result, responseMsg.getClientAttributeListList());
265 } 266 }