Skip to content

Java V2 Add Fleetwise code examples #7396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8e80fc6
added IoT Fleetwise Java examples
scmacdon Apr 16, 2025
b6c5ca2
added IoT Fleetwise snippet tags
scmacdon Apr 16, 2025
7fb1a79
added IoT Fleetwise snippet tags
scmacdon Apr 16, 2025
c8f4c3e
updated the spec
scmacdon Apr 16, 2025
524c93d
added tests
scmacdon Apr 17, 2025
8cc0540
updated the scenario
scmacdon Apr 17, 2025
c1102a4
updated Actions
scmacdon Apr 21, 2025
3272cc3
added the scenario readme
scmacdon Apr 22, 2025
f9f27bb
updated the scenario readme
scmacdon Apr 22, 2025
887950c
updated the Actions file
scmacdon Apr 24, 2025
355bc18
updated the Actions file
scmacdon Apr 24, 2025
907eebf
added YAML file
scmacdon Apr 25, 2025
198fa02
added YAML file
scmacdon Apr 25, 2025
2fac06d
added YAML file
scmacdon Apr 25, 2025
ff8d8a5
fixed tag issue
scmacdon Apr 25, 2025
48e8693
updated SOS examples
scmacdon Apr 25, 2025
7203739
updated SOS examples
scmacdon Apr 25, 2025
e17113c
updated SOS examples
scmacdon Apr 25, 2025
022463a
updated SOS examples
scmacdon Apr 25, 2025
c375baf
updated SOS examples
scmacdon Apr 25, 2025
dd741fe
added service level readme produced by Writeme
scmacdon Apr 28, 2025
33373e0
updated the spec
scmacdon Apr 28, 2025
2a05ee8
updated the Action class
scmacdon Apr 28, 2025
2556462
rolled in review comments
scmacdon Apr 29, 2025
0907737
rolled in review comments
scmacdon Apr 29, 2025
035bd25
rolled in review comments
scmacdon Apr 29, 2025
b45c341
modified validate file
scmacdon Apr 30, 2025
40e3c29
rolled in review comments
scmacdon Apr 30, 2025
a93cf3e
rolled in review comments
scmacdon Apr 30, 2025
b525eff
rolled in review comments
scmacdon Apr 30, 2025
355842f
updated the spec
scmacdon Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated the Action class
  • Loading branch information
scmacdon authored and brmur committed May 1, 2025
commit 2a05ee8780f821cc58588098702c9224662b0d3b
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,13 @@ public CompletableFuture<Void> getVehicleDetailsAsync(String vehicleName) {
return getAsyncClient().getVehicle(request)
.whenComplete((response, exception) -> {
if (exception != null) {
throw new CompletionException("Failed to fetch vehicle details: " + exception.getMessage(), exception);
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;

if (cause instanceof ResourceNotFoundException) {
throw new CompletionException((ResourceNotFoundException) cause);
} else {
throw new CompletionException("Failed to fetch vehicle details: " + cause.getMessage(), cause);
}
} else {
Map<String, Object> details = new HashMap<>();
details.put("vehicleName", response.vehicleName());
Expand All @@ -537,7 +543,7 @@ public CompletableFuture<Void> getVehicleDetailsAsync(String vehicleName) {
});
}
})
.thenApply(response -> null); // returning CompletableFuture<Void>
.thenApply(response -> null); // CompletableFuture<Void>
}
// snippet-end:[iotfleetwise.java2.get.vehicle.main]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import software.amazon.awssdk.services.iotfleetwise.model.Node;
import software.amazon.awssdk.services.iotfleetwise.model.ResourceNotFoundException;
import software.amazon.awssdk.services.iotfleetwise.model.ValidationException;

