5.2.1.2. pyiot/iot

This module does the actual job of subscribing and publishing to MQTT topics, use GET and POST method to transfer data using HTTP protocol on the request of Action Server.

pyiot.iot.http_post(spread_sheet_id, parameters)[source]

This function is called to push data to google spreadsheet using HTTP protocol.

Parameters:
  • spread_sheet_id (str) – Google Spreadsheet ID
  • parameters (str, int) – Parameters to push
Returns:

Success flag

Return type:

bool

pyiot.iot.mqtt_publish(arg_broker_url, arg_broker_port, arg_mqtt_topic, arg_mqtt_message, arg_mqtt_qos)[source]

This function is called in new thread to publish data to a MQTT topic.

Parameters:
  • arg_broker_url (str) – Broker URL
  • arg_broker_port (int) – Broker Port
  • arg_mqtt_topic (str) – MQTT topic name
  • arg_mqtt_message (str, int) – Message to publish
  • arg_mqtt_qos (int) – Quality of Service
Returns:

Success flag

Return type:

bool

pyiot.iot.mqtt_subscribe_thread_start(arg_callback_func, arg_broker_url, arg_broker_port, arg_mqtt_topic, arg_mqtt_qos)[source]

This function is called in a new thread to subscribe to a MQTT topic.

Parameters:
  • arg_callback_func (function) – Callback function
  • arg_broker_url (str) – Broker URL
  • arg_broker_port (int) – Broker Port
  • arg_mqtt_topic (str) – MQTT topic to subscribe
  • arg_mqtt_qos (int) – Quality of Service
Returns:

Success flag

Return type:

bool