''' 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)
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)
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)