Skip to content

allthingstalk/java-sdk

Repository files navigation

Java SDK Build Status

Installation

Get the jar from the Release page and include it in your project.

Examples

Several basic examples are found in the /src/examples folder.

  • Counter.java send data from your application to AllThingsTalk (sensing)
  • Actuation.java toggle a boolean from AllThingsTalk (actuation)
  • BinaryPayload.java send data of multiple assets together in one binary payload. The corresponding .json file for decoding the payload in AllThingsTalk can be found in the same folder.

Device Credentials

You can either set them globally, using the same credentials for all applications using the sdk. Or you can set them locally in a specific sketch, overriding the global settings.

Depending on how you initialize the device object in your application, the global or local credentials will be used.

  • device = new Device(this, "your_device_id", "your_device_token"); will use the provided local credentials
  • device = new Device(this); will use the global credentials from the keys.json file

Raspberry Pi support

Prerequisites

Java 1.8 installed on your Raspberry Pi.

Raspian Jessie with Pixel has the latest Java version by default.

Raspian Jessie lite does not come with Java preinstalled.

GPIO pin layout and setup

Please check the pi4j documentation. Add the following jars to your project

  • pi4j-core.jar
  • pi4j-gpio-extension.jar

You can download the pi4j library here.

Building

You can build the project locally using supplied gradlew wrapper:

gradlew jar

This will produce .jar in the build/libs directory.