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
質問済み 2年前339ビュー
2回答
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
エキスパート
Greg_B
回答済み 2年前
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
回答済み 2年前
  • The reserved topic includes the thing name, e.g. $aws/things/THING_NAME/shadow/update

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