I am trying to get the GPRS module to connect to a remote TCP server. This should begin a two way data communication.
On the Tessel, I run the following commands in sequence:
AT+CGATT? // returns 1 if network is connected
AT+CIPSHUT=? // shut existing connections
AT+CIPSTATUS // should be IP INITIAL
AT+CIPMUX=0
AT+CGDCONT=1,"IP","epc.tmobile.com" // not always needed
AT+CSTT="epc.tmobile.com","","" // apn credentials for T-MOBILE
AT+CIICR // Start wireless
AT+CIFSR // test by getting the local IP address.
AT+CIPSTART= "TCP" , "http://174.129.240.180", "80" // IP and port of the server
AT+CIPSEND // wait for prompt then send data
// send data then to end call run...
AT+CIPCLOSE
AT+CIPSHUT
After running AT+CIPSTART
I get the response OK
and CONNECT OK
which seems to indicate a successful connection. However I don't see any signs the connection is actually valid. No logging on the server, no data received, none sent.
Could this be related to: https://github.com/tessel/runtime/pull/145
I've tried the following server code:
Http
var http = require('http');
var fs = require('fs');
var server = http.createServer(function(req, res) {
console.log(req);
var stream = fs.createReadStream(__dirname + '/data.txt');
stream.pipe(res);
});
server.listen(5000);
net
var net = require('net');
var server = net.createServer(function(socket) {
socket.write('Hello\r\n');
socket.write('This is your Tessel talking\r\n');
socket.write('I\'m opening a pipe with you...\r\n');
setTimeout(function() {
socket.write(new Date().toString());
}, 200);
//socket.pipe(socket); // this should send back any data we send it
socket.on('data', function(data) {
console.log('Received from local connection: ' + data);
socket.write('Hello\r\n');
});
socket.on('connect', function(data) {
console.log('Received from local connection: ' + data);
});
});
server.listen(5000);
Websockets
var WebSocketServer = require('ws').Server
, http = require('http')
, express = require('express')
, app = express();
app.use(express.static(__dirname + '/public'));
var server = http.createServer(app);
server.listen(5000);
var wss = new WebSocketServer({server: server});
wss.on('connection', function(ws) {
var id = setInterval(function() {
ws.send(JSON.stringify(process.memoryUsage()), function() {});
}, 100);
console.log('started client interval');
ws.on('close', function() {
console.log('stopping client interval');
clearInterval(id);
});
});