Crea sito


org.zu.ardulink.protocol
Interface IProtocol

All Known Implementing Classes:
ALProtocol, SimpleBinaryProtocol

public interface IProtocol

Ardulink - return to homepage

v0.6.1 Magnum PI

This interface defines all the messages that can be sent to the Arduino and provides a method to analyze all messages from Arduino. For each message sent the caller can set a callback class. In this way the caller can know asynchronously if a message has been processed by Arduino board. If callback class is not setted (or is null) then arduino should not send a reply message because caller is not interested in replies.

Author:
Luciano Zu project Ardulink http://www.ardulink.org/
See Also:
ProtocolHandler, Link,


Nested Class Summary
static class IProtocol.ProtocolType
           
 
Field Summary
static byte DEFAULT_INCOMING_MESSAGE_DIVIDER
           
static byte DEFAULT_OUTGOING_MESSAGE_DIVIDER
           
static int HIGH
           
static int LOW
           
static int POWER_HIGH
           
static int POWER_LOW
           
static int REPLY_KO
           
static int REPLY_OK
           
static int UNDEFINED_ID
           
static int UNDEFINED_REPLY
           
 
Method Summary
 int getIncomingMessageDivider()
          the incoming message divider used from Connection to divide incoming message (if ProtocolType is binary then incoming must be equal to outgoing
 int getOutgoingMessageDivider()
          the outgoing message divider used from Protocol to divide outgoing message (if ProtocolType is binary then incoming must be equal to outgoing
 String getProtocolName()
           
 IProtocol.ProtocolType getProtocolType()
           
 IncomingMessageEvent parseMessage(int[] realMsg)
          When a message arrives from Arduino, ConnectionContactImpl and Link classes call this method that parses message and returns a specific event.
 MessageInfo sendCustomMessage(Link link, String message)
          Sends a custom message used for specific actions in Arduino sketches
 MessageInfo sendCustomMessage(Link link, String message, ReplyMessageCallback callback)
          Sends a custom message used for specific actions in Arduino sketches
 MessageInfo sendKeyPressEvent(Link link, char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex)
          Sends information about which key was pressed.
 MessageInfo sendKeyPressEvent(Link link, char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex, ReplyMessageCallback callback)
          Sends information about which key was pressed.
 MessageInfo sendNoToneMessage(Link link, int pin)
          Sends the request to stop the generation of a tone (square wave)
 MessageInfo sendNoToneMessage(Link link, int pin, ReplyMessageCallback callback)
          Sends the request to stop the generation of a tone (square wave)
 MessageInfo sendPowerPinIntensity(Link link, int pin, int intensity)
          Sends the request to set a PWM type pin to a certain intensity.
 MessageInfo sendPowerPinIntensity(Link link, int pin, int intensity, ReplyMessageCallback callback)
          Sends the request to set a PWM type pin to a certain intensity.
 MessageInfo sendPowerPinSwitch(Link link, int pin, int power)
          Sends the request to set a pin to HIGH or LOW power.
 MessageInfo sendPowerPinSwitch(Link link, int pin, int power, ReplyMessageCallback callback)
          Sends the request to set a pin to HIGH or LOW power.
 MessageInfo sendToneMessage(Link link, int pin, int frequency)
          Sends the request to generate a tone (square wave)
 MessageInfo sendToneMessage(Link link, int pin, int frequency, int duration)
          Sends the request to generate a tone (square wave)
 MessageInfo sendToneMessage(Link link, int pin, int frequency, int duration, ReplyMessageCallback callback)
          Sends the request to generate a tone (square wave)
 MessageInfo sendToneMessage(Link link, int pin, int frequency, ReplyMessageCallback callback)
          Sends the request to generate a tone (square wave)
 MessageInfo startListenAnalogPin(Link link, int pin)
          Sends the request to listen on a specific analog pin.
 MessageInfo startListenAnalogPin(Link link, int pin, ReplyMessageCallback callback)
          Sends the request to listen on a specific analog pin.
 MessageInfo startListenDigitalPin(Link link, int pin)
          Sends the request to listen on a specific pin.
 MessageInfo startListenDigitalPin(Link link, int pin, ReplyMessageCallback callback)
          Sends the request to listen on a specific pin.
 MessageInfo stopListenAnalogPin(Link link, int pin)
          Sends the request to not listen on a specific analog pin.
 MessageInfo stopListenAnalogPin(Link link, int pin, ReplyMessageCallback callback)
          Sends the request to not listen on a specific analog pin.
 MessageInfo stopListenDigitalPin(Link link, int pin)
          Sends the request to not listen on a specific pin.
 MessageInfo stopListenDigitalPin(Link link, int pin, ReplyMessageCallback callback)
          Sends the request to not listen on a specific pin.
 

Field Detail

POWER_HIGH

static final int POWER_HIGH
See Also:
Constant Field Values

POWER_LOW

static final int POWER_LOW
See Also:
Constant Field Values

HIGH

static final int HIGH
See Also:
Constant Field Values

LOW

static final int LOW
See Also:
Constant Field Values

UNDEFINED_ID

static final int UNDEFINED_ID
See Also:
Constant Field Values

UNDEFINED_REPLY

static final int UNDEFINED_REPLY
See Also:
Constant Field Values

REPLY_OK

static final int REPLY_OK
See Also:
Constant Field Values

REPLY_KO

static final int REPLY_KO
See Also:
Constant Field Values

DEFAULT_INCOMING_MESSAGE_DIVIDER

static final byte DEFAULT_INCOMING_MESSAGE_DIVIDER
See Also:
Constant Field Values

DEFAULT_OUTGOING_MESSAGE_DIVIDER

static final byte DEFAULT_OUTGOING_MESSAGE_DIVIDER
See Also:
Constant Field Values
Method Detail

sendKeyPressEvent

MessageInfo sendKeyPressEvent(Link link,
                              char keychar,
                              int keycode,
                              int keylocation,
                              int keymodifiers,
                              int keymodifiersex)
Sends information about which key was pressed.

Parameters:
link -
keychar -
keycode -
keylocation -
keymodifiers -
keymodifiersex -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendPowerPinIntensity

MessageInfo sendPowerPinIntensity(Link link,
                                  int pin,
                                  int intensity)
Sends the request to set a PWM type pin to a certain intensity. Values must be between 0 and 255. Arduino should perform an analogWrite(pin, intensity)

Parameters:
link -
pin -
intensity -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendPowerPinSwitch

MessageInfo sendPowerPinSwitch(Link link,
                               int pin,
                               int power)
Sends the request to set a pin to HIGH or LOW power. Arduino should perform a digitalWrite(pin, power)

Parameters:
link -
pin -
power -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendToneMessage

MessageInfo sendToneMessage(Link link,
                            int pin,
                            int frequency)
Sends the request to generate a tone (square wave)

Parameters:
link -
pin -
frequency -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendToneMessage

MessageInfo sendToneMessage(Link link,
                            int pin,
                            int frequency,
                            int duration)
Sends the request to generate a tone (square wave)

Parameters:
link -
pin -
frequency -
duration -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendNoToneMessage

MessageInfo sendNoToneMessage(Link link,
                              int pin)
Sends the request to stop the generation of a tone (square wave)

Parameters:
link -
pin -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendCustomMessage

MessageInfo sendCustomMessage(Link link,
                              String message)
Sends a custom message used for specific actions in Arduino sketches

Parameters:
link -
message -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendKeyPressEvent

MessageInfo sendKeyPressEvent(Link link,
                              char keychar,
                              int keycode,
                              int keylocation,
                              int keymodifiers,
                              int keymodifiersex,
                              ReplyMessageCallback callback)
Sends information about which key was pressed.

Parameters:
link -
keychar -
keycode -
keylocation -
keymodifiers -
keymodifiersex -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendPowerPinIntensity

MessageInfo sendPowerPinIntensity(Link link,
                                  int pin,
                                  int intensity,
                                  ReplyMessageCallback callback)
Sends the request to set a PWM type pin to a certain intensity. Values must be between 0 and 255. Arduino should perform an analogWrite(pin, intensity)

Parameters:
link -
pin -
intensity -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendPowerPinSwitch

MessageInfo sendPowerPinSwitch(Link link,
                               int pin,
                               int power,
                               ReplyMessageCallback callback)
Sends the request to set a pin to HIGH or LOW power. Arduino should perform a digitalWrite(pin, power)

Parameters:
link -
pin -
power -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendToneMessage

MessageInfo sendToneMessage(Link link,
                            int pin,
                            int frequency,
                            ReplyMessageCallback callback)
Sends the request to generate a tone (square wave)

Parameters:
link -
pin -
frequency -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendToneMessage

MessageInfo sendToneMessage(Link link,
                            int pin,
                            int frequency,
                            int duration,
                            ReplyMessageCallback callback)
Sends the request to generate a tone (square wave)

Parameters:
link -
pin -
frequency -
duration -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendNoToneMessage

MessageInfo sendNoToneMessage(Link link,
                              int pin,
                              ReplyMessageCallback callback)
Sends the request to stop the generation of a tone (square wave)

Parameters:
link -
pin -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

sendCustomMessage

MessageInfo sendCustomMessage(Link link,
                              String message,
                              ReplyMessageCallback callback)
Sends a custom message used for specific actions in Arduino sketches

Parameters:
link -
message -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

parseMessage

IncomingMessageEvent parseMessage(int[] realMsg)
When a message arrives from Arduino, ConnectionContactImpl and Link classes call this method that parses message and returns a specific event. If message arrived is a reply message then null is returned and a callback action is taken. Otherwise the caller take specific action based on specific IncomingMessage. i.e. if a AnalogReadChangeEvent is raised then the caller fire the event to all the listeners.

Parameters:
realMsg -
Returns:
IncomingMessageEvent dependent from message parsed, null if message is a reply message.

startListenDigitalPin

MessageInfo startListenDigitalPin(Link link,
                                  int pin)
Sends the request to listen on a specific pin. After calling this method, Arduino should start sending messages about the value read from the specified pin (digitalRead).

Parameters:
link -
pin -
Returns:
a MessageInfo containing the success or failure (for comunication)

stopListenDigitalPin

MessageInfo stopListenDigitalPin(Link link,
                                 int pin)
Sends the request to not listen on a specific pin. After calling this method, Arduino should stop sending messages about the value read from the specified pin (digitalRead).

Parameters:
link -
pin -
Returns:
a MessageInfo containing the success or failure (for comunication)

startListenAnalogPin

MessageInfo startListenAnalogPin(Link link,
                                 int pin)
Sends the request to listen on a specific analog pin. After calling this method, Arduino should start sending messages about the value read from the specified pin (analogRead).

Parameters:
link -
pin -
Returns:
a MessageInfo containing the success or failure (for comunication)

stopListenAnalogPin

MessageInfo stopListenAnalogPin(Link link,
                                int pin)
Sends the request to not listen on a specific analog pin. After calling this method, Arduino should stop sending messages about the value read from the specified pin (analogRead).

Parameters:
link -
pin -
Returns:
a MessageInfo containing the success or failure (for comunication)

startListenDigitalPin

MessageInfo startListenDigitalPin(Link link,
                                  int pin,
                                  ReplyMessageCallback callback)
Sends the request to listen on a specific pin. After calling this method, Arduino should start sending messages about the value read from the specified pin (digitalRead).

Parameters:
link -
pin -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

stopListenDigitalPin

MessageInfo stopListenDigitalPin(Link link,
                                 int pin,
                                 ReplyMessageCallback callback)
Sends the request to not listen on a specific pin. After calling this method, Arduino should stop sending messages about the value read from the specified pin (digitalRead).

Parameters:
link -
pin -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

startListenAnalogPin

MessageInfo startListenAnalogPin(Link link,
                                 int pin,
                                 ReplyMessageCallback callback)
Sends the request to listen on a specific analog pin. After calling this method, Arduino should start sending messages about the value read from the specified pin (analogRead).

Parameters:
link -
pin -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

stopListenAnalogPin

MessageInfo stopListenAnalogPin(Link link,
                                int pin,
                                ReplyMessageCallback callback)
Sends the request to not listen on a specific analog pin. After calling this method, Arduino should stop sending messages about the value read from the specified pin (analogRead).

Parameters:
link -
pin -
callback -
Returns:
a MessageInfo containing the success or failure (for comunication)

getProtocolName

String getProtocolName()
Returns:
the protocol name

getProtocolType

IProtocol.ProtocolType getProtocolType()
Returns:
the protocol type

getIncomingMessageDivider

int getIncomingMessageDivider()
the incoming message divider used from Connection to divide incoming message (if ProtocolType is binary then incoming must be equal to outgoing


getOutgoingMessageDivider

int getOutgoingMessageDivider()
the outgoing message divider used from Protocol to divide outgoing message (if ProtocolType is binary then incoming must be equal to outgoing



Copyright © 2015. All rights reserved.