api_handlers.go 670 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "context"
  4. "strconv"
  5. "hnyfkj.com.cn/rtu/linux/netmgrd"
  6. "hnyfkj.com.cn/rtu/linux/utils/jsonrpc2"
  7. )
  8. func getModemInfo(ctx context.Context, req *jsonrpc2.Request) *jsonrpc2.Response {
  9. result := map[string]string{
  10. "imei": netmgrd.GetIMEI(),
  11. "iccid": netmgrd.GetSimICCID(),
  12. "rssi": netmgrd.GetRSSI(),
  13. }
  14. return jsonrpc2.BuildResponse(req, result, nil)
  15. }
  16. func getNetStatus(ctx context.Context, req *jsonrpc2.Request) *jsonrpc2.Response {
  17. result := map[string]string{
  18. "net_ok": strconv.FormatBool(netmgrd.IsInetAvailable()),
  19. "net_type": netmgrd.GetCurrentNetType().String(),
  20. }
  21. return jsonrpc2.BuildResponse(req, result, nil)
  22. }