at.abraxas.amarino
Interface AmarinoIntent


public interface AmarinoIntent

AmarinoIntent is a collection of Intents and Extras used by Amarino to perform actions. You can either use these intents directly or you can use the convenient functions in Amarino to communicate with Amarino. The way your application communicates with Amarino happens exclusively via Intents. For more information about Intents in general please refer to the Android Reference and learn everything about Intents.

The most important intents in Amarino are:

The ACTION_CONNECT, ACTION_DISCONNECT and ACTION_SEND intents are supposed to be broadcasted by your application in order to use Amarino to fulfill your request. ACTION_RECEIVED however is used the other way around. Amarino will broadcast this intent if it has received new data from Arduino. If you want to receive these data, your application has to implement a BroadcastReceiver catching the ACTION_RECEIVED intent.
SensorGraph is a neat example demonstrating the use of ACTION_CONNECT, ACTION_DISCONNECT and ACTION_RECEIVED.

Intents broadcasted by Amarino for feedback

Sometimes it is important to have feedback if an operation was successful or not. Amarino normally provides feedback by broadcasting intents with detailed information. We already have heart about ACTION_RECEIVED which is indeed also a feedback intent.

Feedback intents are:

To receive feedback your have to register a BroadcastReceiver for information you are interested in.

Author:
Bonifaz Kaufmann

$Id: AmarinoIntent.java 444 2010-06-10 13:11:59Z abraxas $

Field Summary
static java.lang.String ACTION_CONNECT
          Activity Action: Tell Amarino to connect to a device Input: EXTRA_DEVICE_ADDRESS - The address of the device Amarino should connect to.
static java.lang.String ACTION_CONNECTED
          Broadcast Action sent by Amarino: A connection to a device has been established The Intent will have the following extra value: EXTRA_DEVICE_ADDRESS - the address of the connected device.
static java.lang.String ACTION_CONNECTED_DEVICES
          Broadcast Action sent by Amarino: The list of currently connected devices The Intent will have the following extra value: #EXTRA_CONNECTED_DEVICES This action is only broadcasted if you have requested the list of device before by sending ACTION_GET_CONNECTED_DEVICES
static java.lang.String ACTION_CONNECTION_FAILED
          Broadcast Action sent by Amarino: A connection attempt to a device was not successful The Intent will have the following extra value: EXTRA_DEVICE_ADDRESS - the address of the device which could not be connected There are many reasons why this might happen.
static java.lang.String ACTION_DISABLE
          used to disable a specific plug-in, needs EXTRA_PLUGIN_ID to be set
static java.lang.String ACTION_DISABLE_ALL
          disables all plug-ins if there is no active connection
static java.lang.String ACTION_DISCONNECT
          Activity Action: Tell Amarino to disconnect from a device Input: EXTRA_DEVICE_ADDRESS - The address of the device Amarino should disconnect from.
static java.lang.String ACTION_DISCONNECTED
          Broadcast Action sent by Amarino: The connection to a device has been disconnected The Intent will have the following extra value: EXTRA_DEVICE_ADDRESS - the address of the disconnected device.
static java.lang.String ACTION_EDIT_PLUGIN
          calls the edit activity of a plug-in
static java.lang.String ACTION_ENABLE
          used to enaable a specific plug-in, needs EXTRA_PLUGIN_ID to be set
static java.lang.String ACTION_GET_CONNECTED_DEVICES
          Activity Action: Request the connected devices list from Amarino Input: nothing Output: Amarino will broadcast the result as ACTION_CONNECTED_DEVICES When you request the connected devices list you should always have a BroadcastReceiver ready to receive the result from Amarino
static java.lang.String ACTION_PAIRING_REQUESTED
          Broadcast Action sent by Amarino: Indicates that a pairing request has been started.
static java.lang.String ACTION_RECEIVED
          Broadcast Action sent by Amarino: Amarino broadcasts any received data from Arduino so that your application can receive them.
