From 18aad8a5ba84adfa0030531f2b6dabd57dee1b41 Mon Sep 17 00:00:00 2001 From: Cuddly Cheetah Date: Wed, 23 Oct 2019 03:53:00 +0200 Subject: [PATCH] fixed --- main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/main.py b/main.py index 04d57d3..8160de9 100644 --- a/main.py +++ b/main.py @@ -5,8 +5,15 @@ from RFM69_POCSAGregisters import * import datetime import time from ConfigParser import SafeConfigParser +import pika config = SafeConfigParser() +config.read('config.ini') +config.add_section('main') +config.set('main', 'amqpURI', 'amqp://user:pw@host:port') + +with open('config.ini', 'w') as f: + config.write(f) rfmModule = RFM69_POCSAG.RFM69_POCSAG(RF69_433MHZ, pocsagBaudRate=1200, isRFM69HW = True) #rfmModule.shutdown() @@ -29,6 +36,29 @@ def my_random_string(string_length=10): random = random.replace("-","") # Remove the UUID '-'. return random[0:string_length] # Return the random string. +def msgCallback(ch, method, properties, body): + print(" [x] Received %r" % body) + +while True: + try: + connection = pika.BlockingConnection(pika.ConnectionParameters( config.get('main', 'amqpURI') )) + channel = connection.channel() + queue = channel.queue_declare(queue='input') + queue_ttl60 = channel.queue_declare(queue='input_ttl60') + channel.basic_consume(queue='input', + auto_ack=True, + on_message_callback=msgCallback) + channel.basic_consume(queue='input_ttl60', + auto_ack=True, + on_message_callback=msgCallback) + print(' [*] Waiting for messages. To exit press CTRL+C') + channel.start_consuming() + + except Exception: + time.sleep(.5) + pass + + from pocsag import encodeTXBatch msgs = [] """