diff --git a/src/scripts/device/apply-routes.lua b/src/scripts/device/apply-routes.lua index bb933339..ce71a564 100644 --- a/src/scripts/device/apply-routes.lua +++ b/src/scripts/device/apply-routes.lua @@ -92,9 +92,6 @@ AsyncEventHook { device:set_param ("Route", param) - route_info.prev_active = true - route_info.active = true - ::skip_route:: end diff --git a/src/scripts/device/select-routes.lua b/src/scripts/device/select-routes.lua index cbfb16cf..ecd3df52 100644 --- a/src/scripts/device/select-routes.lua +++ b/src/scripts/device/select-routes.lua @@ -67,9 +67,6 @@ SimpleEventHook { avail_routes_changed = true end end - route_info.prev_active = route_info.active - route_info.active = false - route_info.save = false -- store new_route_infos [route.index] = route_info diff --git a/src/scripts/device/state-routes.lua b/src/scripts/device/state-routes.lua index e6ccba10..1f57c5b7 100644 --- a/src/scripts/device/state-routes.lua +++ b/src/scripts/device/state-routes.lua @@ -170,6 +170,8 @@ store_or_restore_routes_hook = SimpleEventHook { return end + local new_route_infos = {} + -- look at all the routes and update/reset cached information for p in device:iterate_params ("EnumRoute") do -- parse pod @@ -179,7 +181,7 @@ store_or_restore_routes_hook = SimpleEventHook { end -- find cached route information - local route_info = devinfo.find_route_info (dev_info, route, false) + local route_info = devinfo.find_route_info (dev_info, route, true) if not route_info then goto skip_enum_route end @@ -189,9 +191,16 @@ store_or_restore_routes_hook = SimpleEventHook { route_info.active = false route_info.save = false + -- store + new_route_infos [route.index] = route_info + ::skip_enum_route:: end + -- update route_infos with new prev_active, active and save changes + dev_info.route_infos = new_route_infos + new_route_infos = nil + -- check for changes in the active routes for p in device:iterate_params ("Route") do local route = cutils.parseParam (p, "Route") @@ -216,6 +225,8 @@ store_or_restore_routes_hook = SimpleEventHook { log:info (device, string.format ("new active route(%s) found of device(%s)", route.name, dev_info.name)) + route_info.prev_active = true + route_info.active = true selected_routes [tostring (route.device)] = Json.Object { index = route_info.index }:to_string ()