static java.lang.String ACTION_SEND
          Activity Action: Tell Amarino to send data to Arduino Input: following EXTRAS must be within your intent EXTRA_DEVICE_ADDRESS - The address of the device Amarino should send data to EXTRA_DATA_TYPE - The type of data shipped with this intent EXTRA_DATA - The actual data you want to send.
static int BOOLEAN_ARRAY_EXTRA
           
static int BOOLEAN_EXTRA
          boolean in Android is in Arduino 0=false, 1=true
static int BYTE_ARRAY_EXTRA
           
static int BYTE_EXTRA
          byte is byte.
static int CHAR_ARRAY_EXTRA
           
static int CHAR_EXTRA
          char is char.
static int CONNECTED
          Describes the state in EXTRA_DEVICE_STATE
static int CONNECTING
          Describes the state in EXTRA_DEVICE_STATE
static int DISCONNECTED
          Describes the state in EXTRA_DEVICE_STATE
static int DOUBLE_ARRAY_EXTRA
           
static int DOUBLE_EXTRA
          double is too large for Arduinos, better not to use this datatype
static java.lang.String EXTRA_CONNECTED_DEVICE_ADDRESSES
          Type: String[] - an array containing the addresses of all connected devices
static java.lang.String EXTRA_DATA
          Type: depends on EXTRA_DATA_TYPE
static java.lang.String EXTRA_DATA_TYPE
          the type of data attached to an intent You have to pass in the type of extra you going to send; for example: BOOLEAN_EXTRA, BYTE_EXTRA, STRING_EXTRA, INTEGER_EXTRA, etc.
static java.lang.String EXTRA_DEVICE
          Type: BTDevice
static java.lang.String EXTRA_DEVICE_ADDRESS
          Type: String e.g. "00:06:54:4B:31:7E"
static java.lang.String EXTRA_DEVICE_STATE
          Type: int either CONNECTED, DISCONNECTED or CONNECTING
static java.lang.String EXTRA_FLAG
          Type: char the flag is the identifier for your data used by Arduino to determine which function to call.
static java.lang.String EXTRA_PLUGIN_DESC
          Type: String - the description what your plug-in does
static java.lang.String EXTRA_PLUGIN_ID
          Type: Integer - the id of your plug-in given to your EditActivity when it is called
static java.lang.String EXTRA_PLUGIN_NAME
          Type: String - the name of your plug-in which is displayed to the user
static java.lang.String EXTRA_PLUGIN_SERVICE_CLASS_NAME
          Type: String - the name of your plug-in service class (fully qualified) e.g. at.abraxas.amarino.plugins.compass.BackgroundService
static java.lang.String EXTRA_PLUGIN_VISUALIZER
          Type: Integer - the type of visualizer you want to use to show data sent by a plug-in must be one of VISUALIZER_TEXT VISUALIZER_BARS VISUALIZER_GRAPH
static java.lang.String EXTRA_VISUALIZER_MAX_VALUE
          Type: Float - the maximum value to be expected when using a graphical visualizer this value must be set to initialize the visualizer
static java.lang.String EXTRA_VISUALIZER_MIN_VALUE
          Type: Float - the minimum value to be expected when using a graphical visualizer (em>VISUALIZER_BARS or em>VISUALIZER_GRAPH) this value must be set to initialize the visualizer
static int FLOAT_ARRAY_EXTRA
           
static int FLOAT_EXTRA
          float in Android is float in Arduino (4 bytes)
static int INT_ARRAY_EXTRA
           
static int INT_EXTRA
          int in Android is long in Arduino (4 bytes)
static int LONG_ARRAY_EXTRA
           
static int LONG_EXTRA
          long in Android does not fit in Arduino data types, better not to use it
static int SHORT_ARRAY_EXTRA
           
static int SHORT_EXTRA
          short in Android is like int in Arduino (2 bytes) 2^15
