package netmgrd

import (
	modem1 "hnyfkj.com.cn/rtu/linux/air720u"
	modem2 "hnyfkj.com.cn/rtu/linux/ec200u"
)

type ModemType int

const (
	Unknown ModemType = iota
	Air720U           // 合宙4G调制解调器, 注册网卡名为"eth2"
	EC200U            // 移远4G调制解调器, 注册网卡名为"usb0"
)

var (
	curModemType ModemType
)

func (m ModemType) String() string {
	switch m {
	case Air720U:
		return "合宙"
	case EC200U:
		return "移远"
	default:
		return "未知"
	}
}

func ModemInit() bool {
	if modem1.ModuleInit(false) {
		curModemType = Air720U
		return true
	} else {
		modem1.ModuleExit()
	}

	if modem2.ModuleInit(false) {
		curModemType = EC200U
		return true
	} else {
		modem2.ModuleExit()
	}

	return false
}

func ModemExit() {
	switch curModemType {
	case Air720U:
		modem1.ModuleExit()
	case EC200U:
		modem2.ModuleExit()
	}
}

func GetCurModemType() ModemType {
	return curModemType
}
