Skip to content

Instantly share code, notes, and snippets.

View tomconte's full-sized avatar

Thomas Conté tomconte

View GitHub Profile
@tomconte
tomconte / IoTHubClient.php
Last active March 9, 2016 16:53
Simple Azure IoT Hub client example in PHP using the HTTP transport. Use the Device Explorer or the iothubclient CLI to generate the Shared Access Signature (SAS) token.
<?php
/**
* Created by PhpStorm.
* User: tconte
* Date: 08/03/2016
* Time: 17:44
*/
namespace tconte\AzureIoTHub;
@tomconte
tomconte / iothub_send.py
Created February 11, 2016 14:29
This is a quick sample showing how to send data to Azure IoT Hub using the Proton bindings for Python. Please note you need to use our fork of Proton with an additional patch to fix the URL parsing; see https://github.com/tomconte/qpid-proton/tree/0.9-IoTClient
#!/usr/bin/python
# Send messages to an Azure IoT Hub using the Apache Qpid Proton AMQP library.
import urllib
from proton import *
# IoT Hub address & credentials
# The Device ID
@tomconte
tomconte / event_hubs_http_proxy.js
Created July 8, 2015 13:56
This is a simple Node.JS HTTP proxy you can use to forward data to Azure Event Hubs.
var http = require('http');
var https = require('https');
var crypto = require('crypto');
// Event Hubs parameters
var namespace = 'demohub';
var hubname ='hub1';
var devicename = 'device-01';
// Shared access key (from Event Hub configuration)
@tomconte
tomconte / event_hubs_receive_many.py
Created March 31, 2015 13:46
Based on the Proton AMQP Python examples (https://qpid.apache.org/releases/qpid-proton-0.8/messenger/python/examples/index.html), here is a script that will listen on all 16 partitions for a single Event Hub and print all messages. You need to have the "async.py" script from the examples in the same directory.
#!/usr/bin/python
# Receive messages from an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
from async import *
# Event Hub address & credentials
# amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname>/ConsumerGroup/<consumergroup>/Partitions/<partition>
# You can find <keyname> and <key> in your Service Bus connection information
@tomconte
tomconte / HueSwitchButton.ino
Created December 14, 2014 11:44
This little sketch allows to turn Hue lamps on or off using a push button.
#include <Bridge.h>
#include <Console.h>
#include <FileIO.h>
#include <HttpClient.h>
#include <Mailbox.h>
#include <Process.h>
#include <YunClient.h>
#include <YunServer.h>
/*
@tomconte
tomconte / event_hubs_receive.py
Created December 6, 2014 10:44
Receive messages from an Azure Event Hub using the Apache Qpid Proton AMQP library. Nota bene: in order to receive all messages, you should really subscribe to all your Event Hub partitions. This example shows how to read from a single partition.
#!/usr/bin/python
# Receive messages from an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
import re
import uuid
import serial
from proton import *
@tomconte
tomconte / event_hubs_send.py
Last active February 15, 2018 08:54
Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
#!/usr/bin/python
# Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
from proton import *
# Event Hub address & credentials
# amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname>
#!/usr/bin/python
import sys
import commands
import re
import uuid
import serial
from proton import *
# Device ID
@tomconte
tomconte / tessel_upload_camera_picture.js
Created September 24, 2014 15:19
This Tessel script will take a picture and upload it to Azure Blob Storage. You will first need to generate a Shared Access Signature: http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/
var tessel = require('tessel');
var https = require('https');
// Upload parameters
var blob_host = 'tconeu.blob.core.windows.net';
var blob_container = 'tessel-uploads';
// Use any tool to generate a Shared Access Key e.g. Azure Management Studio
var blob_sas = '?sr=c&sv=2014-02-14&si=tessel&sig=xxxxRv%2xxxxUTd8xxxxMKc0xxxxi%2Fxxxxw6VsxxxxGjdJxxxx';
@tomconte
tomconte / upload_azure_blob_sas.js
Created September 24, 2014 08:13
Upload a Blob to Azure Storage using Shared Access Signatures (SAS) in Node.JS
var fs = require('fs');
var https = require('https');
var blob_host = 'tconeu.blob.core.windows.net';
var blob_container = 'tessel-uploads';
// Use any tool to generate a Shared Access Key e.g. Azure Management Studio
var blob_sas = '?sr=c&sv=2014-02-14&si=tessel&sig=xxxxRv%2xxxxUTd8xxxxMKc0xxxxi%2Fxxxxw6VsxxxxGjdJxxxx';
var blob_name = 'test.jpg';