# signature { license=0, seed=277031123, key="fdba407ff324ebc39868c7fe9c13938b" }
-- ----------------------------------------------------------------------------



local api = import( 'api' )
local xmlpro = import( 'xmlpro' )


xmlpro.login( cfg.XmlProUserID, cfg:password( 'XmlPro' ) )
local response = xmlpro.post( '<get format="2"><mb mb="9016"/></get>' )
local SwVersion = response:match( '<k k="0">([^<]*)</k>' )


if cfg.SwVersion ~= SwVersion then
	api.post( '/api/v1/Devices/'..cfg.DeviceId..'/version', '{"version":{"software":"%s"}}', SwVersion )
	cfg.SwVersion = SwVersion
	cfg:write()
	log( i18n("Reported new main software version "), SwVersion )
end
