Skip to content

Commit 4fd6cd8

Browse files
author
aws
committed
Release of Version 1.1.0
1 parent bdd489f commit 4fd6cd8

28 files changed

+3336
-254
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

LICENSE

Lines changed: 201 additions & 174 deletions
Large diffs are not rendered by default.

NOTICE

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
AWS Greengrass Core SDK Js
2-
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
AWS Greengrass Core SDK for JavaScript
2+
Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
This product includes software developed at
5+
Amazon Web Services, Inc. (http://aws.amazon.com/).
6+

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Instructions can be found under manual/index.html

README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*/
4+
5+
/*
6+
* Demonstrates a simple publish to a topic using Greengrass Core NodeJS SDK
7+
* This lambda function will retrieve underlying platform information and send
8+
* a hello world message along with the platform information to the topic
9+
* 'hello/world'. The function will sleep for five seconds, then repeat.
10+
* Since the function is long-lived it will run forever when deployed to a
11+
* Greengrass core.
12+
*/
13+
14+
const ggSdk = require('aws-greengrass-core-sdk');
15+
16+
const iotClient = new ggSdk.IotData();
17+
const os = require('os');
18+
const util = require('util');
19+
20+
function publishCallback(err, data) {
21+
console.log(err);
22+
console.log(data);
23+
}
24+
25+
const myPlatform = util.format('%s-%s', os.platform(), os.release());
26+
const pubOpt = {
27+
topic: 'hello/world',
28+
payload: JSON.stringify({ message: util.format('Hello world! Sent from Greengrass Core running on platform: %s using NodeJS', myPlatform) }),
29+
};
30+
31+
function greengrassHelloWorldRun() {
32+
iotClient.publish(pubOpt, publishCallback);
33+
}
34+
35+
// Schedule the job to run every 5 seconds
36+
setInterval(greengrassHelloWorldRun, 5000);
37+
38+
// This is a handler which does nothing for this example
39+
exports.handler = function handler(event, context) {
40+
console.log(event);
41+
console.log(context);
42+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*/
4+
5+
/*
6+
* Demonstrates how to return a result back to the caller of this lambda
7+
*/
8+
9+
exports.handler = function handler(event, context, callback) {
10+
console.log(event);
11+
console.log(context);
12+
callback(undefined, { result: 'message' });
13+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*/
4+
5+
/*
6+
* Demonstrates how to invoke another lambda with binary data and receive the value from the call
7+
*/
8+
9+
const ggSdk = require('aws-greengrass-core-sdk');
10+
11+
const lambdaClient = new ggSdk.Lambda();
12+
13+
exports.handler = function handler(event, context) {
14+
console.log(event);
15+
console.log(context);
16+
17+
const cxt = {
18+
custom: {
19+
customData: 'customData',
20+
},
21+
};
22+
const contextString = JSON.stringify(cxt);
23+
const buff = Buffer.from(contextString);
24+
const clientContext = buff.toString('base64');
25+
26+
const params = {
27+
FunctionName: 'arn:<partition>:lambda:<region>:<accountId>:function:<targetFunctionName>:<targetFunctionQualifier>',
28+
InvocationType: 'RequestResponse',
29+
ClientContext: clientContext,
30+
Payload: Buffer.from('payload message', 'utf8'),
31+
};
32+
33+
lambdaClient.invoke(params, (err, data) => {
34+
if (err) {
35+
console.error(err, err.stack);
36+
} else {
37+
console.log(data);
38+
}
39+
});
40+
};

0 commit comments

Comments
 (0)