|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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:
ACTION_CONNECT
- connect to a Bluetooth deviceACTION_DISCONNECT
- disconnect from a Bluetooth deviceACTION_SEND
- send data to ArduinoACTION_RECEIVED
- received data from Arduino
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
.
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:
ACTION_RECEIVED
- Amarino received data from ArduinoACTION_CONNECTED
- connection has been establishedACTION_DISCONNECTED
- disconnected from a deviceACTION_CONNECTION_FAILED
- connection attempt was not successful
ACTION_PAIRING_REQUESTED
- a notification message to pair the
device has popped upACTION_CONNECTED_DEVICES
- the list of connected devices is
broadcasted after a request was made using
ACTION_GET_CONNECTED_DEVICES
To receive feedback your have to register a BroadcastReceiver for information you are interested in.
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 |
---|
static final java.lang.String ACTION_CONNECT
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);
static final java.lang.String ACTION_DISCONNECT
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);
static final java.lang.String ACTION_SEND
Input: following EXTRAS must be within your intent
EXTRA_DEVICE_ADDRESS
- The address of the device
Amarino should send data toEXTRA_DATA_TYPE
- The type of data shipped with
this intentEXTRA_DATA
- The actual data you want to send. Be
sure the format of that data matches the data type you specified in
EXTRA_DATA_TYPEEXTRA_FLAG
- The flag to which the data correspond
to. If EXTRA_FLAG is not set, 'a' will be used by default.
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
static final java.lang.String ACTION_RECEIVED
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); } } } }
static final java.lang.String ACTION_CONNECTED
The Intent will have the following extra value:
EXTRA_DEVICE_ADDRESS
- the address of the connected
device.
static final java.lang.String ACTION_DISCONNECTED
The Intent will have the following extra value:
EXTRA_DEVICE_ADDRESS
- the address of the
disconnected device.
static final java.lang.String ACTION_CONNECTION_FAILED
The Intent will have the following extra value:
EXTRA_DEVICE_ADDRESS
- the address of the device
which could not be connectedThere are many reasons why this might happen.
static final java.lang.String ACTION_PAIRING_REQUESTED
This action goes along with a pairing request notification in your status bar.
static final java.lang.String ACTION_GET_CONNECTED_DEVICES
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 final java.lang.String ACTION_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 final java.lang.String ACTION_ENABLE
static final java.lang.String ACTION_DISABLE
static final java.lang.String ACTION_DISABLE_ALL
static final java.lang.String ACTION_EDIT_PLUGIN
static final java.lang.String EXTRA_DEVICE
static final java.lang.String EXTRA_DEVICE_ADDRESS
e.g. "00:06:54:4B:31:7E"
static final java.lang.String EXTRA_CONNECTED_DEVICE_ADDRESSES
static final java.lang.String EXTRA_DEVICE_STATE
either CONNECTED
, DISCONNECTED
or
CONNECTING
static final int CONNECTED
EXTRA_DEVICE_STATE
static final int DISCONNECTED
EXTRA_DEVICE_STATE
static final int CONNECTING
EXTRA_DEVICE_STATE
static final java.lang.String EXTRA_FLAG
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.
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.
static final int BOOLEAN_EXTRA
static final int BOOLEAN_ARRAY_EXTRA
static final int BYTE_EXTRA
static final int BYTE_ARRAY_EXTRA
static final int CHAR_EXTRA
static final int CHAR_ARRAY_EXTRA
static final int DOUBLE_EXTRA
static final int DOUBLE_ARRAY_EXTRA
static final int FLOAT_EXTRA
static final int FLOAT_ARRAY_EXTRA
static final int INT_EXTRA
static final int INT_ARRAY_EXTRA
static final int LONG_EXTRA
static final int LONG_ARRAY_EXTRA
static final int SHORT_EXTRA
static final int SHORT_ARRAY_EXTRA
static final int STRING_EXTRA
static final int STRING_ARRAY_EXTRA
static final java.lang.String EXTRA_DATA
static final java.lang.String EXTRA_PLUGIN_ID
static final java.lang.String EXTRA_PLUGIN_NAME
static final java.lang.String EXTRA_PLUGIN_DESC
static final java.lang.String EXTRA_PLUGIN_SERVICE_CLASS_NAME
static final java.lang.String EXTRA_PLUGIN_VISUALIZER
must be one of
static final int VISUALIZER_TEXT
static final int VISUALIZER_BARS
static final int VISUALIZER_GRAPH
static final java.lang.String EXTRA_VISUALIZER_MIN_VALUE
when using a graphical visualizer (em>VISUALIZER_BARS
or
em>VISUALIZER_GRAPH
) this value must be set to initialize
the visualizer
static final java.lang.String EXTRA_VISUALIZER_MAX_VALUE
when using a graphical visualizer this value must be set to initialize the visualizer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |