Google iot core connection status

google iot core tutorial
google iot devices
google iot project
google iot core pricing
google cloud iot documentation
iot core google docs
google cloud iot arduino
iot core pubsub

I am using Google IOT core with mongoose os. I wanted to update device connection status to firestore. But i am unable to find event which reports mqtt connection status to pub/sub like when device disconnects or reconnect i.e if device is offline or not.

I am stuck on this problem for days.Any help will be appreciated

Update

As @devunwired mentioned in this response it is now possible to monitor Stackdriver logs for disconnect events. You must have at a minimum enabled INFO level logging on your project in IoT Core > Registries > [your registry] > Edit Registry > Select "Info" log level > Click save.

Original Response

There are a few values you can look at that are tracked in device configuration metadata that you could use to know when a device last was online:

  1. Last Configuration Send time - sent anytime your device connects / configuration is posted
  2. Last Event Time - Last time an event was sent from the device
  3. Last State Time - Last time state was sent from the device
  4. Last Heartbeat time - Last time MQTT heartbeat was sent

To get you started, here is an example using API explorer that you can fill-in with your project ID, region, registry, and device to query for a specific device's metadata.

For 1...3 you have control over these through device manager and by publishing data. MQTT heartbeat is updated if your device sends an MQTT_PINGREQ message during the "ping period" without other messages getting sent.

At any rate, you could use any of these update time values to see the last time a device was online / functioning. You could query the states of your devices after listing the devices in a registry and could update a Firebase RTDB periodically if that's how you want to report (e.g. using AppEngine TaskQueue). Note that you also just can get these "last connected" values from the Google Cloud Console.

It was said before but we don't have an event for disconnect, just configuration ack, which generally is the connection event. If you want to share state between a device and the device manager, use state messages.

Troubleshooting | Cloud IoT Core Documentation, If your device has trouble establishing a TLS connection to the Cloud IoT Core Use the gcloud command below to review the most recent error status and� I am using Google IOT core with mongoose os. I wanted to update device connection status to firestore. But i am unable to find event which reports mqtt connection status to pub/sub like when device disconnects or reconnect i.e if device is offline or not.

Unfortunately, there's no built in way to do this right now as there aren't events on this state.

However, you could implement a hack by sending a message on connect/disconnect from the device that you have a Cloud Function subscribed to the Pub/Sub topic listening for. It's not perfect as it would fail in the case where the device disconnected unexpectedly.

Google iot core connection status, Last Configuration Send time - sent anytime your device connects / configuration is posted. Last Event Time - Last time an event was sent from the device. Last State Time - Last time state was sent from the device. Last Heartbeat time - Last time MQTT heartbeat was sent. Cloud IoT Core runs on Google’s serverless infrastructure, which scales automatically in response to real-time changes and adheres to stringent industry-standard security protocols that protect your business data.

There currently is no way to do this, that i've been able to find (a year later after this original post). I posted a question here on SO regarding this as well, with more details and link to example code I had to use for handling this: Google Core IoT Device Offline Event or Connection Status

Google iot core connection status, Update. As @devunwired mentioned in this response it is now possible to monitor Stackdriver logs for disconnect events. You must have at a� Google’s own services, such as Google Search and YouTube, run on the GCP, but end users can also book the cloud services. For the Internet of Things (IoT) area, the platform offers the “Cloud IoT Core” services, which provide the functionalities to connect large quantities of devices. The connection is possible via an integrated MQTT broker.

The AWS IoT platform publishes messages on a special MQTT topic (prefixed with $aws) when your device connects/disconnects. You can easily use these to monitor these events - however, you should be aware that the MQTT protocol is designed to be robust to a poor networking conditions and the broker on the AWS side probably doesn't think it's a bit deal to disconnect a client. The broker expects that the client will just reconnect and queue messages for a moment during that process (which can be a big deal on a microcontroller).

All that being said, the AWS topics you would watch are:

$aws/events/presence/connected/{clientId}

and

$aws/events/presence/disconnected/{clientId}

and the documentation for these (and other) lifecycle events are located: https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html

A Tour of Cloud IoT Core - Codelabs, Cloud IoT Core is a fully managed service that allows you to easily and securely connect, manage, and ingest data from millions of globally dispersed devices. In the current release of Cloud IoT Core, the available regions are us-central1, europe-west1, and asia-east1. The device code defaults to --cloud_region=us-central1. If you run the server code and

Google's Internet of Things Solutions, Cloud IoT Core is a fully managed service that allows you to easily and securely connect, manage, and ingest data from millions of globally dispersed devices. Google Cloud Internet of Things (IoT) Core is a fully managed service for securely connecting and managing IoT devices, from a few to millions. Ingest data from connected devices and build rich applications that integrate with the other big data services of Google Cloud Platform.

[PDF] Connecting the IDK to the Google Cloud IoT Core AND9887/D, Sensor data are transmitted over secure connection to [Ref 2] Google Cloud IoT Core documentation: https://cloud.google.com/iot/docs/how−tos/devices The application will print status messages to serial terminal showing sensor data � Cloud IoT Core supports two protocols for device connection and communication: MQTT and HTTP. Devices communicate with Cloud IoT Core across a "bridge" — either the MQTT bridge or the HTTP bridge. When you create a device registry, you select protocols to enable: MQTT, HTTP, or both.

Core IoT/MQTT Device Disconnected � Issue #1150 , https://stackoverflow.com/questions/54609757/google-core-iot-device-offline- event-or-connection-status. Makes me wish I hadn't put my faith in� Cloud IoT Core supports two protocols for device connection and communication: MQTT and HTTP. Devices communicate with Cloud IoT Core across a "bridge" — either the MQTT bridge or the HTTP bridge. The MQTT/HTTP bridge is a central component of Cloud IoT Core, as shown in the components overview.

Comments
  • Thanks i think this may work. I am unable to access google iot v1beta1 api. cloudiot.googleapis.com/$discovery/rest?version=v1beta1 whenever i try this discovery api this shows Discovery document not found for API service. Can you please help
  • My bad, I need to update those samples to instead use v1 (we're moving on from v1beta1).
  • Sorry to ask a another question in comment, I just wanted to know how to send iot config messages from firebase function with qos 0. I could not find anything in docs.
  • @HonneyGoyal might be worth asking another question but you could use the NodeJS manager example ensuring you add the dependencies in package.json for your cloud function.
  • We shouldn't have to do something like this just check if a device is online .. it's as simple as an MQTT connect/disconnect but i'm finding more and more how incomplete Google's IoT functionality is .. which makes it difficult to just use core iot and firebase without having to write a bunch of helper functions for basic iot stuff
  • Does any other cloud iot service has this option like aws or azure.
  • I don't know offhand. I work at Google, so I'm not as familiar with their systems. I did a quick look at AWS' events, and I don't see one for connect/disconnect, but I definitely could just be missing it in their docs.
  • The question is about the Google Cloud IoT platform, it's not about AWS.
  • Huh, hard to believe I wrote a response for the completely wrong platform. Weird.