_DEVICE=/dev/ttyUSB2
_DEFAULT_LTE_BANDS="1 2 3 4 5 7 8 12 13 14 17 18 19 20 25 26 28 29 30 32 34 38 39 40 41 42 43 48 66 71"
_DEFAULT_5GNSA_BANDS="1 2 3 5 7 8 12 14 20 28 38 40 41 48 66 71 77 78"
_DEFAULT_5GSA_BANDS="1 2 3 5 7 8 12 14 20 28 38 40 41 48 66 71 77 78"

getinfo() {
	echo "SIMCOM SIM8200EA-M2"
}

getsupportedbands() {
	echo "$_DEFAULT_LTE_BANDS"
}

getbands() {
	O=$(sms_tool -d $_DEVICE at "AT+CSYSSEL=\"lte_band\"")
	echo "$O" | awk -F, '/^\+CSYSSEL: "lte_band",/{gsub(":"," ");print $2}' | xargs
}

setbands() {
	BANDS="$1"
	[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_LTE_BANDS"

	T=""
	for BAND in $BANDS; do
		case $BAND in
			''|*[!0-9]*) continue ;;
		esac
		[ -n "$T" ] && T="${T}:"
		T="${T}${BAND}"
	done

	[ -n "$T" ] && sms_tool -d $_DEVICE at "AT+CSYSSEL=\"lte_band\",$T"
}

getsupportedbands5gnsa() {
	echo "$_DEFAULT_5GNSA_BANDS"
}

getbands5gnsa() {
	O=$(sms_tool -d $_DEVICE at "AT+CSYSSEL=\"nsa_nr5g_band\"")
	echo "$O" | awk -F, '/^\+CSYSSEL: "nsa_nr5g_band",/{gsub(":"," ");print $2}' | xargs
}

setbands5gnsa() {
	BANDS="$1"
	[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_5GNSA_BANDS"

	T=""
	for BAND in $BANDS; do
		case $BAND in
			''|*[!0-9]*) continue ;;
		esac
		[ -n "$T" ] && T="${T}:"
		T="${T}${BAND}"
	done

	[ -n "$T" ] && sms_tool -d $_DEVICE at "AT+CSYSSEL=\"nsa_nr5g_band\",$T"
}

getsupportedbands5gsa() {
	echo "$_DEFAULT_5GSA_BANDS"
}

getbands5gsa() {
	O=$(sms_tool -d $_DEVICE at "AT+CSYSSEL=\"nr5g_band\"")
	echo "$O" | awk -F, '/^\+CSYSSEL: "nr5g_band",/{gsub(":"," ");print $2}' | xargs
}

setbands5gsa() {
	BANDS="$1"
	[ "$BANDS" = "default" ] && BANDS="$_DEFAULT_5GSA_BANDS"

	T=""
	for BAND in $BANDS; do
		case $BAND in
			''|*[!0-9]*) continue ;;
		esac
		[ -n "$T" ] && T="${T}:"
		T="${T}${BAND}"
	done

	[ -n "$T" ] && sms_tool -d $_DEVICE at "AT+CSYSSEL=\"nr5g_band\",$T"
}
