com.motorola.oem.i2c
Interface I2CDatagramConnection

All Superinterfaces:
javax.microedition.io.Connection, javax.microedition.io.DatagramConnection

public interface I2CDatagramConnection
extends javax.microedition.io.DatagramConnection

This interface defines an I2C serial datagram connection.

A URI (Uniform Resource Identifier) with the below parameters is used to open an I2C connection.
The scheme must be as follows:
"i2c://"<bus_id>:[<device_address>][<bus_mode>][<data_rate>]

Any parameters must be separated by a semi-colon (;), spaces are not allowed in the string.

Only one I2CDatagramConnection may be opened for each bus identifier.
A java.io.IOException is thrown when trying to open 2nd I2CDatagramConection with the same bus identifier.
Legal parameters are defined below. Illegal or unrecognized parameters result with an IllegalArgumentException. If the value of a parameter is supported by the device, it must be honored. If the value of a parameter is not supported a java.io.IOException is thrown.

BNF Format for Connector.open() string

The URI must conform to the BNF syntax specified below. If the URI does not conform to this syntax, an IllegalArgumentException is thrown.

<i2c_datagram_connection_string> ::= "i2c://"<bus_id>:[<device_address>][<bus_mode>][<data_rate>]
<bus_id> ::= The bus identifier name. Use System.getProperty("microedition.i2cbusids") to get available i2c buses.
<device_address> ::= The device address in Hexadecimal representation. To be use in slave mode.
<bus_mode> ::= ;bus_mode=<bus_mode_value>
<bus_mode_value> ::= "singleMaster" |"multiMaster" | "slave"
<data_rate> ::= ;data_rate=<data_rate_value>
<data_rate_value> ::= "standard" | "fast" | "high"


For default values please see device's USER GUIDE.

In order to send or receive data on the I2CDatagramConnection, a new I2CDatagram object must be created.
Datagram objects must be allocated by calling the "newDatagram" method of the I2CDatagramConnection object.
The String addr parameter of "newDatagram" must be as described below.

The device_address and the register_address must be in a hexadecimal representation.
One of them or both can be omitted. Nevertheless the user need to set the device address and register address
before sending or receiving any data. Otherwise, the send or receive method will throw an IOException.
Address setting can be done through the I2CDatagram set address method.

For default values of the datagram header parameters, please, see device's USER GUIDE.

URI Scheme for address parameter in "newDatagram" method

The URI must conform to the BNF syntax specified below. Otherwise, an IllegalArgumentException is thrown.

<new_datagram_address_string> ::= "i2c://"[<device_address>]:[<register_address>]
<device_address> ::= address of the remote device in hexadecimal representation respective to the remote device address type
<register_address> ::= address of the register in hexadecimal representation respective to the register address length


Field Summary
static int DATA_RATE_FAST
          Specifies a fast data rate - up to 400Kbits/sec.
static int DATA_RATE_HIGH
          Specifies a high data rate - up to 3.4Mbits/sec.
static int DATA_RATE_STANDARD
          Specifies a standard data rate - up to 100Kbits/sec.
static int MODE_MULTI_MASTER
          Specifies an I2C multi master mode.
static int MODE_SINGLE_MASTER
          Specifies an I2C single master mode.
static int MODE_SLAVE
          Specifies an I2C slave mode.
 
Method Summary
 void allSlavesReaddress()
          Sends a general call address message to all slaves with a request to re-address.
 void allSlavesResetAndReaddress()
          Sends a general call address message to all slaves with a request to reset and re-address.
 int getDataRate()
          Gets the I2CDatagramConnection data rate.
 int getMode()
          Gets the I2CDatagramConnection mode.
 
Methods inherited from interface javax.microedition.io.DatagramConnection
getMaximumLength, getNominalLength, newDatagram, newDatagram, newDatagram, newDatagram, receive, send
 
Methods inherited from interface javax.microedition.io.Connection
close
 

Field Detail

MODE_SINGLE_MASTER

static final int MODE_SINGLE_MASTER
Specifies an I2C single master mode.

See Also:
Constant Field Values

MODE_MULTI_MASTER

static final int MODE_MULTI_MASTER
Specifies an I2C multi master mode.

See Also:
Constant Field Values

MODE_SLAVE

static final int MODE_SLAVE
Specifies an I2C slave mode.

See Also:
Constant Field Values

DATA_RATE_STANDARD

static final int DATA_RATE_STANDARD
Specifies a standard data rate - up to 100Kbits/sec.

See Also:
Constant Field Values

DATA_RATE_FAST

static final int DATA_RATE_FAST
Specifies a fast data rate - up to 400Kbits/sec.

See Also:
Constant Field Values

DATA_RATE_HIGH

static final int DATA_RATE_HIGH
Specifies a high data rate - up to 3.4Mbits/sec.

See Also:
Constant Field Values
Method Detail

getMode

int getMode()
Gets the I2CDatagramConnection mode.

Returns:
I2CDatagramConnection mode. The mode can be:
MODE_SINGLE_MASTER,
MODE_MULTI_MASTER,
MODE_SLAVE.

getDataRate

int getDataRate()
Gets the I2CDatagramConnection data rate.

Returns:
I2CDatagramConnection data rate.
The data rate can be:
DATA_RATE_STANDARD,
DATA_RATE_FAST,
DATA_RATE_HIGH.

allSlavesReaddress

void allSlavesReaddress()
                        throws java.io.IOException
Sends a general call address message to all slaves with a request to re-address.

Throws:
java.io.IOException - Failed sending all slaves a re-address broadcast message.

allSlavesResetAndReaddress

void allSlavesResetAndReaddress()
                                throws java.io.IOException
Sends a general call address message to all slaves with a request to reset and re-address.

Throws:
java.io.IOException - Failed sending all slaves a reset and re-address broadcast message.