|
|
@@ -4,6 +4,8 @@ import (
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
|
|
|
"hnyfkj.com.cn/rtu/linux/utils/jsonrpc2"
|
|
|
)
|
|
|
@@ -32,8 +34,9 @@ func CallRPCResult(ctx context.Context, port int, method string, params any, res
|
|
|
return json.Unmarshal(resp.Result, result)
|
|
|
}
|
|
|
|
|
|
-func GetNetworkInfo(ctx context.Context) (netOK string, netType string, iccid string, rssi string, err error) {
|
|
|
+func GetNetworkInfo(ctx context.Context) (netOK string, netType string, imei string, iccid string, rssi string, err error) {
|
|
|
var modem struct {
|
|
|
+ IMEI string `json:"imei"`
|
|
|
ICCID string `json:"iccid"`
|
|
|
RSSI string `json:"rssi"`
|
|
|
}
|
|
|
@@ -43,14 +46,14 @@ func GetNetworkInfo(ctx context.Context) (netOK string, netType string, iccid st
|
|
|
}
|
|
|
|
|
|
if err = CallRPCResult(ctx, 7000, "core.getNetStatus", nil, &net); err != nil {
|
|
|
- return "", "", "", "", err
|
|
|
+ return "", "", "", "", "", err
|
|
|
}
|
|
|
|
|
|
if err = CallRPCResult(ctx, 7000, "core.getModemInfo", nil, &modem); err != nil {
|
|
|
- return "", "", "", "", err
|
|
|
+ return "", "", "", "", "", err
|
|
|
}
|
|
|
|
|
|
- return net.Status, net.Type, modem.ICCID, modem.RSSI, nil
|
|
|
+ return net.Status, net.Type, modem.IMEI, modem.ICCID, modem.RSSI, nil
|
|
|
}
|
|
|
|
|
|
func GetGpsPosition(ctx context.Context) (string, string, error) {
|
|
|
@@ -67,17 +70,22 @@ func GetGpsPosition(ctx context.Context) (string, string, error) {
|
|
|
return pos.Lat, pos.Lon, nil
|
|
|
}
|
|
|
|
|
|
-func GetCameraCount(ctx context.Context) (hk string, dh string, err error) {
|
|
|
+func GetCameraCount(ctx context.Context) (hk, dh int, err error) {
|
|
|
+ var hkStr, dhStr string
|
|
|
+
|
|
|
if err = CallRPCResult(ctx, 7003, "core.getSupportedCameraCount",
|
|
|
- map[string]string{"type": "hk"}, &hk); err != nil {
|
|
|
- return "", "", err
|
|
|
+ map[string]string{"type": "hk"}, &hkStr); err != nil {
|
|
|
+ return 0, 0, err
|
|
|
}
|
|
|
|
|
|
if err = CallRPCResult(ctx, 7003, "core.getSupportedCameraCount",
|
|
|
- map[string]string{"type": "dh"}, &dh); err != nil {
|
|
|
- return "", "", err
|
|
|
+ map[string]string{"type": "dh"}, &dhStr); err != nil {
|
|
|
+ return 0, 0, err
|
|
|
}
|
|
|
|
|
|
+ hk, _ = strconv.Atoi(strings.TrimSpace(hkStr))
|
|
|
+ dh, _ = strconv.Atoi(strings.TrimSpace(dhStr))
|
|
|
+
|
|
|
return hk, dh, nil
|
|
|
}
|
|
|
|