Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should open accesspoint when fails connecting to network ssid #41

Open
arneboon opened this issue Jul 1, 2015 · 9 comments
Open

should open accesspoint when fails connecting to network ssid #41

arneboon opened this issue Jul 1, 2015 · 9 comments

Comments

@arneboon
Copy link
Contributor

arneboon commented Jul 1, 2015

see this line here:

https://github.com/Doodle3D/doodle3d-firmware/blob/master/src/main.lua#L104

if connectWith then
        local rv,msg = netconf.associateSsid(connectWith,nil,nil)
        if rv then
            return true, "autowifi: associated -- client mode with ssid '" .. connectWith .. "'"
        else
            return nil, "autowifi: could not associate with ssid '" .. connectWith .. "' (" .. msg .. ")"
        end

in the else it should open up the accesspoint again

@arneboon arneboon added the bug label Jul 1, 2015
@arneboon
Copy link
Contributor Author

arneboon commented Jul 1, 2015

tested the scenario of changing to wifi network with incorrect password. cannot connect (obviously) and then it doesn't create an accesspoint either.

http://192.168.5.1/d3dapi/network/status

{
data: {
bssid: "",
channel: "",
mode: "sta",
noise: -86,
quality_max: 70,
ssid: "",
status: "-1",
statusMessage: "Could not associate with network (incorrect password?)",
txpower: 18
},
msg: "Could not associate with network (incorrect password?)",
status: "success"
}

wifibox log

07-01 14:30:31 (info)     =======rest api (api debugging)=======
07-01 14:30:31 (info)     received request of type POST for network/associate
07-01 14:30:31 (info)     remote IP/port: 10.0.0.102/54570
01-07 14:30:31  [IPC] command: [>>getState]
01-07 14:30:31  [IPC] command: [<<ok]
07-01 14:30:31 (info)     netconfig:associateSsid: werkplaats, true
07-01 14:30:31 (info)     network:setStatus: 1 | Connecting...
07-01 14:30:31 (info)     start wifi scan
07-01 14:30:31 (info)     =======rest api (api debugging)=======
07-01 14:30:31 (info)     received request of type GET for info/status
07-01 14:30:31 (info)     remote IP/port: 10.0.0.102/54526
07-01 14:30:32 (info)     =======rest api (api debugging)=======
07-01 14:30:32 (info)     received request of type GET for network/status
07-01 14:30:32 (info)     remote IP/port: 10.0.0.102/54571
07-01 14:30:32 (info)     network:getStatus
07-01 14:30:32 (info)     =======rest api (api debugging)=======
07-01 14:30:32 (info)     received request of type GET for info/status
07-01 14:30:32 (info)     remote IP/port: 10.0.0.102/54571
07-01 14:30:32 (info)     =======rest api (api debugging)=======
07-01 14:30:32 (info)     received request of type GET for info/status
07-01 14:30:32 (info)     remote IP/port: 10.0.0.102/54571
07-01 14:30:32 (info)     =======rest api (api debugging)=======
07-01 14:30:32 (info)     received request of type GET for info/status
07-01 14:30:32 (info)     remote IP/port: 10.0.0.102/54526
07-01 14:30:33 (info)     =======rest api (api debugging)=======
07-01 14:30:33 (info)     wifi scan done
07-01 14:30:33 (info)     received request of type GET for network/status
07-01 14:30:33 (info)     remote IP/port: 10.0.0.102/54571
07-01 14:30:33 (info)     network:getStatus
07-01 14:30:33 (debug)     reconfiguring component 'wwwredir' (rm)
07-01 14:30:33 (debug)     reconfiguring component 'dnsredir' (rm)
07-01 14:30:33 (debug)     reconfiguring component 'staticaddr' (rm)
07-01 14:30:33 (debug)     reconfiguring component 'wifiiface' (add)
07-01 14:30:33 (debug)     reconfiguring component 'dhcppool' (rm)
07-01 14:30:33 (info)     committing component 'dhcp'
07-01 14:30:33 (info)     committing component 'network'
07-01 14:30:33 (info)     committing component 'uhttpd'
07-01 14:30:33 (info)     reloading component 'dnsmasq'
07-01 14:30:34 (debug)       result reloading component 'dnsmasq' (cmd: '/etc/init.d/dnsmasq reload'):

07-01 14:30:34 (info)     reloading component 'network'
07-01 14:30:34 (info)     =======rest api (api debugging)=======
07-01 14:30:34 (info)     received request of type GET for network/status
07-01 14:30:34 (info)     remote IP/port: 10.0.0.102/54571
07-01 14:30:34 (info)     network:getStatus
07-01 14:30:34 (debug)       result reloading component 'network' (cmd: '/etc/init.d/network reload'):

07-01 14:30:34 (info)     reloading component 'uhttpd'
07-01 14:30:35 (debug)       result reloading component 'uhttpd' (cmd: '/etc/init.d/uhttpd reload'):

