use of org.thingsboard.server.common.msg.kv.AttributesKVMsg in project thingsboard by thingsboard.
the class JsonCoapAdaptor method convertGetAttributesResponse.
private Response convertGetAttributesResponse(GetAttributesResponse msg) {
if (msg.isSuccess()) {
Optional<AttributesKVMsg> payload = msg.getData();
if (!payload.isPresent() || (payload.get().getClientAttributes().isEmpty() && payload.get().getSharedAttributes().isEmpty())) {
return new Response(ResponseCode.NOT_FOUND);
} else {
Response response = new Response(ResponseCode.CONTENT);
JsonObject result = JsonConverter.toJson(payload.get(), false);
response.setPayload(result.toString());
return response;
}
} else {
return convertError(msg.getError());
}
}
use of org.thingsboard.server.common.msg.kv.AttributesKVMsg in project thingsboard by thingsboard.
the class GatewayDeviceSessionCtx method createMqttPublishMsg.
private MqttMessage createMqttPublishMsg(String topic, GetAttributesResponse response) {
JsonObject result = new JsonObject();
result.addProperty("id", response.getRequestId());
result.addProperty(DEVICE_PROPERTY, device.getName());
Optional<AttributesKVMsg> responseData = response.getData();
if (responseData.isPresent()) {
AttributesKVMsg msg = responseData.get();
if (msg.getClientAttributes() != null) {
addValues(result, msg.getClientAttributes());
}
if (msg.getSharedAttributes() != null) {
addValues(result, msg.getSharedAttributes());
}
}
return createMqttPublishMsg(topic, result);
}
Aggregations