static int STRING_ARRAY_EXTRA
           
static int STRING_EXTRA
          String in Android is char[] in Arduino
static int VISUALIZER_BARS
          Displays the data coming from a plug-in using bars.
static int VISUALIZER_GRAPH
          Displays the data coming from a plug-in within a graph.
static int VISUALIZER_TEXT
          Displays the data coming from a plug-in as text
 

Field Detail

ACTION_CONNECT

static final java.lang.String ACTION_CONNECT
Activity Action: Tell Amarino to connect to a device

Input: EXTRA_DEVICE_ADDRESS - The address of the device Amarino should connect to.

Output: one of the following actions will be broadcasted

Example

 Intent intent = new Intent(AmarinoIntent.ACTION_CONNECT);
 intent.putExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS, DEVICE_ADDRESS);
 sendBroadcast(intent);
 

See Also:
Constant Field Values

ACTION_DISCONNECT

static final java.lang.String ACTION_DISCONNECT
Activity Action: Tell Amarino to disconnect from a device

Input: EXTRA_DEVICE_ADDRESS - The address of the device Amarino should disconnect from.

Output: the following action will be broadcasted

Example

 Intent intent = new Intent(AmarinoIntent.ACTION_DISCONNECT);
 intent.putExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS, DEVICE_ADDRESS);
 sendBroadcast(intent);
 

See Also:
Constant Field Values

ACTION_SEND

static final java.lang.String ACTION_SEND
Activity Action: Tell Amarino to send data to Arduino

Input: following EXTRAS must be within your intent

Apart from EXTRA_FLAG all EXTRAS are mandatory, otherwise Amarino will not forward your data to Arduino.

Output: Amarino forwards the data to the given address if the device is connected

See Also:
Constant Field Values

ACTION_RECEIVED

static final java.lang.String ACTION_RECEIVED
Broadcast Action sent by Amarino: Amarino broadcasts any received data from Arduino so that your application can receive them.

The Intent will have the following EXTRAS:

Example

 
 public class YourReceiver extends BroadcastReceiver {
 
        @Override
        public void onReceive(Context context, Intent intent) {
                String data = null;
                final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS);
                final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1);
 
                if (dataType == AmarinoIntent.STRING_EXTRA) {
                        data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA);
 
                        if (data != null) {
                                // do whatever you want to do with the data
                                mValueTV.setText(data);
                        }
                }
        }
 }
 

See Also:
Constant Field Values

ACTION_CONNECTED

static final java.lang.String ACTION_CONNECTED
Broadcast Action sent by Amarino: A connection to a device has been established

The Intent will have the following extra value:

See Also:
Constant Field Values

ACTION_DISCONNECTED

static final java.lang.String ACTION_DISCONNECTED
Broadcast Action sent by Amarino: The connection to a device has been disconnected

The Intent will have the following extra value:

See Also:
Constant Field Values

ACTION_CONNECTION_FAILED

static final java.lang.String ACTION_CONNECTION_FAILED
Broadcast Action sent by Amarino: A connection attempt to a device was not successful

The Intent will have the following extra value:

There are many reasons why this might happen.

See Also:
Constant Field Values

ACTION_PAIRING_REQUESTED

static final java.lang.String ACTION_PAIRING_REQUESTED
Broadcast Action sent by Amarino: Indicates that a pairing request has been started.

This action goes along with a pairing request notification in your status bar.

See Also:
Constant Field Values

ACTION_GET_CONNECTED_DEVICES

static final java.lang.String ACTION_GET_CONNECTED_DEVICES
Activity Action: Request the connected devices list from Amarino

Input: nothing

Output: Amarino will broadcast the result as ACTION_CONNECTED_DEVICES

When you request the connected devices list you should always have a BroadcastReceiver ready to receive the result from Amarino

See Also:
Constant Field Values

ACTION_CONNECTED_DEVICES

