Android SDK to listen to information travelling on The Things Network
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
gradle/wrapper
img
ttn-android-sdk
.gitignore
CHANGELOG.md
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

The Things Network - Android SDK

Android SDK to interact with the API of The Things Network servers.

Sample App

The sample app serves as an example. You can try it on your device:

Get it on Google Play

Sample app screenshot

Note that you won't be able to receive packets if you build the app yourself, as you need the right credentials.

Download SDK

Grab via gradle:

compile 'io.ticofab:ttn-android-sdk:2.0.0'

Usage

Please refer to the sample app. These are the main steps:

  1. Get a TTNMqttClient instance:
// instantiate a new client passing host, app EUI and access key, device to track ("+" for all devices)
TTNMqttClient mTTNMqttClient = new TTNMqttClient(STAGING_HOST, APP_EUI, ACCESS_KEY, "+");
  1. Subscribe to updates using a listener implementation of the MqttApiListener interface.
public interface MqttApiListener {
    void onPacket(Packet packet);

    void onError(Throwable throwable);

    void onConnected();

    void onDisconnected();
}
mTTNMqttClient.listen(new MqttApiListener() {
  ...
});

That's basically it! Remember to unsubscribe when done.

mTTNMqttClient.disconnect();

Deprecation

The SDK also offers capabilities to use the API v0, which had REST endpoint next to the MQTT one. Those API are considered deprecated and will eventually be discontinued.

Dependencies

SDK:

SAMPLE:

License

Copyright 2016 Fabio Tiriticco / Fabway

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.