|
@@ -1,7 +1,6 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
- "github.com/gogf/gf/util/guid"
|
|
|
"sparrow/pkg/models"
|
|
|
"sparrow/pkg/rpcs"
|
|
|
"sparrow/pkg/server"
|
|
@@ -24,10 +23,10 @@ type DeviceService interface {
|
|
|
GetDevices(vendorid, proid string, pi, ps int, deviceid string) ([]*models.Devices, int, error)
|
|
|
//获取用户下所有设备的数量,在线设备的数量,离线设备的数量
|
|
|
GetDevicesCountByVenderId(vendorid string) (map[string]interface{}, error)
|
|
|
- // 发起设备OTA升级
|
|
|
- Upgrade(params *models.UpgradeParams) error
|
|
|
- // GetUpgradeProgress 获取ota升级进度
|
|
|
- GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgress, error)
|
|
|
+ //// 发起设备OTA升级
|
|
|
+ //Upgrade(params *models.UpgradeParams) error
|
|
|
+ //// GetUpgradeProgress 获取ota升级进度
|
|
|
+ //GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgress, error)
|
|
|
}
|
|
|
|
|
|
type deviceservice struct {
|
|
@@ -129,44 +128,44 @@ func (a deviceservice) GetDevicesCountByVenderId(vendorid string) (map[string]in
|
|
|
return deviceCount, nil
|
|
|
}
|
|
|
|
|
|
-func (a deviceservice) Upgrade(param *models.UpgradeParams) error {
|
|
|
-
|
|
|
- var fileArgs rpcs.ArgsOtaFile
|
|
|
- fileArgs.FileData = param.File
|
|
|
- fileArgs.FileId = guid.S()
|
|
|
- var reply rpcs.ReplyEmptyResult
|
|
|
-
|
|
|
- err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.SavaFile", fileArgs, &reply)
|
|
|
- if err != nil {
|
|
|
- server.Log.Errorf("OTA升级文件保存失败:%v", err)
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- var args rpcs.ArgsUpgrade4G
|
|
|
- args.DeviceId = param.DeviceID
|
|
|
- args.FileId = fileArgs.FileId
|
|
|
- args.FileSize = param.FileSize
|
|
|
-
|
|
|
- err = server.RPCCallByName(nil, rpcs.MQTTAccessName, "Access.UpgradeFor4G", args, &reply)
|
|
|
- if err != nil {
|
|
|
- server.Log.Errorf("4G模组OTA升级失败:%v", err)
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (a deviceservice) GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgress, error) {
|
|
|
- var args rpcs.ArgsOtaProgress
|
|
|
- args.DeviceId = deviceId
|
|
|
-
|
|
|
- var reply rpcs.ReplyOtaProgress
|
|
|
-
|
|
|
- err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetProgress", args, &reply)
|
|
|
- if err != nil {
|
|
|
- server.Log.Errorf("OTA升级进度获取失败:%v", err)
|
|
|
- return reply, err
|
|
|
- }
|
|
|
-
|
|
|
- return reply, nil
|
|
|
-}
|
|
|
+//func (a deviceservice) Upgrade(param *models.UpgradeParams) error {
|
|
|
+//
|
|
|
+// var fileArgs rpcs.ArgsOtaFile
|
|
|
+// fileArgs.FileData = param.File
|
|
|
+// fileArgs.FileId = guid.S()
|
|
|
+// var reply rpcs.ReplyEmptyResult
|
|
|
+//
|
|
|
+// err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.SavaFile", fileArgs, &reply)
|
|
|
+// if err != nil {
|
|
|
+// server.Log.Errorf("OTA升级文件保存失败:%v", err)
|
|
|
+// return err
|
|
|
+// }
|
|
|
+//
|
|
|
+// var args rpcs.ArgsUpgrade4G
|
|
|
+// args.DeviceId = param.DeviceID
|
|
|
+// args.FileId = fileArgs.FileId
|
|
|
+// args.FileSize = param.FileSize
|
|
|
+//
|
|
|
+// err = server.RPCCallByName(nil, rpcs.MQTTAccessName, "Access.UpgradeFor4G", args, &reply)
|
|
|
+// if err != nil {
|
|
|
+// server.Log.Errorf("4G模组OTA升级失败:%v", err)
|
|
|
+// return err
|
|
|
+// }
|
|
|
+//
|
|
|
+// return nil
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (a deviceservice) GetUpgradeProgress(deviceId string) (rpcs.ReplyOtaProgress, error) {
|
|
|
+// var args rpcs.ArgsOtaProgress
|
|
|
+// args.DeviceId = deviceId
|
|
|
+//
|
|
|
+// var reply rpcs.ReplyOtaProgress
|
|
|
+//
|
|
|
+// err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetProgress", args, &reply)
|
|
|
+// if err != nil {
|
|
|
+// server.Log.Errorf("OTA升级进度获取失败:%v", err)
|
|
|
+// return reply, err
|
|
|
+// }
|
|
|
+//
|
|
|
+// return reply, nil
|
|
|
+//}
|