Skip to content
121 changes: 71 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
# AWS IoT Device SDK for Java v2

This document provides information about the AWS IoT device SDK for Java V2. This SDK is built on the [AWS Common Runtime](https://docs.aws.amazon.com/sdkref/latest/guide/common-runtime.html)
The AWS IoT Device SDK for Java v2 connects your Java applications and devices to the AWS IoT platform. It handles the complexities of secure communication, authentication, and device management so you can focus on your IoT solution. The SDK makes it easy to use AWS IoT services like Device Shadows, Jobs, Fleet Provisioning, and Commands.

*__Jump To:__*
**Supported Platforms**: Linux, Windows 10+, macOS 10.15+, Android API level 24+ (Android 7.0+)

*__Topics:__*
* [Features](#features)
* [Installation](#installation)
* [Android](./documents/ANDROID.md)
* [Minimum Requirements](#minimum-requirements)
* [Getting Started](#getting-started)
* [Samples](samples)
* [Mac-Only TLS Behavior](#mac-only-tls-behavior)
* [Getting Help](#getting-help)
* [FAQ](./documents/FAQ.md)
* [API Docs](https://aws.github.io/aws-iot-device-sdk-java-v2/)
* [MQTT5 User Guide](./documents/MQTT5_Userguide.md)
* [Migration Guide from the AWS IoT SDK for Java v1](./documents/MIGRATION_GUIDE.md)
* [Getting Help](#getting-help)
* [Resources](#resources)

## Features

The primary purpose of the AWS IoT Device SDK for Java v2 is to simplify the process of connecting devices to AWS IoT Core and interacting with AWS IoT services on various platforms. The SDK provides:

* Integrated service clients for AWS IoT Core services
* Secure device connections to AWS IoT Core using MQTT protocol including MQTT 5.0
* Support for [multiple authentication methods and connection types](./documents/MQTT5_Userguide.md#how-to-setup-mqtt5-builder-based-on-desired-connection-method)
* Android [support](./documents/ANDROID.md)

#### Supported AWS IoT Core services

* The [AWS IoT Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) service manages device state information in the cloud.
* The [AWS IoT Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) service sends remote operations to connected devices.
* The [AWS IoT fleet provisioning](https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html) service generates and delivers device certificates automatically.
* The [AWS IoT Device Management commands](https://docs.aws.amazon.com/iot/latest/developerguide/iot-remote-command.html) service sends instructions from the cloud to connected devices.

## Installation

The recommended way to use the AWS IoT Device SDK for Java v2 in your project is to consume it from Maven Central.

### Minimum Requirements

To develop applications that use AWS IoT Device SDK for Java v2, you need:
* Java 8+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html))
* Java JDK 8+ ([Download and Install JDK](https://docs.oracle.com/en/java/javase/18/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A))
* Java JDK 8+ ([Download and Install JDK](https://docs.oracle.com/en/java/javase/18/install/overview-jdk-installation.html))
* [Set JAVA_HOME](./documents/PREREQUISITES.md#set-java_home)
* A build tool such as [Maven](https://maven.apache.org/install.html)

[Step-by-step instructions](./documents/PREREQUISITES.md)

### Requirements to build the AWS CRT locally
* C++ 11 or higher
* Clang 3.9+ or GCC 4.4+ or MSVC 2015+
* CMake 3.1+

[Step-by-step instructions](./documents/PREREQUISITES.md)
See [detailed setup instructions](./documents/PREREQUISITES.md) for more information.

### Consuming IoT Device SDK from Maven in your application

Consuming this SDK via Maven is the preferred method of consuming it and using it within your application. To consume the Java V2 SDK in your application, add the following to your `pom.xml` dependencies:
Add the following to your `pom.xml` dependencies:

``` xml
<dependency>
Expand All @@ -46,57 +59,65 @@ Consuming this SDK via Maven is the preferred method of consuming it and using i
Replace `1.27.4` in `<version>1.27.4</version>` with the latest release version for the SDK.
Look up the latest SDK version here: https://github.com/aws/aws-iot-device-sdk-java-v2/releases

### Build IoT Device SDK from source
### Building AWS IoT SDK from source

[Install Maven and Set PATH](https://maven.apache.org/install.html)
See the [Development Guide](./documents/DEVELOPING.md) for detailed instructions on building from source and using local builds.

``` sh
# Create a workspace directory to hold all the SDK files
mkdir sdk-workspace
cd sdk-workspace
# Clone the repository
git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git
cd aws-iot-device-sdk-java-v2
# Compile and install
mvn clean install
```
## Getting Started

If you wish to use the latest CRT release, rather than the latest tested with the IoT SDK, you can run the following before running `mvn clean install`:
To get started with the AWS IoT Device SDK for Java v2:

~~~ sh
# Update the version of the CRT being used
mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*"
~~~
1. Add the SDK to your project - See the [Using SDK](#using-sdk) section for Maven dependency details

2. Choose your connection method - The SDK supports multiple authentication methods including X.509 certificates, AWS credentials, and custom authentication. [MQTT5 User Guide connection section](./documents/MQTT5_Userguide.md#how-to-setup-mqtt5-builder-based-on-desired-connection-method) and [MQTT5 PubSub sample](./samples/Mqtt5/PubSub/README.md) provide more guidance

3. Follow a complete example - Check out the [samples](samples) directory

4. Learn MQTT5 features - For advanced usage and configuration options, see the [MQTT5 User Guide](./documents/MQTT5_Userguide.md)

## Samples

[Samples README](samples)
Check out the [samples](samples) directory for working code examples that demonstrate:
- Basic MQTT connection and messaging
- [AWS IoT Device Shadow operations](./samples/ShadowSandbox/README.md)
- [AWS IoT Jobs](./samples/JobsSandbox/README.md)
- AWS IoT Fleet provisioning: [basic](./samples/Provisioning/Basic/README.md) and [with CSR](./samples/Provisioning/Csr/README.md)
- [AWS IoT Commands](./samples/CommandsSandbox/README.md)

The samples provide ready-to-run code with detailed setup instructions for each authentication method and use case.

## Getting Help

The best way to interact with our team is through GitHub.
* Open [discussion](https://github.com/aws/aws-iot-device-sdk-java-v2/discussions): Share ideas and solutions with the SDK community
* Search [issues](https://github.com/aws/aws-iot-device-sdk-java-v2/issues): Find created issues for answers based on a topic
* Create an [issue](https://github.com/aws/aws-iot-device-sdk-java-v2/issues/new/choose): New feature request or file a bug

### Mac-Only TLS Behavior
If you have a support plan with [AWS Support](https://aws.amazon.com/premiumsupport/), you can also create a new support case.

#### Mac-Only TLS Behavior

> [!NOTE]
> This SDK does not support TLS 1.3 on macOS. Support for TLS 1.3 on macOS is planned for a future release.

Please note that on Mac, once a private key is used with a certificate, that certificate-key pair is imported into the Mac Keychain. All subsequent uses of that certificate will use the stored private key and ignore anything passed in programmatically. Beginning in v1.7.3, when a stored private key from the Keychain is used, the following will be logged at the "info" log level:

```
static: certificate has an existing certificate-key pair that was previously imported into the Keychain. Using key from Keychain instead of the one provided.
static: certificate has an existing certificate-key pair that was previously imported into the Keychain.
Using key from Keychain instead of the one provided.
```

## Getting Help

The best way to interact with our team is through GitHub. You can open a [discussion](https://github.com/aws/aws-iot-device-sdk-java-v2/discussions) for guidance questions or an [issue](https://github.com/aws/aws-iot-device-sdk-java-v2/issues/new/choose) for bug reports, or feature requests. You may also find help on community resources such as [StackOverFlow](https://stackoverflow.com/questions/tagged/aws-iot) with the tag [#aws-iot](https://stackoverflow.com/questions/tagged/aws-iot) or if you have a support plan with [AWS Support](https://aws.amazon.com/premiumsupport/), you can also create a new support case.
## Resources

Please make sure to check out our resources too before opening an issue:
Check out our resources for additional guidance too before opening an issue:

* [FAQ](./documents/FAQ.md)
* [IoT Guide](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) ([source](https://github.com/awsdocs/aws-iot-docs))
* [AWS IoT Core Developer Guide](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html)
* [MQTT5 User Guide](./documents/MQTT5_Userguide.md)
* Check for similar [Issues](https://github.com/aws/aws-iot-device-sdk-java-v2/issues)
* [API Docs](https://aws.github.io/aws-iot-device-sdk-java-v2/)
* [AWS IoT Core Documentation](https://docs.aws.amazon.com/iot/)
* [Dev Blog](https://aws.amazon.com/blogs/?awsf.blog-master-iot=category-internet-of-things%23amazon-freertos%7Ccategory-internet-of-things%23aws-greengrass%7Ccategory-internet-of-things%23aws-iot-analytics%7Ccategory-internet-of-things%23aws-iot-button%7Ccategory-internet-of-things%23aws-iot-device-defender%7Ccategory-internet-of-things%23aws-iot-device-management%7Ccategory-internet-of-things%23aws-iot-platform)
* Integration with AWS IoT Services such as
[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html)
[Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html)
[Fleet Provisioning](https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html)
is provided by code that been generated from a model of the service.
* [Dev Blog](https://aws.amazon.com/blogs/iot/category/internet-of-things/)
* [Migration Guide from the AWS IoT SDK for Java v1](./documents/MIGRATION_GUIDE.md)
* [Contributions Guidelines](./documents/CONTRIBUTING.md)
* [DEVELOPING](./documents/DEVELOPING.md)

Expand Down
71 changes: 50 additions & 21 deletions documents/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,64 @@
# Developing Instructions
# Development Guide

Please first follow the instructions in the [main readme](../README.md)
This guide covers building and developing with the AWS IoT Device SDK for Java v2.

## Consuming Local IoT Device SDK from Maven in your application
To build the SDK locally and test local changes do the following:
**Prerequisites:** Follow the setup instructions in the [main README](../README.md) first.

Modify [sdk/pom.xml](https://github.com/aws/aws-iot-device-sdk-java-v2/sdk/pom.xml)
``` xml
## Building from Source

### Basic Build

```bash
# Create workspace directory
mkdir sdk-workspace
cd sdk-workspace

# Clone the repository
git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git
cd aws-iot-device-sdk-java-v2

# Build and install
mvn clean install
```

### Using Latest CRT Version

To use the latest AWS CRT release instead of the tested version:

```bash
# Update CRT version before building
mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*"
mvn clean install
```

## Using Local IoT SDK in Your Application

### Maven Dependency Configuration

To test local changes, update your application's `pom.xml`:

```xml
<dependency>
<groupId>software.amazon.awssdk.iotdevicesdk</groupId>
<artifactId>aws-iot-device-sdk</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
```
Note the version number matches the sdk version number in [aws-crt-java](https://github.com/awslabs/aws-crt-java/pom.xml)
under
```xml
<version>1.0.0-SNAPSHOT</version>
```

Please note: The default location for local builds with maven is
Linux: /home/<User_Name>/.m2
Windows: C:\Users\<User\_Name>\.m2
Mac: /Users/<user_name>/.m2
**Note:** Ensure the version matches the SDK version in [aws-crt-java pom.xml](https://github.com/awslabs/aws-crt-java/blob/main/pom.xml).

### Maven Local Repository

It is safe to delete the whole directory
It is possible to pass this directory as an argument to the maven command
**Default locations:**
- **Linux:** `/home/<username>/.m2`
- **Windows:** `C:\Users\<username>\.m2`
- **macOS:** `/Users/<username>/.m2`

**Custom repository location:**
```bash
mvn -Dmaven.repo.local=/my/local/repository/path clean install
mvn -Dmaven.repo.local=/path/to/custom/repo clean install
```
It is also possible to change it globally by modifying setting.xml in the maven
configuration files

After that making your changes, follow the guide in the [main page](../README.md)
**Global configuration:** Modify `settings.xml` in Maven configuration directory.

**Cleanup:** The `.m2` directory can be safely deleted to clear local builds.
Loading
Loading