local m = {}

-- default co-mapping based on current P
m.CO = {}
m.CO.enableCo 						    = 1
m.CO.enableStatusCo 					= 2
m.CO.userAccessCo						= 3
m.CO.userAccessStatusCo				    = 4
m.CO.installerAccessCo				    = 5
m.CO.installerAccessStatusCo			= 6
m.CO.vpnAccessCo						= 9
m.CO.vpnAccessStatusCo				    =10
m.CO.connectionStateCo				    =20
m.CO.anyAccessStateCo					=21
m.CO.userAccessCurrentStateCo			=22
m.CO.installerAccessCurrentStateCo	    =23
m.CO.vpnCurrentStateCo				    =25
m.CO.errorCo							=30
m.CO.conectionInfoCo					=31
m.CO.errorInfoCo						=32

function m.AddCosToMap()
Logger:Info("-- sdamanager_module.lua: add COs")
local urn = deviceUrn_base .. ":Remote-Access:"
helper.AddAssociatedCoToMap(m.CO.enableCo, "WC", "1.003", urn .. "Enabled") -- control general portal connection
helper.AddAssociatedCoToMap(m.CO.enableStatusCo, "RTC", "1.003", urn .. "Enabled") -- status
helper.AddAssociatedCoToMap(m.CO.userAccessCo, "WC", "1.003", urn .. "User-Access") -- control resident potal connection
helper.AddAssociatedCoToMap(m.CO.userAccessStatusCo, "RTC", "1.003", urn .. "User-Access") -- status
helper.AddAssociatedCoToMap(m.CO.installerAccessCo, "WC", "1.003", urn .. "Installer-Access") -- control installer portal connection
helper.AddAssociatedCoToMap(m.CO.installerAccessStatusCo, "RTC", "1.003", urn .. "Installer-Access") -- status
helper.AddAssociatedCoToMap(m.CO.vpnAccessCo, "WC", "1.003", deviceUrn_base .. ":Remote-Access-VPN:" .. "VPN-Access") -- control VPN any connection
helper.AddAssociatedCoToMap(m.CO.vpnAccessStatusCo, "RTC", "1.003", deviceUrn_base .. ":Remote-Access-VPN:" .. "VPN-Access") -- status
helper.AddAssociatedCoToMap(m.CO.connectionStateCo, "RTC", "1.011", urn .. "Connection-State") -- state portal connection
helper.AddAssociatedCoToMap(m.CO.anyAccessStateCo, "RTC", "1.011", urn .. "Access-State") -- state any remote connection
helper.AddAssociatedCoToMap(m.CO.userAccessCurrentStateCo, "RTC", "1.011", urn .. "User-Access-State") -- state user remote connection
helper.AddAssociatedCoToMap(m.CO.installerAccessCurrentStateCo, "RTC", "1.011", urn .. "Installer-Access-State") -- state installer remote connection
helper.AddAssociatedCoToMap(m.CO.vpnCurrentStateCo, "RTC", "1.011", deviceUrn_base .. ":Remote-Access-VPN:" .. "VPN-Access-State") -- state installer remote connection
helper.AddAssociatedCoToMap(m.CO.errorCo, "RTC", "1.005", urn .. "Error") -- error indication
helper.AddAssociatedCoToMap(m.CO.conectionInfoCo, "RTC", "16.001", urn .. "Connection-Info") -- portal connection info
helper.AddAssociatedCoToMap(m.CO.errorInfoCo, "RTC", "16.001", urn .. "Error-Info") -- connection error info
end

function m.Configure(config)
    Logger:Info("-- sdamanager_module.lua: configure parameter")
    helper.LogConfiguration("SdaManager-App", config)
    local channel = device:AddChannel("Remote-Access")
    channel:AddParameterSet("SDA", "GlobalAccessStateAfterRestart", config.GeneralRemoteAccessAfterRestart)
    channel:AddParameterSet("SDA", "ResidentAccessStateAfterRestart", config.ResidentRemoteAccessAfterRestart)
    channel:AddParameterSet("SDA", "InstallerAccessStateAfterRestart", config.InstallerRemoteAccessAfterRestart)
end

return m

