Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Karan Goel
481-SoundBrain
Commits
3cab1af9
Commit
3cab1af9
authored
Feb 09, 2015
by
Max-Ferdinand Suffel
Browse files
remove TesselSoundBrain
parent
7acaa4e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
TesselSoundBrain/client.js
deleted
100644 → 0
View file @
7acaa4e3
var
net
=
require
(
'
net
'
);
var
host
=
'
69.91.157.20
'
;
// Use tessel wifi -l in order to get the latest host IP.
var
port
=
6000
;
var
client
=
new
net
.
Socket
();
client
.
connect
(
'
6000
'
,
host
,
function
()
{
console
.
log
(
'
Connected to:
'
+
host
+
'
:
'
+
port
);
});
client
.
on
(
'
data
'
,
function
(
data
)
{
console
.
log
(
'
data:
'
+
data
);
});
client
.
on
(
'
close
'
,
function
()
{
console
.
log
(
'
Connection closed
'
);
});
\ No newline at end of file
TesselSoundBrain/package.json
deleted
100644 → 0
View file @
7acaa4e3
{
"name"
:
"TesselSoundBrain"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
}
TesselSoundBrain/server.js
deleted
100644 → 0
View file @
7acaa4e3
// TCP server stuff
var
net
=
require
(
'
net
'
);
var
server
;
var
sockets
=
{},
nextSocketId
=
0
;
// Wifi stuff
var
wifi
=
require
(
'
wifi-cc3000
'
);
var
network
=
'
University of Washington
'
;
var
pass
=
''
;
var
security
=
'
unsecured
'
;
var
timeouts
=
0
;
function
connect
(){
wifi
.
connect
({
security
:
security
,
ssid
:
network
,
password
:
pass
,
timeout
:
120
// 120 seconds
});
}
wifi
.
on
(
'
connect
'
,
function
(
data
){
console
.
log
(
"
Wifi connection established
"
,
data
);
if
(
data
.
ssid
)
{
server
=
net
.
createServer
();
server
.
listen
(
6000
);
console
.
log
(
'
Server listening on
'
+
server
.
address
().
address
+
'
:
'
+
server
.
address
().
port
);
server
.
on
(
'
connection
'
,
function
(
sock
)
{
console
.
log
(
'
Connected:
'
+
sock
.
remoteAddress
+
'
:
'
+
sock
.
remotePort
);
sock
.
on
(
'
data
'
,
function
(
data
)
{
console
.
log
(
'
Data
'
+
sock
.
remoteAddress
+
'
:
'
+
data
);
});
sock
.
on
(
'
close
'
,
function
(
data
)
{
console
.
log
(
'
Closed:
'
+
sock
.
remoteAddress
+
'
:
'
+
sock
.
remotePort
);
});
});
}
});
wifi
.
on
(
'
disconnect
'
,
function
(
data
)
{
console
.
log
(
"
Wifi connection destroyed
"
,
data
);
if
(
server
)
server
.
close
();
powerCycle
();
})
wifi
.
on
(
'
timeout
'
,
function
(
err
){
// tried to connect but couldn't, retry
console
.
log
(
"
Wifi connection timeout, try to reconnect
"
);
if
(
server
)
server
.
close
();
timeouts
++
;
if
(
timeouts
>
2
)
{
// reset the wifi chip if we've timed out too many times
powerCycle
();
}
else
{
// try to reconnect
connect
();
}
});
wifi
.
on
(
'
error
'
,
function
(
err
){
// one of the following happened
// 1. tried to disconnect while not connected
// 2. tried to disconnect while in the middle of trying to connect
// 3. tried to initialize a connection without first waiting for a timeout or a disconnect
console
.
log
(
"
Wifi connection error
"
,
err
);
if
(
server
)
server
.
close
();
});
// reset the wifi chip progammatically
function
powerCycle
(){
// when the wifi chip resets, it will automatically try to reconnect
// to the last saved network
wifi
.
reset
(
function
(){
timeouts
=
0
;
// reset timeouts
console
.
log
(
"
Wifi power cycling done
"
);
// give it some time to auto reconnect
setTimeout
(
function
(){
if
(
!
wifi
.
isConnected
())
{
// try to reconnect
connect
();
}
},
20
*
1000
);
// 20 second wait
})
}
// Connect to Wifi and start server.
connect
();
// server.on('connection', function (socket) {
// // Add a newly connected socket
// var socketId = nextSocketId++;
// sockets[socketId] = socket;
// console.log('socket', socketId, 'opened');
// // Remove the socket when it closes
// socket.on('close', function () {
// console.log('socket', socketId, 'closed');
// delete sockets[socketId];
// });
// // Extend socket lifetime for demo purposes
// socket.setTimeout(4000);
// });
// // Count down from 10 seconds
// (function countDown (counter) {
// console.log(counter);
// if (counter > 0)
// return setTimeout(countDown, 1000, counter - 1);
// // Close the server
// server.close(function () { console.log('Server closed!'); });
// // Destroy all open sockets
// for (var socketId in sockets) {
// console.log('socket', socketId, 'destroyed');
// sockets[socketId].destroy();
// }
// })(10);
\ No newline at end of file
TesselSoundBrain/vs1053.pdf
deleted
100644 → 0
View file @
7acaa4e3
File deleted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment