3. 3 simple rules
1. Delays are to be expected
a. Non-blocking asynchronous code
b. Work with mocks
c. let the user know you are working (spinners, etc)
2. Study the APIs & SDKs
3. Start small and add features - MVP thinking
a. Do the Hard stuff first
b. Have fun (at the end)
23. HTML5 library initialize
//Initialize the Relayr SDK, you must give a RedirectURI and AppID
var relayr = RELAYR.init({
appId: "b616cb5d-17e6-4f57-aec5-e6eb1ab3de29",
});
24. HTML5 library Get Data
//If you have a token and your device ID, you can start listening to your
device without going through the login process
relayr.devices().getDeviceData({
token: "p7xjSVAhqP9gtqvg9aGD_dZ4DDzlSJHw",
deviceId:"c9b48194-bd71-42a6-9c11-f6901b9c9017",
incomingData: function(data){
console.log("data from single sensor with specific token", data);
}
});
25. HTML5 library Send Commands
//Turn you're BSH oven on
relayr.devices().sendCommand({
//you're relayr token if you haven't included it before
token: "p7xjSVAhqP9gtqvg9aGD_dZ4DDzlSJHw",
//relayr ID of you're oven
deviceId:"c9b48194-bd71-42a6-9c11-f6901b9c9017",
//turns on the Oven
command:{"path":"power_unit", "command": "power", "value": 2}
});
28. // HANDLE DATA
private void subscribeForUpdates(TransmitterDevice transmitterDevice) {
RelayrSdk.getWebSocketClient()
.subscribe(transmitterDevice)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Object>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Object o) {
//Parse data depending on device model
Log.i("DATA", o.toString());
}
});
}
29. // Send a Command
int value = 2;
String path = "power_unit";
String command = "power";
Command mCommand = new Command(path, command, value);
RelayrSdk.getRelayrApi()
.sendCommand(deviceId, mCommand)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Void>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Void aVoid) {
Log.i("TAG", "Command sent");
}
});
30. The Other SDKs / Libraries and
Frameworks
● NodeJS - Paul
● iOS - Marcos
● C# - Khaled
● Ruby - sorry!
● Python - Dinu
Would Like to see more? let’s talk :)