Last active
February 15, 2018 08:54
-
-
Save tomconte/c94af7efeccb2a274b82 to your computer and use it in GitHub Desktop.
Revisions
-
tomconte revised this gist
May 12, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ # Event Hub address & credentials # amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname> # You can find <keyname> and <key> in your Service Bus connection information # <key> needs to be URL-encoded # <namespace> is your SB top-level namespace # <eventhubname> is the name of your Event Hub @@ -17,12 +18,10 @@ # Create Proton objects messenger = Messenger() # Create AMQP message message = Message() message.body = sys.argv[1] message.address = address messenger.put(message) -
tomconte revised this gist
May 12, 2015 . 1 changed file with 8 additions and 28 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,46 +4,26 @@ import sys import commands from proton import * # Event Hub address & credentials # amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname> # You can find <keyname> and <key> in your Service Bus connection information # <namespace> is your SB top-level namespace # <eventhubname> is the name of your Event Hub address = "amqps://send:[email protected]/yun"; # Create Proton objects messenger = Messenger() temp = 'T:25_L:500' # Create AMQP message message = Message() message.body = unicode(temp) message.address = address messenger.put(message) messenger.send() -
tomconte created this gist
Dec 6, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/usr/bin/python # Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library. import sys import commands import re import uuid import serial from proton import * # Device ID id = uuid.getnode() # Event Hub address & credentials # amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname> # You can find <keyname> and <key> in your Service Bus connection information # <namespace> is your SB top-level namespace # <eventhubname> is the name of your Event Hub address = "amqps://RootManageSharedAccessKey:92UHxxxx1noKxxxxOkaexxxxyTxoxxxxCePcxxxxIsI=@tomhub-ns.servicebus.windows.net/raspberry" # Open serial port #ser = serial.Serial('/dev/ttyACM0', 9600) # Create Proton objects messenger = Messenger() while True: # Read values from Arduino in the form K1:V1_K2:V2_... # temp = ser.readline().rstrip('\r\n') temp = 'T:25_L:500' print temp # Create AMQP message message = Message() # Initialize properties message.properties = dict() message.properties[symbol("DeviceId")] = symbol(id) # Map string to list, symbolize, create dict and merge pairs=map(lambda x:x.split(':'), temp.split('_')) symbols = map(lambda x:(symbol(x[0]),int(x[1])), pairs) message.properties.update(dict(symbols)) message.address = address messenger.put(message) messenger.send()