HAVE MOVED THE FILES TO a repo...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gist demonstrates a simple method to create a WebSockets proxy for a MQTT broker. | |
# I use this method to provide a WebSockets interface for the Mosquitto MQTT broker. | |
# This lets my browser based MQTT applications to access my MQTT broker. | |
# I consider this approach simpler than the common alternative which is to run lighttpd | |
# with the mod_websocket addon which can be complex to setup. | |
# | |
# Dependencies are Python, Twisted and Autobahn. | |
# | |
# This example sets up a WebSockets server listening on localhost:9000. Messages received from | |
# WebSocket clients are forwarded to the MQTT broker using the endpointforward plugin provided |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ouimeaux.environment import Environment | |
def on_switch(switch): | |
print ('******** Switch found:', switch.name) | |
def on_change(value): | |
print('******** light has changed state and has been switched!') | |
env = Environment(switch_callback=on_switch, with_cache=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import os, shutil | |
import subprocess | |
import os.path | |
from datetime import datetime | |
######################## Functions ######################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def distance_on_unit_sphere(lat1, long1, lat2, long2): | |
# by Matthew Bordignon @bordignon Oct 2013 | |
# | |
# handy example for finding distance between two sets of co-oridinates | |
# modified from http://www.johndcook.com/python_longitude_latitude.html | |
# Convert latitude and longitude to | |
# spherical coordinates in radians. | |
degrees_to_radians = math.pi/180.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&sensor=false"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> | |
<script src="mqttws31.js" type="text/javascript"></script> | |
<TITLE>MQTTitude - find my family & friends</title> | |
<style type="text/css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Testing Temp Gauge</title> | |
</head> | |
<body onload="init();"> | |
<canvas id=gaugeCanvas width=200 height=200>No canvas in your browser...sorry...</canvas> | |
</body> | |
<script type="text/javascript" src="mosquitto-1.1.js"></script> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | |
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/tween-min.js></script> | |
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/steelseries-min.js></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import mosquitto | |
import ssl | |
def on_connect(mosq, userdata, rc): | |
print("Connect: rc: "+str(rc)) | |
def on_message(mosq, userdata, msg): | |
print "%s (qos=%s, r=%s) %s" % (msg.topic, str(msg.qos), msg.retain, str(msg.payload)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn = mysql_connect("thebeast.localdomain", "root", "") or die(mysql_error()); | |
mysql_select_db("mqtt") or die(mysql_error()); | |
?> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> | |
<title>Google Maps</title> | |
<style type="text/css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# September 2013 | |
# by Matthew Bordignon, @bordignon on Twitter | |
# | |
# Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the topic into a mysql database | |
# This is designed for the http://mqttitude.org/ project backend | |
# | |
import MySQLdb | |
import mosquitto |