java.io.Serializablepublic class Device
extends java.lang.Object
implements java.io.Serializable
| Constructor | Description |
|---|---|
Device(java.net.InetAddress ip,
Token token,
java.lang.String[] acceptableModels,
int timeout,
int retries) |
Baseclass for all miIO devices.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
configureRouter(java.lang.String ssid,
java.lang.String password) |
Set the deviced network connection up.
|
boolean |
configureRouter(java.lang.String ssid,
java.lang.String password,
int uid) |
|
boolean |
discover() |
Connect to a device and send a Hello message.
|
java.lang.String |
firmware() |
Get the devices firmware version.
|
java.lang.String[] |
getAcceptableModels() |
|
java.net.InetAddress |
getIp() |
|
int |
getRetries() |
|
int |
getTimeout() |
|
Token |
getToken() |
|
org.json.JSONObject |
info() |
Get the device info from the device
|
java.lang.String |
model() |
Get the devices model id.
|
java.lang.String |
send(java.lang.String payload) |
Send an arbitrary string as payload to the device.
|
Response |
send(java.lang.String method,
java.lang.Object params) |
Send a command to a device.
|
boolean |
sendOk(java.lang.String method) |
Send a command to a device without parameters.
|
boolean |
sendOk(java.lang.String method,
java.lang.Object params) |
Send a command to a device.
|
org.json.JSONArray |
sendToArray(java.lang.String method) |
Send a command to a device without parameters.
|
org.json.JSONArray |
sendToArray(java.lang.String method,
java.lang.Object params) |
Send a command to a device.
|
org.json.JSONObject |
sendToObject(java.lang.String method) |
Send a command to a device without parameters.
|
org.json.JSONObject |
sendToObject(java.lang.String method,
java.lang.Object params) |
Send a command to a device.
|
boolean |
update(java.lang.String url,
java.lang.String md5) |
Command the device to update
|
int |
updateProgress() |
Request the update progress as a percentage value from 0 to 100
|
java.lang.String |
updateStatus() |
Request the update status.
|
public Device(java.net.InetAddress ip,
Token token,
java.lang.String[] acceptableModels,
int timeout,
int retries)
ip - The IP address of the device to connect to. If the address is null the first device that is an acceptableModel will be chosen.token - The token for that device. If the token is null the token will be extracted from unprovisioned devices.acceptableModels - An array of acceptable devices to connect to.timeout - The timeout for the communicationretries - The number of retries after a failed communicationpublic java.net.InetAddress getIp()
public Token getToken()
public int getRetries()
public java.lang.String[] getAcceptableModels()
public int getTimeout()
public boolean discover()
public Response send(java.lang.String method, java.lang.Object params) throws CommandExecutionException
method - The method to execute on the device.params - The command to execute on the device. Must be a JSONArray or JSONObject.CommandExecutionException - When there has been a error during the communication or the response was invalid.public java.lang.String send(java.lang.String payload)
throws CommandExecutionException
payload - The string to send.CommandExecutionException - When there has been a error during the communication or the response was invalid.public org.json.JSONObject sendToObject(java.lang.String method,
java.lang.Object params)
throws CommandExecutionException
method - The method to execute on the device.params - The command to execute on the device. Must be a JSONArray or JSONObject.CommandExecutionException - When there has been a error during the communication or the response was invalid.public org.json.JSONObject sendToObject(java.lang.String method)
throws CommandExecutionException
method - The method to execute on the device.CommandExecutionException - When there has been a error during the communication or the response was invalid.public org.json.JSONArray sendToArray(java.lang.String method,
java.lang.Object params)
throws CommandExecutionException
method - The method to execute on the device.params - The command to execute on the device. Must be a JSONArray or JSONObject.CommandExecutionException - When there has been a error during the communication or the response was invalid.public org.json.JSONArray sendToArray(java.lang.String method)
throws CommandExecutionException
method - The method to execute on the device.CommandExecutionException - When there has been a error during the communication or the response was invalid.public boolean sendOk(java.lang.String method,
java.lang.Object params)
throws CommandExecutionException
method - The method to execute on the device.params - The command to execute on the device. Must be a JSONArray or JSONObject.CommandExecutionException - When there has been a error during the communication or the response was invalid.public boolean sendOk(java.lang.String method)
throws CommandExecutionException
method - The method to execute on the device.CommandExecutionException - When there has been a error during the communication or the response was invalid.public org.json.JSONObject info()
throws CommandExecutionException
CommandExecutionException - When there has been a error during the communication or the response was invalid.public boolean update(java.lang.String url,
java.lang.String md5)
throws CommandExecutionException
url - The URL to update frommd5 - The MD5 Checksum for the updateCommandExecutionException - When there has been a error during the communication or the response was invalid.public int updateProgress()
throws CommandExecutionException
CommandExecutionException - When there has been a error during the communication or the response was invalid.public java.lang.String updateStatus()
throws CommandExecutionException
CommandExecutionException - When there has been a error during the communication or the response was invalid.public boolean configureRouter(java.lang.String ssid,
java.lang.String password)
throws CommandExecutionException
ssid - The SSID to device should connect topassword - The password for that connectionCommandExecutionException - When there has been a error during the communication or the response was invalid.public boolean configureRouter(java.lang.String ssid,
java.lang.String password,
int uid)
throws CommandExecutionException
CommandExecutionExceptionpublic java.lang.String model()
throws CommandExecutionException
CommandExecutionException - When there has been a error during the communication or the response was invalid.public java.lang.String firmware()
throws CommandExecutionException
CommandExecutionException - When there has been a error during the communication or the response was invalid.Copyright © 2018. All rights reserved.