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

I60 Connected Android to server #74

Merged
merged 31 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
02e0ed7
Removed firebase folder
Feb 1, 2019
1cb992e
Removed firebase functions deployment from travis.yaml
oktay-sen Feb 2, 2019
a8df289
Random IntelliJ changes
oktay-sen Feb 2, 2019
aa62dcb
Made initial hello world server
oktay-sen Feb 2, 2019
342300e
Added more packages
oktay-sen Feb 2, 2019
b843945
Minor change to README
oktay-sen Feb 2, 2019
2bf2d17
Minor change to README
oktay-sen Feb 2, 2019
ffc9114
Basic implementation of a CRUD server with mongodb
oktay-sen Feb 2, 2019
9e34bf8
Added Bonjour Publisher and Client
freddiejbawden Feb 2, 2019
95129ba
added bonjour
Feb 2, 2019
80e9d1a
Robot comms teset
Feb 3, 2019
dd4cc58
WIP makefile
oktay-sen Feb 3, 2019
ac21271
Merge branch 'beta' into i58
oktay-sen Feb 3, 2019
0f8768e
Re-added package-lock.json
oktay-sen Feb 3, 2019
420cf07
Robot turns on when button pressed
freddiejbawden Feb 4, 2019
2ef45f9
Merge branch 'i58' of https://github.com/Assis10t/assis10t into i58
freddiejbawden Feb 4, 2019
98a4e95
Android can now find server via zeroconf
oktay-sen Feb 4, 2019
f16ada6
Added test mode for when disconnected from robot
Feb 4, 2019
f6e88f2
Refactored ServerConnection
oktay-sen Feb 4, 2019
cc9648f
Merge remote-tracking branch 'origin' into i60
oktay-sen Feb 4, 2019
b8d7aa7
Merge remote branch into i58
Feb 4, 2019
d4bb2bd
Updated server name in android
Feb 4, 2019
12a7f19
Added turn off on
Feb 4, 2019
60f7b5b
Fixed minor things
oktay-sen Feb 4, 2019
43e5746
App can display list of items
oktay-sen Feb 4, 2019
cee62ba
Merge beta into i60
oktay-sen Feb 4, 2019
908332f
Re-added addItem and getItems
oktay-sen Feb 4, 2019
7b2972f
Fixed app not connecting to server
oktay-sen Feb 4, 2019
66c16e1
Added ability to refresh list of items
oktay-sen Feb 4, 2019
ddb6bb6
Implemented adding order on android
oktay-sen Feb 4, 2019
f3a4327
Adding order now removes the items in it from the database
oktay-sen Feb 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added turn off on
  • Loading branch information
Frederick Bawden authored and Frederick Bawden committed Feb 4, 2019
commit 12a7f1981c440f1ed2d7aa06e2991d2f2c458d19
19 changes: 17 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ app.get('/jobs', (req, res, next) => {
.catch(next)
})

app.get('/turnon', (req,res,next) => {
model
.turnOn()
.then(count => res.json({success: true, count}))
.catch(next)
})
app.get('/turnoff', (req,res,next) => {
model
.turnOff()
.then(off => res.json({success: true, off}))
.catch(next)
})


//Logs all responses.
app.use((req, res, next) => {
console.log(`${req.ip}: ${req.method} ${req.originalUrl} response: ${res.body}`)
Expand All @@ -85,6 +99,7 @@ app.use((err, req, res, next) => {
})

app.listen(PORT, () => {
console.log(`Listening on port ${PORT}.`)
bonjour.publish({ name: 'assis10t', type: 'http', host: utils.getIp(), port: PORT })
console.log(`Listening on port ${PORT}.`)

})
bonjour.publish({ name: 'assis10t', type: 'http', port: PORT })
25 changes: 25 additions & 0 deletions server/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ const factory = db => ({
.toArray((err, docs) => {
err ? rej(err) : res(docs)
})
}),
turnOn: () =>
new Promise((res,rej) => {
db()
.collection('bob_movement')
.update({"_id":"movement"}, {"moving":true}, (err, count_modified) => {
err ? rej(err) : res(count_modified)
})
}),
turnOff: () =>
new Promise((res,rej) => {
db()
.collection('bob_movement')
.update({"_id":"movement"}, {"moving":false}, (err, count_modified) => {
err ? rej(err) : res(count_modified)
})
}),
setUpOn: () =>
new Promise((res,rej) => {
db()
.collection('bob_movement')
.insertOne({"_id":"movement",'moving':false}, (err, move) => {
err ? rej(err) : res(move)
})

})
})

Expand Down