The Mbed Cloud SDK provides a simplified interface to the Mbed Cloud APIs by exposing functionality using conventions and paradigms familiar to Java developers.
- Java > 1.7 tested with Oracle JRE
- The SDK uses SLF4j and hence, any supported logging framework (e.g. java.util.logging, logback, log4j) can be used by your application.
In order to best meet your requirements, Java SDK is packaged in 3 different ways:
- Individual Jars
- Distribution ZIP. See related gradle plugin for more details.
- A fat jar comprising the SDK and all its dependencies.
Artefacts listed above are published on JCenter and Maven Central. They can therefore be retrieved and included into your project using the package manager of your choice. To do so, please follow the instructions present on one of these artefact repositories (Bintray page of the project).
For example, if using Gradle, add the following compile dependency to build.gradle:
compile 'com.arm.mbed.cloud.sdk:mbed-cloud-sdk:1.x.y'
Current artefacts are not fully tailored for Android but can be used as is on this mobile platform. However, oltu dependency will have to be excluded to remove any compilation issue (e.g. Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Lorg/apache/oltu/oauth2/common/domain/credentials/Credentials). To do so, import the SDK in the gradle file, as follows:
implementation( 'com.arm.mbed.cloud.sdk:mbed-cloud-sdk:1.x.y' ){
// Excluding a particular transitive dependency:
exclude group: 'org.apache.oltu.oauth2'
}
These instructions can also be found in the official documentation:
- Create an API key on Mbed Cloud Portal.
- Import the SDK to your project using one of the packages listed above.
- Create a configuration object:
String logLevel = "BODY"; //Defines the logging level of HTTP communications. See CallLogLevel for more information. String apiKey = "<apikey>"; //API key to use for contacting Mbed Cloud. ConnectionOptions config = new ConnectionOptions(apiKey); config.setClientLogLevel(CallLogLevel.getLevel(logLevel));
- You are ready to go.
DeviceDirectory deviceApi = new DeviceDirectory(config); try { System.out.println(deviceApi.listDevices(null)); } catch (MbedCloudException e) { // TODO Auto-generated catch block e.printStackTrace(); }
The current version scheme used by the SDK reflects the version of the API it abstracts (e.g. 1.2.3 refers to 1.2 version of Mbed Cloud APIs). The last digit of the version corresponds to the SDK incremental version.
See the full documentation and API reference (i.e. javadoc) at https://cloud.mbed.com/docs/latest/mbed-cloud-sdk-java/. For usage examples, please have a look at the example project.
Mbed Cloud SDK for Java is open source and we would like your help. There is a brief guide on how to get started in CONTRIBUTING.md.
- All code inside *.internal.* packages or annotated as @Internal is considered private API and should not be relied upon at all.
- Classes annotated as @Module contain all Arm Mbed Cloud APIs
- Methods annotated as @API are the functions which can be used to interact with Mbed Cloud.
- APIs, objects or methods annotated as @Deprecated are supported until the next major release and will be removed later on. It is highly recommended to stop using them.
- Methods with @Daemon annotation should be used to monitor SDK daemon threads.
Mbed Cloud SDK for Java is free-to-use and licensed under the Apache License 2.0. See LICENCE file for more information.