public class Device
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Device.DeviceListener
A device listener receives notifications of new data available in the
Device object. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
D_DRAW_GESTURE |
static java.lang.String |
D_MESSAGE_RECEIVED |
static java.lang.String |
D_OUTPUT_STATE |
static java.lang.String |
D_START_DRAW |
static java.lang.String |
D_STATE_ADDRESS |
static byte |
DEVICE_INFO_NAME |
static byte |
DEVICE_INFO_TYPE |
static java.lang.String |
G_BUTTON_PRESS |
static java.lang.String |
G_DOUBLE_TOUCH |
static java.lang.String |
G_ID |
static java.lang.String |
G_SINGLE_TOUCH |
static char |
M_DEBUG |
static char |
M_ERROR |
static char |
M_GESTURE |
static char |
M_SYSTEM |
static java.lang.String |
S_ANALOG_READ |
static java.lang.String |
S_CHARGER_CONNECTED |
static java.lang.String |
S_DIGITAL_READ |
static java.lang.String |
S_DRAW_FINISHED |
static java.lang.String |
S_EEPROM_DUMP |
static java.lang.String |
S_FREE_RAM |
static java.lang.String |
S_PONG_MESSAGE |
static java.lang.String |
S_POWER_OFF |
static java.lang.String |
S_SYSTEM_VOLTAGE |
Constructor and Description |
---|
Device() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Device.DeviceListener deviceListener)
Adds a listener to the current set of event listeners of this adapter.
|
void |
connect(Context appContext)
Connects this adapter to the Tact-Tiles runtime service,
which handles the bluetooth communication and device access.
|
RuntimeConnection |
getServiceConnection()
Returns the service connection of this device.
|
protected void |
onDeviceFound()
Called when the bluetooth device is connected.
|
protected void |
onDeviceLost()
Called when the bluetooth device connection is lost or the device is not connected.
|
protected void |
onMessage(java.lang.String msg)
Called when a bluetooth message is received by the runtime service and this device is properly connected.
|
void |
powerOff()
Power the connected device off.
|
void |
removeListener(Device.DeviceListener deviceListener)
Removes a listener from the set listening to this adapter.
|
void |
requestBatteryStatus()
Request the battery status.
|
void |
send(byte[] msg)
Send a low level message to the physical device.
|
void |
send(java.lang.String msg)
Send a low level message to the physical device in a more human readable form.
|
void |
setTouchSensibility(int sensibility)
Sets the touch sensibility of the device's tiles.
|
void |
vibrateDevice(int times,
int duration)
Vibrates the physical device.
|
public static final char M_SYSTEM
public static final char M_ERROR
public static final char M_DEBUG
public static final char M_GESTURE
public static final java.lang.String S_PONG_MESSAGE
public static final java.lang.String S_POWER_OFF
public static final java.lang.String S_CHARGER_CONNECTED
public static final java.lang.String S_DRAW_FINISHED
public static final java.lang.String S_EEPROM_DUMP
public static final java.lang.String S_ANALOG_READ
public static final java.lang.String S_DIGITAL_READ
public static final java.lang.String S_FREE_RAM
public static final java.lang.String S_SYSTEM_VOLTAGE
public static final java.lang.String G_ID
public static final java.lang.String G_DOUBLE_TOUCH
public static final java.lang.String G_SINGLE_TOUCH
public static final java.lang.String G_BUTTON_PRESS
public static final java.lang.String D_DRAW_GESTURE
public static final java.lang.String D_MESSAGE_RECEIVED
public static final java.lang.String D_OUTPUT_STATE
public static final java.lang.String D_START_DRAW
public static final java.lang.String D_STATE_ADDRESS
public static byte DEVICE_INFO_NAME
public static byte DEVICE_INFO_TYPE
public RuntimeConnection getServiceConnection()
public void addListener(Device.DeviceListener deviceListener)
deviceListener
- The listener to be added to the current set of listeners on this adapter.public void removeListener(Device.DeviceListener deviceListener)
deviceListener
- The listener to be removed to the current set of listeners on this adapter.public void connect(Context appContext)
appContext
- The current context of this application.protected void onMessage(java.lang.String msg)
msg
- Message contents.protected void onDeviceFound()
protected void onDeviceLost()
public void powerOff()
public void requestBatteryStatus()
public void vibrateDevice(int times, int duration)
times
- Number of pulses.duration
- Duration in milliseconds of the on and off state.public void setTouchSensibility(int sensibility)
sensibility
- Integer in the range [0, 16].public void send(byte[] msg)
msg
- Message to be sent.public void send(java.lang.String msg)
msg
- Message to be sent.