-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenumerate_TinkerForge.py
More file actions
40 lines (29 loc) · 1.14 KB
/
Copy pathenumerate_TinkerForge.py
File metadata and controls
40 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tinkerforge.ip_connection import IPConnection
HOST = "localhost"
PORT = 4223
# Print incoming enumeration
def cb_enumerate(uid, connected_uid, position, hardware_version, firmware_version,
device_identifier, enumeration_type):
print("UID: " + uid)
print("Enumeration Type: " + str(enumeration_type))
if enumeration_type == IPConnection.ENUMERATION_TYPE_DISCONNECTED:
print("disconnected?")
return
print("Connected UID: " + connected_uid)
print("Position: " + position)
print("Hardware Version: " + str(hardware_version))
print("Firmware Version: " + str(firmware_version))
print("Device Identifier: " + str(device_identifier))
print("")
if __name__ == "__main__":
# Create connection and connect to brickd
ipcon = IPConnection()
ipcon.connect(HOST, PORT)
# Register Enumerate Callback
ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE, cb_enumerate)
# Trigger Enumerate
ipcon.enumerate()
input("Press key to exit\n") # Use raw_input() in Python 2
ipcon.disconnect()