|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zu.ardulink.Link
public class Link
v0.6.1 Magnum PI
This class represents the connection between the computer and the Arduino board. At the moment the connection is only a serial connection to USB. Any java class must use this class to communicate with Arduino. To get a class instance you can call a static method to get the default link or require the creation of a specific link. In this way it is possible to simultaneously connect to several Arduino boards. Each link can define a specific protocol or use the protocol ardulink (ALProtocol).
Field Summary | |
---|---|
static int |
DEFAULT_BAUDRATE
Default baud rate for serial connections |
static String |
DEFAULT_LINK_NAME
Default Link name |
Method Summary | |
---|---|
boolean |
addAnalogReadChangeListener(AnalogReadChangeListener listener)
Register an AnalogReadChangeListener to receive events about analog pin change state. |
boolean |
addConnectionListener(ConnectionListener connectionListener)
Register a ConnectionListener to receive events about connection status. |
boolean |
addDigitalReadChangeListener(DigitalReadChangeListener listener)
Register an DigitalReadChangeListener to receive events about digital pin change state. |
boolean |
addRawDataListener(RawDataListener rawDataListener)
Register a RawDataListener to receive data from Arduino. |
boolean |
connect(Object... params)
Connects to Arduino board. |
static Link |
createInstance(String linkName)
Creates a Link instance with a specific name. |
static Link |
createInstance(String linkName,
Connection connection)
Creates a Link instance with a specific name and a specific connection (default is serial connection) |
static Link |
createInstance(String linkName,
String protocolName)
Creates a Link instance with a specific name and a specific protocol. |
static Link |
createInstance(String linkName,
String protocolName,
Connection connection)
Creates a Link instance with a specific name and a specific protocol and a specific connection (default is serial connection) |
static Link |
destroyInstance(String linkName)
|
boolean |
disconnect()
Disconnect from arduino board. |
Connection |
getConnection()
|
static Link |
getDefaultInstance()
|
static Link |
getInstance(String linkName)
|
LoggerReplyMessageCallback |
getLoggerCallback()
|
String |
getName()
|
List<String> |
getPortList()
It works for serial connection links |
String |
getProtocolName()
|
boolean |
isConnected()
|
IncomingMessageEvent |
parseMessage(int[] realMsg)
Parse a message sent from arduino. |
boolean |
removeAnalogReadChangeListener(AnalogReadChangeListener listener)
Remove a AnalogReadChangeListener from the event notification set. |
boolean |
removeConnectionListener(ConnectionListener connectionListener)
Remove a ConnectionListener from the event notification set. |
boolean |
removeDigitalReadChangeListener(DigitalReadChangeListener listener)
Remove a DigitalReadChangeListener from the event notification set. |
boolean |
removeRawDataListener(RawDataListener rawDataListener)
Remove a RawDataListener from the data notification set. |
MessageInfo |
sendCustomMessage(String message)
Call protocol sendCustomMessage with this Link (and without a call back implementation to manage reply message) Custom message should be used to request specific actions in custom sketches |
MessageInfo |
sendCustomMessage(String message,
ReplyMessageCallback callback)
Call protocol sendCustomMessage with this Link. |
MessageInfo |
sendKeyPressEvent(char keychar,
int keycode,
int keylocation,
int keymodifiers,
int keymodifiersex)
Call protocol sendKeyPressEvent with this Link (and without a call back implementation to manage reply message) |
MessageInfo |
sendKeyPressEvent(char keychar,
int keycode,
int keylocation,
int keymodifiers,
int keymodifiersex,
ReplyMessageCallback callback)
Call protocol sendKeyPressEvent with this Link. |
MessageInfo |
sendNoToneMessage(int pin)
Call protocol sendNoToneMessage with this Link (and without a call back implementation to manage reply message) This method request arduino to perform a noTone function call. |
MessageInfo |
sendNoToneMessage(int pin,
ReplyMessageCallback callback)
Call protocol sendNoToneMessage with this Link This method request arduino to perform a noTone function call. |
MessageInfo |
sendPowerPinIntensity(int pin,
int intensity)
Call protocol sendPowerPinIntensity with this Link (and without a call back implementation to manage reply message) This method request arduino to perform an analogWrite function call. |
MessageInfo |
sendPowerPinIntensity(int pin,
int intensity,
ReplyMessageCallback callback)
Call protocol sendPowerPinIntensity with this Link. |
MessageInfo |
sendPowerPinSwitch(int pin,
int power)
Call protocol sendPowerPinSwitch with this Link (and without a call back implementation to manage reply message) This method request arduino to perform a digitalWrite function call. |
MessageInfo |
sendPowerPinSwitch(int pin,
int power,
ReplyMessageCallback callback)
Call protocol sendPowerPinSwitch with this Link. |
MessageInfo |
sendToneMessage(int pin,
int frequency)
Call protocol sendToneMessage with this Link (and without a call back implementation to manage reply message) This method request arduino to perform a tone function call. |
MessageInfo |
sendToneMessage(int pin,
int frequency,
int duration)
Call protocol sendToneMessage with this Link (and without a call back implementation to manage reply message) This method request arduino to perform a tone function call. |
MessageInfo |
sendToneMessage(int pin,
int frequency,
int duration,
ReplyMessageCallback callback)
Call protocol sendToneMessage with this Link This method request arduino to perform a tone function call. |
MessageInfo |
sendToneMessage(int pin,
int frequency,
ReplyMessageCallback callback)
Call protocol sendToneMessage with this Link This method request arduino to perform a tone function call. |
MessageInfo |
startListenAnalogPin(int pin)
Call protocol startListenAnalogPin with this Link (and without a call back implementation to manage reply message). |
MessageInfo |
startListenAnalogPin(int pin,
ReplyMessageCallback callback)
As startListenAnalogPin(int pin) but with the possibility to add a callback. |
MessageInfo |
startListenDigitalPin(int pin)
Call protocol startListenDigitalPin with this Link (and without a call back implementation to manage reply message). |
MessageInfo |
startListenDigitalPin(int pin,
ReplyMessageCallback callback)
As startListenDigitalPin(int pin) but with the possibility to add a callback. |
MessageInfo |
stopListenAnalogPin(int pin)
Call protocol stopListenAnalogPin with this Link (and without a call back implementation to manage reply message). |
MessageInfo |
stopListenAnalogPin(int pin,
ReplyMessageCallback callback)
As stopListenAnalogPin(int pin) but with the possibility to add a callback. |
MessageInfo |
stopListenDigitalPin(int pin)
Call protocol stopListenDigitalPin with this Link (and without a call back implementation to manage reply message). |
MessageInfo |
stopListenDigitalPin(int pin,
ReplyMessageCallback callback)
As stopListenDigitalPin(int pin) but with the possibility to add a callback. |
boolean |
writeSerial(int numBytes,
int[] message)
Writes data to arduino |
boolean |
writeSerial(String message)
Writes data to arduino |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BAUDRATE
public static final String DEFAULT_LINK_NAME
getDefaultInstance()
,
getInstance(String linkName)
,
Constant Field ValuesMethod Detail |
---|
public static Link getDefaultInstance()
public static Link getInstance(String linkName)
linkName
- the link name. If null the method returns the default instance.
public static Link createInstance(String linkName)
linkName
-
ProtocolHandler
public static Link createInstance(String linkName, String protocolName)
linkName
- protocolName
-
ProtocolHandler
public static Link createInstance(String linkName, Connection connection)
linkName
- connection
-
public static Link createInstance(String linkName, String protocolName, Connection connection)
linkName
- protocolName
- connection
-
public static Link destroyInstance(String linkName)
public boolean connect(Object... params)
params
-
public List<String> getPortList()
SerialConnection
public boolean disconnect()
public boolean isConnected()
SerialConnection
public boolean writeSerial(String message)
message
-
SerialConnection
public boolean writeSerial(int numBytes, int[] message)
numBytes
- message
-
SerialConnection
public boolean addConnectionListener(ConnectionListener connectionListener)
connectionListener
-
ConnectionContact
public boolean removeConnectionListener(ConnectionListener connectionListener)
connectionListener
-
ConnectionContact
public boolean addRawDataListener(RawDataListener rawDataListener)
rawDataListener
-
ConnectionContact
public boolean removeRawDataListener(RawDataListener rawDataListener)
rawDataListener
-
ConnectionContact
public boolean addAnalogReadChangeListener(AnalogReadChangeListener listener)
listener
-
ConnectionContact
public boolean removeAnalogReadChangeListener(AnalogReadChangeListener listener)
listener
-
ConnectionContact
public boolean addDigitalReadChangeListener(DigitalReadChangeListener listener)
listener
-
ConnectionContact
public boolean removeDigitalReadChangeListener(DigitalReadChangeListener listener)
listener
-
ConnectionContact
public LoggerReplyMessageCallback getLoggerCallback()
public String getName()
public MessageInfo sendKeyPressEvent(char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex)
keychar
- keycode
- keylocation
- keymodifiers
- keymodifiersex
-
public MessageInfo sendPowerPinIntensity(int pin, int intensity)
pin
- intensity
- range 0-255
public MessageInfo sendPowerPinSwitch(int pin, int power)
pin
- power
- IProtocol.POWER_HIGH or IProtocol.POWER_LOW
public MessageInfo sendToneMessage(int pin, int frequency)
pin
- frequency
-
public MessageInfo sendToneMessage(int pin, int frequency, int duration)
pin
- frequency
- duration
-
public MessageInfo sendNoToneMessage(int pin)
pin
-
public MessageInfo sendCustomMessage(String message)
message
-
public MessageInfo sendKeyPressEvent(char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex, ReplyMessageCallback callback)
keychar
- keycode
- keylocation
- keymodifiers
- keymodifiersex
- callback
-
public MessageInfo sendPowerPinIntensity(int pin, int intensity, ReplyMessageCallback callback)
pin
- intensity
- callback
-
public MessageInfo sendPowerPinSwitch(int pin, int power, ReplyMessageCallback callback)
pin
- power
- IProtocol.HIGH or IProtocol.LOWcallback
-
public MessageInfo sendToneMessage(int pin, int frequency, ReplyMessageCallback callback)
pin
- frequency
- callback
-
public MessageInfo sendToneMessage(int pin, int frequency, int duration, ReplyMessageCallback callback)
pin
- frequency
- duration
- callback
-
public MessageInfo sendNoToneMessage(int pin, ReplyMessageCallback callback)
pin
- callback
-
public MessageInfo sendCustomMessage(String message, ReplyMessageCallback callback)
message
- callback
-
public MessageInfo startListenDigitalPin(int pin)
pin
-
public MessageInfo stopListenDigitalPin(int pin)
pin
-
public MessageInfo startListenAnalogPin(int pin)
pin
-
public MessageInfo stopListenAnalogPin(int pin)
pin
-
public MessageInfo startListenDigitalPin(int pin, ReplyMessageCallback callback)
pin
- callback
-
public MessageInfo stopListenDigitalPin(int pin, ReplyMessageCallback callback)
pin
- callback
-
public MessageInfo startListenAnalogPin(int pin, ReplyMessageCallback callback)
pin
- callback
-
public MessageInfo stopListenAnalogPin(int pin, ReplyMessageCallback callback)
pin
- callback
-
public String getProtocolName()
public IncomingMessageEvent parseMessage(int[] realMsg)
realMsg
-
public Connection getConnection()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |