Greengrass Core Local Connectivity Information

0

Hi,

Does anyone know if there is a way of querying the connectivity status of a GreenGrass core from within a GGC Lambda running on the device?

We are looking to report the cloud connectivity health via an LED on the device, however, need to know (ideally) if the core is connected to the cloud and shadows are syncing correctly.

I am hoping there is a way to pull the data from the GGC locally, but cannot see anything in the documentation to suggest this exists.

My end goal is this, which is perfectly possible with Lambda accessing the hardware - it's just a matter of getting the connectivity information from the core.
GGC not running: LED Off
GGC running and connected: LED On
GGC running but disconnected: LED Flashing

Thanks,
Marty

asked 5 years ago188 views
2 Answers
0

I don't think we have an existing way to expose this information. One alternative this would be the lambda checks network connectivity regularly instead of through Greengrass Core. Have you considered that?

answered 5 years ago
0

Thanks @aws-hui, I ended up implementing the following (calling the GPIO connector) - which checks DNS and the connection to the ATS endpoint. A message pattern (or local file state) would be nice in future releases - If you could put in a feature request that would be great!

This can give the following light outputs:
OFF - When the connector terminates, say during a deploy or if GGCore is not running
ON - When the socket is successfully established and checked every 30s
Blinking - When a socket connection cannot be established to the ATS endpoiint

run_indicator_update = True
iot_connected = False

def is_connected():
    # Crude but will do for now
    try:
        host = socket.gethostbyname("greengrass-ats.iot.eu-west-1.amazonaws.com")
        s = socket.create_connection((host, 8443), 1)
        return True
    except:
        pass
    return False

def worker_iot_checker():
    global iot_connected
    while run_indicator_update:
        iot_connected = is_connected()
        sleep(30)

def worker_iot():
    led_full_on = False

    while run_indicator_update:

        if not iot_connected:
            led_full_on = False
            indicator_on(iot_gpio)
            sleep(0.5)
            indicator_off(iot_gpio)

        if iot_connected and not led_full_on:
            led_full_on = True
            indicator_on(iot_gpio)

        sleep(0.5)

t2 = threading.Thread(target=worker_iot_checker)
t2.start()

t3 = threading.Thread(target=worker_iot)
t3.start()

Edited by: martysweet on Jan 19, 2019 10:02 AM

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions