Simulate a "thing" in Java?

1

I'm hoping I can write a quick function that simulates a "thing" in Java and be able to use it to either post messages to a topic, or update its shadow.

I have the AWS Java SDK in my project and I know how to use the IotClient and IotDataPlaneClient. The problem is that these clients are both authenticated with an access key that belongs to an AWS account, and in the case of the IotDataPlane client, I have to specify the name of the thing who's shadow I want to update.

What I'd like to do instead is mimic what an actual thing would do, which is to say, use a certificate to connect with the service, and only be able to update its own shadow, etc.

It seems like this should be possible, but I can't find any kind of credentials provider that works with certificates or any other obvious way to do it.

I know there is a complicated device simulator available and I may use it months from now when my application is further along, but for right now I'm just looking for something very quick and simple to prove a few concepts and work out my strategy.

Thanks, Frank

Frank
asked 2 years ago334 views
2 Answers
1

Hi Frank. I'm going to mention the device SDK again. It's what a device, implemented in Java, would normally use.

https://github.com/aws/aws-iot-device-sdk-java-v2/blob/main/samples/BasicPubSub/src/main/java/pubsub/PubSub.java

https://github.com/aws/aws-iot-device-sdk-java-v2/blob/main/samples/Shadow/src/main/java/shadow/ShadowSample.java

Stepping outside of Java, we have similar samples in most of our other-language device SDKs. We also have the Device Client: https://github.com/awslabs/aws-iot-device-client

You can use pretty much any MQTT client though. You could even use mosquitto_pub: https://manpages.debian.org/testing/mosquitto-clients/mosquitto_pub.1.en.html

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago
0

Thanks, I have that and I think I see how it can work with certificates. I guess that when a thing updates it's "shadow" it's just posting to a queue with a reserved name, correct? Does the "thing" need to tell its own name to IoT or does IoT figure that out from its certificate?

Frank
answered 2 years ago
  • The reserved topic includes the thing name, e.g. $aws/things/THING_NAME/shadow/update

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