gursi26 commited on
Commit
a64da8a
·
1 Parent(s): d050ff7

pls work now

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -113,21 +113,22 @@ elif st.session_state.selected_command == "control/gripper":
113
 
114
  with st.form("mqtt_form"):
115
  if st.form_submit_button("Send Command"):
116
- client = create_paho_client()
117
- setup_paho_client(
118
- client,
119
- HIVEMQ_USERNAME,
120
- HIVEMQ_PASSWORD,
121
- HIVEMQ_HOST,
122
- PORT,
123
- DEVICE_ID
124
- )
 
125
 
126
  payload = {"command": st.session_state.selected_command, "args": args}
127
  st.markdown("### Payload")
128
  st.write(payload)
129
 
130
- response = publish_and_wait(client, DEVICE_ID, payload)
131
  st.markdown("### Response")
132
  if response is not None:
133
  if "image" in response:
 
113
 
114
  with st.form("mqtt_form"):
115
  if st.form_submit_button("Send Command"):
116
+ if "client" not in st.session_state:
117
+ st.session_state.client = create_paho_client()
118
+ setup_paho_client(
119
+ st.session_state.client,
120
+ HIVEMQ_USERNAME,
121
+ HIVEMQ_PASSWORD,
122
+ HIVEMQ_HOST,
123
+ PORT,
124
+ DEVICE_ID
125
+ )
126
 
127
  payload = {"command": st.session_state.selected_command, "args": args}
128
  st.markdown("### Payload")
129
  st.write(payload)
130
 
131
+ response = publish_and_wait(st.session_state.client, DEVICE_ID, payload)
132
  st.markdown("### Response")
133
  if response is not None:
134
  if "image" in response: