|
1 | 1 | # awsiotgg |
2 | 2 |
|
3 | | -Establishes AWS GreenGrass Connections |
| 3 | +Wrapper for AWS Greengrass to perform Core Discovery and Connection Establishment |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +* Core Discovery |
| 8 | +* Core Connection Establishment |
| 9 | +* Discovery Information Cache (enables connecting to Core even connection to Discovery Endpoint is lost) |
| 10 | +* Automatic Retry during Discovery and Connection Establishment |
4 | 11 |
|
5 | 12 | ## Usage |
6 | 13 |
|
7 | 14 | ```python |
8 | | -# Init AWSIoTMQTTShadowClient |
9 | | -self._shadow_client = AWSIoTMQTTShadowClient(self._config.THING_NAME) |
10 | 15 |
|
11 | | -# AWSIoTShadowClient configuration |
12 | | -... |
| 16 | +from AWSIoTGG import GGConnector |
| 17 | + |
| 18 | +# Init AWSIoTMQTTShadowClient |
| 19 | +self._shadow_client = AWSIoTPyMQTT.AWSIoTMQTTShadowClient(<THING_NAME>) |
13 | 20 |
|
14 | 21 | # Init DiscoveryInfoProvider |
15 | | -discovery_info_provider = DiscoveryInfoProvider() |
| 22 | +self._discovery_info_provider = DiscoveryInfoProvider() |
| 23 | +self._discovery_info_provider.configureEndpoint(<HOST>) |
| 24 | +self._discovery_info_provider.configureCredentials(<ROOT_CA_PATH>, <CERTIFICATE_PATH>, <PRIVATE_KEY_PATH>) |
16 | 25 |
|
17 | | -# DiscoveryInfoProvider configuration |
18 | | -... |
| 26 | +gg_connector = GGConnector( |
| 27 | + self._shadow_client, self._discovery_info_provider) |
19 | 28 |
|
20 | | -discovery_info = discovery_info_provider.discover( |
21 | | - self._config.THING_NAME) |
| 29 | +try: |
| 30 | + core_info, group_ca_path = gg_connector.discover(<THING_NAME>) |
22 | 31 |
|
23 | | -# Connect to GGC |
24 | | -self._connection_manager = GGConnectionManager( |
25 | | - self._shadow_client, discovery_info) |
26 | | -# Connect ShadowClient |
27 | | -logger.info('Connecting MQTT Shadow Client') |
28 | | -self._connection_manager.connect( |
29 | | - self._config.PRIVATE_KEY_PATH, self._config.CERTIFICATE_PATH) |
| 32 | + gg_connector.connect( |
| 33 | + core_info, group_ca_path, <CERTIFICATE_PATH>, <PRIVATE_KEY_PATH>) |
| 34 | +except BaseException as err: |
| 35 | + logger.error(err) |
| 36 | + sys.exit(1) |
30 | 37 |
|
31 | | -``` |
| 38 | +# Here comes the actual device implementation |
32 | 39 |
|
| 40 | +``` |
0 commit comments