Skip to content

Commit

Permalink
change resin wifi connect state flow diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitguigal committed Jun 5, 2017
1 parent 53e7b16 commit e8ae4e2
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ ssids = []

error = (e) ->
console.log(e)
if retry
console.log('Retrying')
console.log('Clearing credentials')
manager.clearCredentials()
.then(run)
.catch(error)
else
console.log('Not retrying')
console.log('Exiting')
process.exit()
console.log('Retrying')
start_hotspot()

app.get '/ssids', (req, res) ->
res.json(ssids)
Expand All @@ -47,6 +39,15 @@ app.post '/connect', (req, res) ->
app.use (req, res) ->
res.redirect('/')


start_hotspot = ->
hotspot.stop(manager, device)
.then ->
wifiScan.scanAsync()
.then (results) ->
ssids = results
hotspot.start(manager, device)

run = ->
manager.isSetup()
.then (setup) ->
Expand All @@ -63,17 +64,10 @@ run = ->
.catch(error)
else
console.log('Credentials not found')
hotspot.stop(manager, device)
.then ->
wifiScan.scanAsync()
.then (results) ->
ssids = results
hotspot.start(manager, device)
.catch(error)
start_hotspot()

app.listen(80)

retry = true
clear = true
device = null
manager = null
Expand Down

0 comments on commit e8ae4e2

Please sign in to comment.