07-01 14:30:36 (debug)     associated check 0/5
07-01 14:30:38 (debug)     associated check 1/5
07-01 14:30:40 (debug)     associated check 2/5
07-01 14:30:42 (debug)     associated check 3/5
07-01 14:30:44 (debug)     associated check 4/5
07-01 14:30:44 (info)     network:setStatus: -1 | Could not associate with network (incorrect password?)
07-01 14:30:44 (info)     failed to associate to wifi: werkplaats (Could not associate with network (incorrect password?))
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     received request of type GET for sketch/list
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54641
07-01 14:31:49 (error)     calling function 'list' in API module 'sketch' somehow failed ('/usr/share/lua/wifibox/rest/api/api_sketch.lua:52: cannot open /root/sketches: No such file or directory')
07-01 14:31:49 (debug)     Response:error (call to function 'sketch/list' failed)
07-01 14:31:49 (info)     received request of type GET for info/status
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54642
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     received request of type GET for printer/listall
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54641
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     received request of type GET for config/all
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54642
07-01 14:31:49 (info)     received request of type GET for update/status
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54641
07-01 14:31:49 (info)     received request of type GET for network/scan
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54643
07-01 14:31:49 (info)     start wifi scan
07-01 14:31:49 (debug)     Downloading file 'http://doodle3d.com/updates/images/wifibox-image.index'
07-01 14:31:49 (debug)     error: could not obtain available versions (could not download image index file (1: Generic error))
07-01 14:31:49 (debug)     Response:fail (could not download image index file (1: Generic error))
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     =======rest api (api debugging)=======
07-01 14:31:49 (info)     received request of type GET for network/status
07-01 14:31:49 (info)     remote IP/port: 192.168.5.2/54644
07-01 14:31:49 (info)     network:getStatus
07-01 14:31:51 (info)     wifi scan done
07-01 14:31:51 (debug)     getSubstitutedSsid unformattedSsid:'Doodle3D-%%MAC_ADDR_TAIL%%' baseApSsid:'nil' cachedApSsid:'nil
07-01 14:31:51 (debug)     getMacAddress
07-01 14:31:51 (debug)       macText: '10:fe:ed:4c:c2:8c
'
07-01 14:31:51 (debug)       macTail:'4CC28C
07-01 14:31:51 (debug)     getSubstitutedSsid unformattedSsid:'Doodle3D-%%MAC_ADDR_TAIL%%' baseApSsid:'Doodle3D-%%MAC_ADDR_TAIL%%' cachedApSsid:'Doodle3D-4CC28C
07-01 14:31:51 (debug)     getSubstitutedSsid unformattedSsid:'Doodle3D-%%MAC_ADDR_TAIL%%' baseApSsid:'Doodle3D-%%MAC_ADDR_TAIL%%' cachedApSsid:'Doodle3D-4CC28C

excerpt from logs:

07-01 14:30:31 (info)     netconfig:associateSsid: werkplaats, true
07-01 14:30:31 (info)     network:setStatus: 1 | Connecting...
07-01 14:30:31 (info)     start wifi scan
07-01 14:30:33 (info)     wifi scan done
07-01 14:30:44 (info)     network:setStatus: -1 | Could not associate with network (incorrect password?)
07-01 14:30:44 (info)     failed to associate to wifi: werkplaats (Could not associate with network (incorrect password?))

@arneboon
Copy link
Contributor Author

arneboon commented Jul 1, 2015

there is a constant M.CONNECTING_FAILED = -1
https://github.com/Doodle3D/doodle3d-firmware/blob/master/src/network/netconfig.lua#L25

but this never leads to creating a hotspot again. why not?

in the earlier hostmodule project such a fallback was implement in place such as the function M.setStatus(code,msg)
https://github.com/Doodle3D/doodle3d-firmware/blob/master/src/network/netconfig.lua#L436

pseudo:
if CONNECTING_FAILED then M.setupAccessPoint(ssid)

@arneboon
Copy link
Contributor Author

arneboon commented Jul 1, 2015

mind the timing issues... can not be or attempt to be client & accesspoint at same time

@peteruithoven peteruithoven added this to the 0.10.7 milestone Jul 1, 2015
@peteruithoven
Copy link
Member

I don't think we use these constants to check if something went wrong, it's main usage is communicating the status over the REST API. I think we mostly use the return value of functions to check if something went wrong.

@companje
Copy link
Member

companje commented Jul 1, 2015

I can confirm this issue also happens with version 0.10.5. When entering a wrong password the only way to regain access to the wifibox is by connecting a UTP cable.

@peteruithoven
Copy link
Member

Please, please think trough how this is going to work though. There is a big change that when you use our current "start a accesspoint" logic it will never try to connect to that WiFi network again. Because from then on the accesspoint config is the preferred (top) wireless config.

@companje
Copy link
Member

companje commented Jul 1, 2015

Is there some way to detect that it failed to connect to a network (ie wrong password?), if so we should delete that network from /etc/config/wireless. You don't need to 'start a accesspoint' because 'it' should do it automatically if that's the next interface in the configfile.

@peteruithoven
Copy link
Member

I don't think we could, not back then anyway. I think we check if it worked by checking ip address and whether the ssid is filled in.

@peteruithoven
Copy link
Member

Also see: Doodle3D/doodle3d-client#209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants