mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
设备信号实时显示
This commit is contained in:
@@ -195,8 +195,8 @@ public class ToolController extends BaseController {
|
||||
if (model.getAction().equals("client_disconnected")) {
|
||||
device.setStatus(4);
|
||||
deviceService.updateDeviceStatusAndLocation(device, "");
|
||||
// 发布设备状态
|
||||
emqxService.publishStatus(device.getProductId(), device.getSerialNumber(), 4, device.getIsShadow());
|
||||
// 设备掉线后发布设备状态
|
||||
emqxService.publishStatus(device.getProductId(), device.getSerialNumber(), 4, device.getIsShadow(),device.getRssi());
|
||||
// 清空保留消息,上线后发布新的属性功能保留消息
|
||||
emqxService.publishProperty(device.getProductId(), device.getSerialNumber(), null);
|
||||
emqxService.publishFunction(device.getProductId(), device.getSerialNumber(), null);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class EmqxService {
|
||||
device.setSerialNumber(deviceNum);
|
||||
deviceService.reportDevice(device,deviceEntity);
|
||||
// 发布设备状态
|
||||
publishStatus(productId, deviceNum, 3, deviceEntity.getIsShadow());
|
||||
publishStatus(productId, deviceNum, 3, deviceEntity.getIsShadow(),device.getRssi());
|
||||
} catch (Exception e) {
|
||||
logger.error("接收设备信息,解析数据时异常 message={}", e.getMessage());
|
||||
}
|
||||
@@ -216,8 +216,8 @@ public class EmqxService {
|
||||
/**
|
||||
* 1.发布设备状态
|
||||
*/
|
||||
public void publishStatus(Long productId, String deviceNum, int deviceStatus, int isShadow) {
|
||||
String message = "{\"status\":" + deviceStatus + ",\"isShadow\":" + isShadow + "}";
|
||||
public void publishStatus(Long productId, String deviceNum, int deviceStatus, int isShadow,int rssi) {
|
||||
String message = "{\"status\":" + deviceStatus + ",\"isShadow\":" + isShadow + ",\"rssi\":" + rssi + "}";
|
||||
emqxClient.publish(1, false, "/" + productId + "/" + deviceNum + pStatusTopic, message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user