static final java.lang.String ACTION_CONNECTED_DEVICES
Broadcast Action sent by Amarino: The list of currently connected devices

The Intent will have the following extra value:

This action is only broadcasted if you have requested the list of device before by sending ACTION_GET_CONNECTED_DEVICES

See Also:
Constant Field Values

ACTION_ENABLE

static final java.lang.String ACTION_ENABLE
used to enaable a specific plug-in, needs EXTRA_PLUGIN_ID to be set

See Also:
Constant Field Values

ACTION_DISABLE

static final java.lang.String ACTION_DISABLE
used to disable a specific plug-in, needs EXTRA_PLUGIN_ID to be set

See Also:
Constant Field Values

ACTION_DISABLE_ALL

static final java.lang.String ACTION_DISABLE_ALL
disables all plug-ins if there is no active connection

See Also:
Constant Field Values

ACTION_EDIT_PLUGIN

static final java.lang.String ACTION_EDIT_PLUGIN
calls the edit activity of a plug-in

See Also:
Constant Field Values

EXTRA_DEVICE

static final java.lang.String EXTRA_DEVICE
Type: BTDevice

See Also:
Constant Field Values

EXTRA_DEVICE_ADDRESS

static final java.lang.String EXTRA_DEVICE_ADDRESS
Type: String
 e.g. "00:06:54:4B:31:7E"
 

See Also:
Constant Field Values

EXTRA_CONNECTED_DEVICE_ADDRESSES

static final java.lang.String EXTRA_CONNECTED_DEVICE_ADDRESSES
Type: String[] - an array containing the addresses of all connected devices

See Also:
Constant Field Values

EXTRA_DEVICE_STATE

static final java.lang.String EXTRA_DEVICE_STATE
Type: int

either CONNECTED, DISCONNECTED or CONNECTING

See Also:
Constant Field Values

CONNECTED

static final int CONNECTED
Describes the state in EXTRA_DEVICE_STATE

See Also:
Constant Field Values

DISCONNECTED

static final int DISCONNECTED
Describes the state in EXTRA_DEVICE_STATE

See Also:
Constant Field Values

CONNECTING

static final int CONNECTING
Describes the state in EXTRA_DEVICE_STATE

See Also:
Constant Field Values

EXTRA_FLAG

static final java.lang.String EXTRA_FLAG
Type: char

the flag is the identifier for your data used by Arduino to determine which function to call. Relates to

 registerFunction(flag, functionPointer);
 
in your Arduino sketch.

See Also:
Constant Field Values

EXTRA_DATA_TYPE

static final java.lang.String EXTRA_DATA_TYPE

the type of data attached to an intent

You have to pass in the type of extra you going to send; for example: BOOLEAN_EXTRA, BYTE_EXTRA, STRING_EXTRA, INTEGER_EXTRA, etc.

See Also:
Constant Field Values

BOOLEAN_EXTRA

static final int BOOLEAN_EXTRA
boolean in Android is in Arduino 0=false, 1=true

See Also:
Constant Field Values

BOOLEAN_ARRAY_EXTRA

static final int BOOLEAN_ARRAY_EXTRA
See Also:
Constant Field Values

BYTE_EXTRA

static final int BYTE_EXTRA
byte is byte. In Arduino a byte stores an 8-bit unsigned number, from 0 to 255.

See Also:
Constant Field Values

BYTE_ARRAY_EXTRA

static final int BYTE_ARRAY_EXTRA
See Also:
Constant Field Values

CHAR_EXTRA

static final int CHAR_EXTRA
char is char. In Arduino stored in 1 byte of memory

See Also:
Constant Field Values

CHAR_ARRAY_EXTRA

static final int CHAR_ARRAY_EXTRA
See Also:
Constant Field Values

DOUBLE_EXTRA

static final int DOUBLE_EXTRA
double is too large for Arduinos, better not to use this datatype

See Also:
Constant Field Values

DOUBLE_ARRAY_EXTRA

