#
# $Id: ipmi.dev 866 2008-05-21 20:42:37Z garlick $
#
# IPMI 1.5 in terminal mode
# Tested on Intel SE7501WV2 motherboard over serial.
# On this motherboard, the System Setup Utility is used to switch
# the BMC into terminal mode.
#
# References:
# "IPMI over Cyclades TS2000", M.P. Anand Babu
# "IPMI 1.5 Reference Guide", 13.7.8 Terminal Mode ASCII Text Commands (p.175)
# http://www.intel.com/design/servers/ipmi/
# http://www.intel.com/design/servers/ipmi/spec.htm
#
#
specification  "ipmi" {
	timeout 	10

	plug name { "1" }

	script login {
		send "\033("
		expect "\\[TMODE OK\\]\r\n"
		send "[SYS PWD -N]\r"  # null password/username
		expect "\\[OK\\]\r\n"
	}
	script logout {
		send "[SYS PWD -X]\r"
	}
	script status {
		send "[SYS HEALTH QUERY]\r"
		expect "\\[OK PWR:(ON|OFF|SLP|S4|S3|S2|S1).*\\]\r\n"
		setplugstate "1" $1 on="ON" off="OFF|SLP|S4|S3|S2|S1"
	}
	script on {
		send "[SYS POWER ON]\r"
		expect "\\[OK\\]\r\n"
	}		
	script off {
		send "[SYS POWER OFF]\r"
		expect "\\[OK\\]\r\n"
	}		
	script reset {
		send "[SYS RESET]\r"
		expect "\\[OK\\]\r\n"
	}
	script cycle {
		send "[SYS POWER OFF]\r"
		expect "\\[OK\\]\r\n"

		delay 4

		send "[SYS POWER ON]\r"
		expect "\\[OK\\]\r\n"
	}
	script status_temp {
		send "[SYS HEALTH QUERY]\r"
		expect "\\[OK PWR:[^ ]* H:.. T:(ok|nc|cr|nr|uf).*\\]\r\n"
                setplugstate "1" $1
        }
}
