class coral.cloudiot.core.CloudIot(config_file, config_section='DEFAULT')

Manages a connection to Google Cloud IoT Core via MQTT, using a JWT for device authentication.

You must configure a connection by specifying a Clout IoT configuration file (.ini). Then you can use publish_message() to send an arbitrary message to your cloud project.

  • config_file (str) – Path to your Cloud IoT configuration file (.ini).
  • config_section (str) – The section name in the .ini file where the Cloud IoT Core config can be read. By default, it reads from the “[DEFAULT]” section.

Checks whether or not Clout Iot Core is enabled, as per the config file’s “Enabled” boolean.

Returns:True if Cloud Iot Core is enabled, False if it’s disabled.

Sends an arbitrary message to the Cloud Iot Core service.

Parameters:message (obj) – The message to send. It can be any message that’s serializable into a JSON message using json.dumps() (such as a dictionary or string).

Specifies functions to call upon various MQTT pub-sub messages.

Parameters:callbacks (dict) – A mapping of callback names from paho.mqtt.client callbacks to your own function names.