static final int DOUBLE_ARRAY_EXTRA
See Also:
Constant Field Values

FLOAT_EXTRA

static final int FLOAT_EXTRA
float in Android is float in Arduino (4 bytes)

See Also:
Constant Field Values

FLOAT_ARRAY_EXTRA

static final int FLOAT_ARRAY_EXTRA
See Also:
Constant Field Values

INT_EXTRA

static final int INT_EXTRA
int in Android is long in Arduino (4 bytes)

See Also:
Constant Field Values

INT_ARRAY_EXTRA

static final int INT_ARRAY_EXTRA
See Also:
Constant Field Values

LONG_EXTRA

static final int LONG_EXTRA
long in Android does not fit in Arduino data types, better not to use it

See Also:
Constant Field Values

LONG_ARRAY_EXTRA

static final int LONG_ARRAY_EXTRA
See Also:
Constant Field Values

SHORT_EXTRA

static final int SHORT_EXTRA
short in Android is like int in Arduino (2 bytes) 2^15

See Also:
Constant Field Values

SHORT_ARRAY_EXTRA

static final int SHORT_ARRAY_EXTRA
See Also:
Constant Field Values

STRING_EXTRA

static final int STRING_EXTRA
String in Android is char[] in Arduino

See Also:
Constant Field Values

STRING_ARRAY_EXTRA

static final int STRING_ARRAY_EXTRA
See Also:
Constant Field Values

EXTRA_DATA

static final java.lang.String EXTRA_DATA
Type: depends on EXTRA_DATA_TYPE

See Also:
Constant Field Values

EXTRA_PLUGIN_ID

static final java.lang.String EXTRA_PLUGIN_ID
Type: Integer - the id of your plug-in given to your EditActivity when it is called

See Also:
Constant Field Values

EXTRA_PLUGIN_NAME

static final java.lang.String EXTRA_PLUGIN_NAME
Type: String - the name of your plug-in which is displayed to the user

See Also:
Constant Field Values

EXTRA_PLUGIN_DESC

static final java.lang.String EXTRA_PLUGIN_DESC
Type: String - the description what your plug-in does

See Also:
Constant Field Values

EXTRA_PLUGIN_SERVICE_CLASS_NAME

static final java.lang.String EXTRA_PLUGIN_SERVICE_CLASS_NAME
Type: String - the name of your plug-in service class (fully qualified) e.g. at.abraxas.amarino.plugins.compass.BackgroundService

See Also:
Constant Field Values

EXTRA_PLUGIN_VISUALIZER

static final java.lang.String EXTRA_PLUGIN_VISUALIZER
Type: Integer - the type of visualizer you want to use to show data sent by a plug-in

must be one of

See Also:
Constant Field Values

VISUALIZER_TEXT

static final int VISUALIZER_TEXT
Displays the data coming from a plug-in as text

See Also:
Constant Field Values

VISUALIZER_BARS

static final int VISUALIZER_BARS
Displays the data coming from a plug-in using bars. Upper and lower bounds need to be specified when this visualizer is used.

See Also:
Constant Field Values

VISUALIZER_GRAPH

static final int VISUALIZER_GRAPH
Displays the data coming from a plug-in within a graph. Upper and lower bounds need to be specified when this visualizer is used.

See Also:
Constant Field Values

EXTRA_VISUALIZER_MIN_VALUE

static final java.lang.String EXTRA_VISUALIZER_MIN_VALUE
Type: Float - the minimum value to be expected

when using a graphical visualizer (em>VISUALIZER_BARS or em>VISUALIZER_GRAPH) this value must be set to initialize the visualizer

See Also:
Constant Field Values

EXTRA_VISUALIZER_MAX_VALUE

static final java.lang.String EXTRA_VISUALIZER_MAX_VALUE
Type: Float - the maximum value to be expected

when using a graphical visualizer this value must be set to initialize the visualizer

See Also:
Constant Field Values