--[[
  init_knxstack.lua
  This lua script is called in the Init() function of the DscKnxAppPrgNG and
  inits the knxstack, e.g. creates all interface objects and registers the
  properties.
]]--

Logger:Info("-- init_knxstack.lua for RemoteAccess started --")

package.path = package.path .. ';/opt/gira/etc/dscknxappprgng/?.lua'

local helper = require("helper")

local downloadVersionMajor,downloadVersionMinor = helper.GetAppPrg1Version()
Logger:Info(string.format("Found application program 1 version %d.%d", downloadVersionMajor, downloadVersionMinor))

-- Handle the correct PDB version

if downloadVersionMajor >= 7 then
  Logger:Info("Init knxstack with v7 handler for application program 1.")
  require("init_knxstack_7")
elseif downloadVersionMajor >= 5 then
  -- PDB version 5 and 6 are equal during download handling but we can only receive 6er downloads due to the magick number 1
  Logger:Info("Init knxstack with v6 handler for supported old application program 1.")
  require("init_knxstack_6")
else
  error("Incompatible application program 1 version for this firmware found! This firmware supports v6 and v7 ETS product databases.")
end

Logger:Info("-- init_knxstack.lua for RemoteAccess done --")
