Skip to content

Instantly share code, notes, and snippets.

View rexstjohn's full-sized avatar

Rex St. John rexstjohn

View GitHub Profile
/*
Basic MQTT example with Authentication
How to send MQTT data to IBM Bluemix from Intel Edison via Arduino.
by Rex St. John
*/
#include <SPI.h>
#include <WiFi.h>
app = require('http').createServer(handler)
io = require('socket.io')(app)
fs = require('fs')
handler = (req, res) ->
fs.readFile __dirname + '/index.html', (err, data) ->
if err
res.writeHead 500
return res.end('Error loading index.html')
res.writeHead 200
@rexstjohn
rexstjohn / gist:dd1991aa149b1fb6f85d
Created December 7, 2014 04:40
TCP socket to CAN Gateway
var net = require('net');
var HOST = '158.199.141.247';
var PORT = 222;
var client = new net.Socket();
client.connect(PORT, HOST, function() {
console.log('CONNECTED TO: ' + HOST + ':' + PORT);
// Write a message to the socket as soon as the client is connected, the server will receive it as message from the client
@rexstjohn
rexstjohn / gist:b996ffba75f774ba335b
Created December 6, 2014 22:22
Share multiple Bluetooth Data sources from CAN Gateway ECU
/*********************************************************************/
/* Copyright (c) 2014 TOYOTA MOTOR CORPORATION. All rights reserved. */
/*********************************************************************/
package com.example.sample;
import java.nio.ByteBuffer;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;