--[[
ģƣӲ(ֿ֧Ӻ͹ػӣͬʱֻܴһӣʵֶӣȵǰӴٴεýӿȥһ)
ģ鹦ܣӹ
ģ޸ʱ䣺2017.12.19
]]

--ntpģ飬ͬʱ
require"ntp"
module(...,package.seeall)

--[[
print
  ӡӿڣļедӡtestǰ׺
  
ֵ
]]
local function print(...)
	_G.print("test",...)
end

--[[
ntpind
  ͬʱϢĴ
  idϢid˴Ϊ"NTP_IND"
		resultϢЯĲ˴ΪͬʱĽtrueΪɹfalseΪʧ
ֵtruetrueʾطעNTP_INDϢĴNTP_IND˺ͷfalsenil
]]
local function ntpind(id,result)
	print("ntpind",id,result)
	--ͬʱɹֱӲοǰʱӼ
	if result then
		--ʱΪ2017121912250룬ûʱݵǰʱ޸Ĵֵ
		--set_alarmӿڲ˵һ1ʾӣ0ʾرӣ6ʾʱ룬رʱ60,0,0,0,0,0
		rtos.set_alarm(1,2017,12,19,12,25,0)
		--ҪԹػӣд
		rtos.poweroff()
	end
	return true
end

--[[
alarmsg
  ¼Ĵ
  
ֵ
]]
local function alarmsg()
	print("alarmsg")
end

--ǹػӿҪһΣGSMЭջ
if rtos.poweron_reason()==rtos.POWERON_ALARM then
	sys.restart("ALARM")
end

--עͬʱϢĴ
sys.regapp(ntpind,"NTP_IND")

--עģ
rtos.init_module(rtos.MOD_ALARM)
--עϢĴǿӣ¼ʱalarmsg
sys.regmsg(rtos.MSG_ALARM,alarmsg)
