Exemplo n.º 1
0
from byteport.clients import ByteportHttpClient

client = ByteportHttpClient('test', 'd8a26587463268f88fea6aec', 'barDev1')

# NOTE: This will block the current thread!
client.poll_directory_and_store_upon_content_change('/home/iot_user/measured_values/', 'barDev1', poll_interval=10)
Exemplo n.º 2
0
  print("Failed creating table: {}".format(err))
  sys.exit(-1)


# SensorList [SensorName, FileName, Temperature value (set default)]
SensorList = ['OutTemp',     '/mnt/1wire/28.571AB8010000/temperature', -99,
              'InTemp',      '/mnt/1wire/28.7EF3FE000000/temperature', -99]


print(" -----------------------------------------------------")
print("  %s  " % ("Defined sensors"))
print("  %-8s  %s" % ( SensorList[0], SensorList[1]))
print("  %-8s  %s" % ( SensorList[3], SensorList[4]))
print(" -----------------------------------------------------")
print
client = ByteportHttpClient(NAMESPACE, API_KEY, uid, initial_heartbeat=False)

# print header for results table
print("  Date                     |   Sensor  |   Temperature")
print(" -----------------------------------------------------")
OutTemp = -99
InTemp  = -99

#while True:
now = time.strftime("%c") #Read time for sensor reading

# Setup filenames etc.
OutSensor = SensorList[0]
OutFileName = SensorList[1]
InSensor = SensorList[3]
InFileName = SensorList[4]
Exemplo n.º 3
0
    print("Failed creating table: {}".format(err))
    sys.exit(-1)

# SensorList [SensorName, FileName, Temperature value (set default)]
SensorList = [
    'OutTemp', '/mnt/1wire/28.571AB8010000/temperature', -99, 'InTemp',
    '/mnt/1wire/28.7EF3FE000000/temperature', -99
]

print(" -----------------------------------------------------")
print("  %s  " % ("Defined sensors"))
print("  %-8s  %s" % (SensorList[0], SensorList[1]))
print("  %-8s  %s" % (SensorList[3], SensorList[4]))
print(" -----------------------------------------------------")
print
client = ByteportHttpClient(NAMESPACE, API_KEY, uid, initial_heartbeat=False)

# print header for results table
print("  Date                     |   Sensor  |   Temperature")
print(" -----------------------------------------------------")
OutTemp = -99
InTemp = -99

#while True:
now = time.strftime("%c")  #Read time for sensor reading

# Setup filenames etc.
OutSensor = SensorList[0]
OutFileName = SensorList[1]
InSensor = SensorList[3]
InFileName = SensorList[4]
Exemplo n.º 4
0
'''
def getHwAddr(ifname):
		s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
		info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15]))
		return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]


'''
		Python main method, execution starts here:
'''
if __name__ == '__main__':

		try:
				current_mac = getHwAddr('wlan0')
		except Exception:
				current_mac = getHwAddr('eth0')
		else:
				current_mac = None	# <== whatever, just so the compare below fails and returns a "Sim" 
				
		print(current_mac)		
		if current_mac == SIM_HW_ADDR:
				uid = 'JosefinSim'
				print ("Josefin Sim set")
		else:
				uid = 'JosefinShip'
				print ("Josefin SHIP set")
		client = ByteportHttpClient(NAMESPACE, API_KEY, uid, initial_heartbeat=False)

		# NOTE: This will block the current thread!
		client.poll_directory_and_store_upon_content_change('/tmp/ByteportReports', uid, poll_interval=POLL_INTERVAL)
Exemplo n.º 5
0
    return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]


'''
		Python main method, execution starts here:
'''
if __name__ == '__main__':

    try:
        current_mac = getHwAddr('wlan0')
    except Exception:
        current_mac = getHwAddr('eth0')
    else:
        current_mac = None  # <== whatever, just so the compare below fails and returns a "Sim"

    print(current_mac)
    if current_mac == SIM_HW_ADDR:
        uid = 'JosefinSim'
        print("Josefin Sim set")
    else:
        uid = 'JosefinShip'
        print("Josefin SHIP set")
    client = ByteportHttpClient(NAMESPACE,
                                API_KEY,
                                uid,
                                initial_heartbeat=False)

    # NOTE: This will block the current thread!
    client.poll_directory_and_store_upon_content_change(
        '/tmp/ByteportReports', uid, poll_interval=POLL_INTERVAL)