Skip to content

Commit 377efd7

Browse files
committed
Fixed broker_connect.py issue
1 parent 298901d commit 377efd7

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

broker_connect.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self):
99
self.client = None
1010

1111
def connect(self):
12+
print("connect() was called from broker_connect.py")
1213
"""Establish persistent connection with message broker."""
1314
self.client = mqtt.Client()
1415
self.client.username_pw_set(

broker_functions.py

+60-1
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,34 @@ def shutdown(self):
143143
self.broker_connect.publish(shutdown_message)
144144
return print("Triggered device shutdown.")
145145

146-
# calibrate_camera() --> sequence (broker message)
146+
def calibrate_camera(self):
147+
calibrate_message = {
148+
**RPC_REQUEST,
149+
"args": {
150+
"label": "3fcd2d32-302b-46c9-9448-b4f30c3a9bb1",
151+
"priority": 600
152+
},
153+
"body": {
154+
"kind": "execute_script",
155+
"args": {
156+
"label": "camera-calibration"
157+
},
158+
"body": {
159+
"kind": "pair",
160+
"args": {
161+
"label": "CAMERA_CALIBRATION_easy_calibration",
162+
"value": "\"TRUE\""
163+
}
164+
}
165+
}
166+
}
167+
168+
self.broker_connect.publish(calibrate_message)
169+
# return ...
170+
147171
# photo_grid() --> sequence (broker message)
148172

173+
149174
def control_servo(self, pin, angle):
150175
if angle < 0 or angle > 180:
151176
return print("ERROR: Servo angle constrained to 0-180 degrees.")
@@ -348,9 +373,43 @@ def axis_length(self, axis='all'):
348373
# mark_as() --> sequence (broker message)
349374

350375
# verify_tool() --> check
376+
351377
# mount_tool() --> check
352378
# dismount_tool() --> check
353379

380+
def mount_tool(self, x, y, z):
381+
mount_tool_message = {
382+
**RPC_REQUEST,
383+
"args": {
384+
"label": "6a6b10a6-46a8-4b97-8b66-c55021c02bbd",
385+
"priority": 600
386+
},
387+
"body": [
388+
{
389+
"kind": "execute",
390+
"args": {
391+
"sequence_id": 24350
392+
},
393+
"body": [
394+
{
395+
"kind": "parameter_application",
396+
"args": {
397+
"label": "Tool",
398+
"data_value": {
399+
"kind": "coordinate",
400+
"args": {
401+
"x": 0,
402+
"y": 40,
403+
"z": 0
404+
}
405+
}
406+
}
407+
}
408+
]
409+
}
410+
]
411+
}
412+
354413
# water() --> check
355414
# dispense() --> check
356415

main.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ def get_token(self, email, password, server="https://my.farm.bot"):
1717
self.api.api_connect.token = token_data
1818

1919
self.broker.token = token_data
20-
self.broker.broker_connect = token_data
20+
self.broker.broker_connect.token = token_data
2121

2222
return token_data
2323

2424
def get_info(self, endpoint, id=None):
2525
return self.api.get_info(endpoint, id)
2626

27+
def set_info(self, endpoint, field, value, id=None):
28+
return self.api.set_info(endpoint, field, value, id)
29+
2730
def connect(self):
2831
self.broker.broker_connect.connect()
29-
return print("Connected to message broker.")

0 commit comments

Comments
 (0)