Commit cb92d1d0 by huangjy

mqtt协议包修改

parent bec0eec6
......@@ -3,6 +3,7 @@ package org.jetlinks.protocol.official;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.extern.slf4j.Slf4j;
......@@ -16,6 +17,7 @@ import org.jetlinks.core.message.property.WritePropertyMessage;
import org.jetlinks.protocol.official.entity.CustomMessage;
import org.jetlinks.protocol.official.entity.CustomReadMessage;
import org.jetlinks.protocol.official.entity.CustomWriteMessage;
import org.jetlinks.protocol.official.entity.UserServerInfo;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
......@@ -125,8 +127,16 @@ public class JetLinksMqttDeviceMessageCodec implements DeviceMessageCodec {
CustomWriteMessage.PayLoad payLoad = new CustomWriteMessage.PayLoad();
payLoad.setDeviceId(deviceMessage.getDeviceId());
payLoad.setProperties(((WritePropertyMessage) deviceMessage).getProperties());
Map<String, Object> properties = ((WritePropertyMessage) deviceMessage).getProperties();
Object result = properties.get("usrServerInfo");
if (result != null) {
Map<String, Object> res = Maps.newConcurrentMap();
UserServerInfo userServerInfo = JSON.parseObject(result.toString(),UserServerInfo.class);
res.put("usrServerInfo",userServerInfo);
payLoad.setProperties(res);
} else {
payLoad.setProperties(properties);
}
customSendMessage.setPayload(payLoad);
customSendMessage.setTimestamp(deviceMessage.getTimestamp());
customSendMessage.setMessageId(deviceMessage.getMessageId());
......
package org.jetlinks.protocol.official.entity;
import lombok.Data;
@Data
public class UserServerInfo {
private String password;
private String secureKey;
private String secureId;
private String addr;
private String username;
private Integer port;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment