|
@@ -31,7 +31,7 @@ type DeviceService interface {
|
|
// GetDeviceStatus 获取设备状态数据
|
|
// GetDeviceStatus 获取设备状态数据
|
|
GetDeviceStatus(deviceId string) (*gjson.Json, error)
|
|
GetDeviceStatus(deviceId string) (*gjson.Json, error)
|
|
// SetReport 获取设备状态
|
|
// SetReport 获取设备状态
|
|
- SetReport(params models.SendCommandParams) error
|
|
|
|
|
|
+ SetReport(params models.SendCommandParams) (*gjson.Json, error)
|
|
// Restart 重启设备
|
|
// Restart 重启设备
|
|
Restart(params models.SendCommandParams) error
|
|
Restart(params models.SendCommandParams) error
|
|
// ClearData 清除设备配置数据
|
|
// ClearData 清除设备配置数据
|
|
@@ -39,7 +39,7 @@ type DeviceService interface {
|
|
// SetDataTrans 设备端自动上报配置
|
|
// SetDataTrans 设备端自动上报配置
|
|
SetDataTrans(params models.SendCommandParams) error
|
|
SetDataTrans(params models.SendCommandParams) error
|
|
// GetInfo 获取网关信息
|
|
// GetInfo 获取网关信息
|
|
- GetInfo(params models.SendCommandParams) error
|
|
|
|
|
|
+ GetInfo(params models.SendCommandParams) (*gjson.Json, error)
|
|
// ForceRun 远程控制某个模块强制运行
|
|
// ForceRun 远程控制某个模块强制运行
|
|
ForceRun(params models.SendCommandParams) error
|
|
ForceRun(params models.SendCommandParams) error
|
|
// SetDeviceId 写入设备id
|
|
// SetDeviceId 写入设备id
|
|
@@ -207,11 +207,15 @@ func (a deviceservice) GetDeviceStatus(deviceId string) (*gjson.Json, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// SetReport 获取设备状态
|
|
// SetReport 获取设备状态
|
|
-func (a deviceservice) SetReport(params models.SendCommandParams) error {
|
|
|
|
|
|
+func (a deviceservice) SetReport(params models.SendCommandParams) (*gjson.Json, error) {
|
|
var args rpcs.ArgsSendCommand
|
|
var args rpcs.ArgsSendCommand
|
|
args.DeviceId = params.DeviceId
|
|
args.DeviceId = params.DeviceId
|
|
args.Cmd = string(models.Report)
|
|
args.Cmd = string(models.Report)
|
|
- return a.sendCommand(args)
|
|
|
|
|
|
+ err := a.sendCommand(args)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ return a.GetDeviceStatus(params.DeviceId)
|
|
}
|
|
}
|
|
|
|
|
|
// Restart 重启设备
|
|
// Restart 重启设备
|
|
@@ -243,11 +247,25 @@ func (a deviceservice) SetDataTrans(params models.SendCommandParams) error {
|
|
}
|
|
}
|
|
|
|
|
|
// GetInfo 获取网关信息
|
|
// GetInfo 获取网关信息
|
|
-func (a deviceservice) GetInfo(params models.SendCommandParams) error {
|
|
|
|
|
|
+func (a deviceservice) GetInfo(params models.SendCommandParams) (*gjson.Json, error) {
|
|
var args rpcs.ArgsSendCommand
|
|
var args rpcs.ArgsSendCommand
|
|
args.DeviceId = params.DeviceId
|
|
args.DeviceId = params.DeviceId
|
|
args.Cmd = string(models.GetInfo)
|
|
args.Cmd = string(models.GetInfo)
|
|
- return a.sendCommand(args)
|
|
|
|
|
|
+ err := a.sendCommand(args)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var newArgs rpcs.ArgsGetStatus
|
|
|
|
+ newArgs.Id = params.DeviceId
|
|
|
|
+ var reply rpcs.ReplayInfo
|
|
|
|
+
|
|
|
|
+ err = server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetDeviceInfo", newArgs, &reply)
|
|
|
|
+ if err != nil {
|
|
|
|
+ server.Log.Errorf("设备状态数据获取失败:%v", err)
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ return gjson.New(reply.Info), nil
|
|
}
|
|
}
|
|
|
|
|
|
// ForceRun 远程控制某个模块强制运行
|
|
// ForceRun 远程控制某个模块强制运行
|
|
@@ -268,7 +286,8 @@ func (a deviceservice) SetDeviceId(params models.SendCommandParams) error {
|
|
args.DeviceId = params.DeviceId
|
|
args.DeviceId = params.DeviceId
|
|
args.Cmd = string(models.SetDeviceId)
|
|
args.Cmd = string(models.SetDeviceId)
|
|
args.Params = map[string]interface{}{
|
|
args.Params = map[string]interface{}{
|
|
- "id": params.Id,
|
|
|
|
|
|
+ "id": params.Id,
|
|
|
|
+ "prefix": params.Prefix,
|
|
}
|
|
}
|
|
return a.sendCommand(args)
|
|
return a.sendCommand(args)
|
|
}
|
|
}
|