From f246252e5390a3de99091378b69d57a21b1cf18a Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Wed, 30 Oct 2013 21:20:42 +0100 Subject: [PATCH] Goto access point mode before update --- src/network/netconfig.lua | 17 +++++++++++++++++ src/rest/api/api_update.lua | 9 ++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 96ddcbc..e4a0d38 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -296,6 +296,23 @@ function M.setupAccessPoint(ssid) return true end +--- set the network configuration to accesspoint, but don't reload (used before updating) +-- Note: this function might belong in the wlanconfig module but that would introduce +-- a circular dependency, easiest solution is to place the function here. +-- @tparam string ssid The SSID to use for the access point. +-- @return True on success or nil+msg on error. +function M.enableAccessPoint(ssid) + log:debug("enableAccessPoint ssid: ".. utils.dump(ssid)) + + M.switchConfiguration{apnet="add_noreload"} + wifi.activateConfig(ssid) + + local ds = wifi.getDeviceState() + log:debug(" ssid: ".. utils.dump(ds.ssid)) + + return true +end + --- Associates wlan device as client with the given SSID. -- Note: this function might belong in the wlanconfig module but that would introduce -- a circular dependency, easiest solution is to place the function here. diff --git a/src/rest/api/api_update.lua b/src/rest/api/api_update.lua index 0279ab4..44e843d 100644 --- a/src/rest/api/api_update.lua +++ b/src/rest/api/api_update.lua @@ -1,3 +1,7 @@ +local wifi = require('network.wlanconfig') +local netconf = require('network.netconfig') +local settings = require('util.settings') + -- NOTE: the module 'detects' command-line invocation by existence of 'arg', so we have to make sure it is not defined. argStash = arg arg = nil @@ -144,7 +148,10 @@ function M.install_POST(request, response) updater.setLogger(log) updater.setState(updater.STATE.INSTALLING,"") - + + local ssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) + local rv,msg = netconf.enableAccessPoint(ssid) + if not argVersion then local success,status,msg = updater.getStatus() if not success then