import java.util.List;
import java.util.Scanner;
import java.util.concurrent.CompletionException;
Expand All @@ -22,17 +23,17 @@ public class FleetwiseScenario {

public static void main(String[] args) {
final String usage =
"""
Usage:
<signalCatalogName> <manifestName> <fleetId> <vecName> <decName>
"""
Usage:
<signalCatalogName> <manifestName> <fleetId> <vecName> <decName>

Where:
signalCatalogName - The name of the Signal Catalog to create (eg, catalog30).
manifestName - The name of the Vehicle Model (Model Manifest) to create (eg, manifest30).
fleetId - The ID of the Fleet to create (eg, fleet30).
vecName - The name of the Vehicle to create (eg, vehicle30).
decName - The name of the Decoder Manifest to create (eg, decManifest30).
""";
Where:
signalCatalogName - The name of the Signal Catalog to create (eg, catalog30).
manifestName - The name of the Vehicle Model (Model Manifest) to create (eg, manifest30).
fleetId - The ID of the Fleet to create (eg, fleet30).
vecName - The name of the Vehicle to create (eg, vehicle30).
decName - The name of the Decoder Manifest to create (eg, decManifest30).
""";

if (args.length != 5) {
System.out.println(usage);
Expand All @@ -46,28 +47,28 @@ public static void main(String[] args) {
String decName = args[4];

logger.info(
"""
AWS IoT FleetWise is a managed service that simplifies the
process of collecting, organizing, and transmitting vehicle
data to the cloud in near real-time. Designed for automakers
and fleet operators, it allows you to define vehicle models,
specify the exact data you want to collect (such as engine
temperature, speed, or battery status), and send this data to
AWS for analysis. By using intelligent data collection
techniques, IoT FleetWise reduces the volume of data
transmitted by filtering and transforming it at the edge,
helping to minimize bandwidth usage and costs.

At its core, AWS IoT FleetWise helps organizations build
scalable systems for vehicle data management and analytics,
supporting a wide variety of vehicles and sensor configurations.
You can define signal catalogs and decoder manifests that describe
how raw CAN bus signals are translated into readable data, making
the platform highly flexible and extensible. This allows
manufacturers to optimize vehicle performance, improve safety,
and reduce maintenance costs by gaining real-time visibility
into fleet operations.
""");
"""
AWS IoT FleetWise is a managed service that simplifies the
process of collecting, organizing, and transmitting vehicle
data to the cloud in near real-time. Designed for automakers
and fleet operators, it allows you to define vehicle models,
specify the exact data you want to collect (such as engine
temperature, speed, or battery status), and send this data to
AWS for analysis. By using intelligent data collection
techniques, IoT FleetWise reduces the volume of data
transmitted by filtering and transforming it at the edge,
helping to minimize bandwidth usage and costs.
At its core, AWS IoT FleetWise helps organizations build
scalable systems for vehicle data management and analytics,
supporting a wide variety of vehicles and sensor configurations.
You can define signal catalogs and decoder manifests that describe
how raw CAN bus signals are translated into readable data, making
the platform highly flexible and extensible. This allows
manufacturers to optimize vehicle performance, improve safety,
and reduce maintenance costs by gaining real-time visibility
into fleet operations.
""");

waitForInputToContinue(scanner);
logger.info(DASHES);
Expand Down Expand Up @@ -104,15 +105,15 @@ private static void runScenario(String signalCatalogName,
logger.info(DASHES);
logger.info("2. Create a fleet that represents a group of vehicles");
logger.info(
"""
Creating an IoT FleetWise fleet allows you to efficiently collect,
organize, and transfer vehicle data to the cloud, enabling real-time
insights into vehicle performance and health.

It helps reduce data costs by allowing you to filter and prioritize
only the most relevant vehicle signals, supporting advanced analytics
and predictive maintenance use cases.
""");
"""
Creating an IoT FleetWise fleet allows you to efficiently collect,
organize, and transfer vehicle data to the cloud, enabling real-time
insights into vehicle performance and health.
It helps reduce data costs by allowing you to filter and prioritize
only the most relevant vehicle signals, supporting advanced analytics
and predictive maintenance use cases.
""");

waitForInputToContinue(scanner);
String fleetid;
Expand Down Expand Up @@ -262,7 +263,17 @@ Before calling createVehicle(), you must create an AWS IoT Thing
logger.info(DASHES);
logger.info("9. Display vehicle details");
waitForInputToContinue(scanner);
actions.getVehicleDetailsAsync(vecName).join();
try {
actions.getVehicleDetailsAsync(vecName).join();
} catch (CompletionException ce) {
Throwable cause = ce.getCause();
if (cause instanceof ResourceNotFoundException) {
logger.error("The resource was not found: {}", cause.getMessage());
} else {
logger.error("An unexpected error occurred.", cause);
}
return;
}
waitForInputToContinue(scanner);
logger.info(DASHES);

Expand Down