"""Returns a random string of length string_length."""
random=str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())+str(uuid.uuid4())# Convert UUID format to a Python string.
random=random.upper()# Make all characters uppercase.
random=random.replace("-","")# Remove the UUID '-'.
returnrandom[0:string_length]# Return the random string.
os.system("echo heartbeat | sudo tee /sys/class/leds/led0/trigger")
defbyteify(input):
ifisinstance(input,dict):
return{byteify(key):byteify(value)
forkey,valueininput.iteritems()}
elifisinstance(input,list):
return[byteify(element)forelementininput]
elifisinstance(input,unicode):
returninput.encode('utf-8')
else:
returninput
frompocsagimportencodeTXBatch
inputQueue=[]
txQueue=[]
defbatchFinal():
globalt
globalinputQueue
globaltxQueue
#print(" [x] Batch Final")
txQueue=inputQueue
inputQueue=[]
#print(txQueue)
iflen(txQueue)>0:
os.system("echo timer | sudo tee /sys/class/leds/led0/trigger")
data=encodeTXBatch(txQueue,repeatNum=2)
rfmModule.sendBuffer(data)
os.system("echo heartbeat | sudo tee /sys/class/leds/led0/trigger")