modem.go 809 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package netmgrd
  2. import (
  3. modem1 "hnyfkj.com.cn/rtu/linux/air720u"
  4. modem2 "hnyfkj.com.cn/rtu/linux/ec200u"
  5. )
  6. type ModemType int
  7. const (
  8. Unknown ModemType = iota
  9. Air720U // 合宙4G调制解调器
  10. EC200U // 移远4G调制解调器
  11. )
  12. var (
  13. curModemType ModemType
  14. )
  15. func (m ModemType) String() string {
  16. switch m {
  17. case Air720U:
  18. return "合宙"
  19. case EC200U:
  20. return "移远"
  21. default:
  22. return "未知"
  23. }
  24. }
  25. func ModemInit() bool {
  26. if modem1.ModuleInit(false) {
  27. curModemType = Air720U
  28. return true
  29. }
  30. if modem2.ModuleInit(false) {
  31. curModemType = EC200U
  32. return true
  33. }
  34. return false
  35. }
  36. func ModemExit() {
  37. switch curModemType {
  38. case Air720U:
  39. modem1.ModuleExit()
  40. case EC200U:
  41. modem2.ModuleExit()
  42. }
  43. }
  44. func GetCurModemType() ModemType {
  45. return curModemType
  46. }