Commit edcad249a313fc3c69f833efe43d6a654edd058a
Committed by
Andrew Shvayka
1 parent
0a668d0a
deviceName added to attribute response message
Showing
4 changed files
with
6 additions
and
5 deletions
... | ... | @@ -139,11 +139,11 @@ public class JsonMqttAdaptor implements MqttTransportAdaptor { |
139 | 139 | } |
140 | 140 | |
141 | 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 | 143 | if (!StringUtils.isEmpty(responseMsg.getError())) { |
144 | 144 | throw new AdaptorException(responseMsg.getError()); |
145 | 145 | } else { |
146 | - JsonObject result = JsonConverter.getJsonObjectForGateway(responseMsg); | |
146 | + JsonObject result = JsonConverter.getJsonObjectForGateway(deviceName, responseMsg); | |
147 | 147 | return Optional.of(createMqttPublishMsg(ctx, MqttTopics.GATEWAY_ATTRIBUTES_RESPONSE_TOPIC, result)); |
148 | 148 | } |
149 | 149 | } | ... | ... |
... | ... | @@ -48,7 +48,7 @@ public interface MqttTransportAdaptor { |
48 | 48 | |
49 | 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 | 53 | Optional<MqttMessage> convertToPublish(MqttDeviceAwareSessionContext ctx, AttributeUpdateNotificationMsg notificationMsg) throws AdaptorException; |
54 | 54 | ... | ... |
... | ... | @@ -65,7 +65,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple |
65 | 65 | @Override |
66 | 66 | public void onGetAttributesResponse(TransportProtos.GetAttributeResponseMsg response) { |
67 | 67 | try { |
68 | - parent.getAdaptor().convertToGatewayPublish(this, response).ifPresent(parent::writeAndFlush); | |
68 | + parent.getAdaptor().convertToGatewayPublish(this, getDeviceInfo().getDeviceName(), response).ifPresent(parent::writeAndFlush); | |
69 | 69 | } catch (Exception e) { |
70 | 70 | log.trace("[{}] Failed to convert device attributes response to MQTT msg", sessionId, e); |
71 | 71 | } | ... | ... |
... | ... | @@ -257,9 +257,10 @@ public class JsonConverter { |
257 | 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 | 261 | JsonObject result = new JsonObject(); |
262 | 262 | result.addProperty("id", responseMsg.getRequestId()); |
263 | + result.addProperty(DEVICE_PROPERTY, deviceName); | |
263 | 264 | if (responseMsg.getClientAttributeListCount() > 0) { |
264 | 265 | addValues(result, responseMsg.getClientAttributeListList()); |
265 | 266 | } | ... | ... |