This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build an authenticated client object | |
// This pattern repeats from https://www.linkedin.com/pulse/sending-sms-from-java-aws-sns-steve-perkins | |
AWSIot iotClient = AWSIotClientBuilder | |
.standard() | |
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET))) | |
.withRegion(Regions.US_WEST_2) | |
.build(); | |
// Send the ListThingsRequest to AWS IoT synchronously | |
ListThingsResult result = iotClient.listThings(new ListThingsRequest()); | |
List<ThingAttribute> things = result.getThings(); | |
// Now you have access to the Thing's name, thing type, version, and a map of attributes/tags | |
// Get all things of a specific type | |
String typeName = "LightsideSensor"; | |
ListThingsRequest listThingsRequest = new ListThingsRequest() | |
.withThingTypeName(typeName) | |
.withMaxResults(200); | |
ListThingsResult result = AwsClientFactory.getIotClient().listThings(listThingsRequest); | |
List<ThingAttribute> things = result.getThings(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment