Last active
January 14, 2019 09:25
-
-
Save qlocx/9e62025c8bc1db290ab5bdd38a45f479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String payload = "ce815a358bed057c3bdb5032a6246b6d5cb6113e705611cb81afe60aa2490126.f2a2b89f3eb8e17d2b612f2cafec30e5672a500cda8b81f21ff44489ececa885010f010b10112713011510110125000a00.13b2c3b7bafb1cb6be4aa252e2b2b7b853d7ae2ce9ae5dbb1834bf4f9d9ea3180201"; | |
//hämta adapter och skapa Qlocx-SDK | |
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); | |
final QlocxInterface qlocxInterface = new QlocxInterface(adapter); | |
//öppna lås med payload från Sesam | |
qlocxInterface.open(payload, new QlocxInterface.Callback() { | |
@Override | |
public void openResult(byte[] result) { | |
} | |
@Override | |
public void senseResult(byte[] result, boolean isOpen) {} | |
@Override | |
public void error(QlocxException e) { | |
Log.e("QlocxException", e.toString()); | |
} | |
}); | |
//känn av dörrstatus med payload från Sesam | |
qlocxInterface.sense(payload, new QlocxInterface.Callback() { | |
@Override | |
public void result(byte[] result) {} | |
@Override | |
public void senseResult(byte[] result, boolean isOpen) { | |
} | |
@Override | |
public void error(QlocxException e) { | |
Log.e("QlocxException", e.toString()); | |
} | |
}); | |
//avbryt pågående handling | |
qlocxInterface.cancel(); | |
//kolla om payloaden innehåller ett sense-kommando | |
qlocxInterface.senseAvailable(payload); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
QlocxException's:
Blåtands-adaptern är ej aktiverad: Bluetooth adapter not enabled
En annan handling körs: Another action is currently running
Blåtands-enheten hittades ej: Peripheral not found
Anslutningen till blåtands-enheten avbröts: Something happened to the bluetooth connection, disconnected
Nyckeln/payloaden skickad till SDK't innehåller inte en 'sense'-payload*: The payload does not contain a sense action
Du får även en metod i SDK't som heter senseAvailable(payload) returnerar en boolean.