|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.dalsemi.onewire.adapter.DSPortAdapter
|
+--com.dalsemi.onewire.adapter.NetAdapter
NetAdapter is a network-based DSPortAdapter. It allows for the use of an actual DSPortAdapter which isn't on the local machine, but rather is connected to another device which is reachable via a TCP/IP network connection.
The syntax for the selectPort(String) command is the
hostname of the computer which hosts the actual DSPortAdapter and the
TCP/IP port that the host is listening on. If the port number is not
specified, a default value of 6161 is used. Here are a few examples to
illustrate the syntax:
In the onewire.properties file, you can add a host to your list of valid
hosts by making a NetAdapter.host with an integer to distinguish the hosts.
There is no limit on the number of hosts which can appear in this list, but
the first one must be numbered '0'. These hosts will then be returned in
the list of valid 'ports' from the selectPortNames() method.
Note that there do not have to be any servers returned from
selectPortNames() for the NetAdapter to be able to connect
to them (so it isn't necessary to add these entries for it to function),
but applications which allow a user to automatically select an appropriate
adapter and a port from a given list will not function properly without it.
For example:
The multicast socket technique allows you to automatically discover
hosts on your subnet which are listening for multicast packets. By
default, the multicast discovery of NetAdapter hosts is disabled.
When enabled, the NetAdapter creates a multicast socket and looks for servers
every time you call selectPortNames(). This will add a
1 second delay (due to the socket timeout) on calling the method. If you'd
like to enable this feature, add the following line to your
onewire.properties file:
Once the NetAdapter is connected with a host, a version check is performed followed by a simple authentication step. The authentication is dependent upon a secret shared between the NetAdapter and the host. Both will use a default value, that each will agree with if you don't provide a secret of your own. To set the secret, add the following line to your onewire.properties file:
All of the above mentioned properties can be set on the command-line as well as being set in the onewire.properties file. To set the properties on the command-line, use the -D option: java -DNetAdapter.Secret="custom secret" myApplication
The following is a list of all parameters that can be set for the
NetAdapter, followed by default values where applicable.
If you wanted added security on the communication channel, an SSL socket
(or similar custom socket implementation) can be used by circumventing the
standard DSPortAdapter's selectPort(String) and using the
NetAdapter-specific selectPort(Socket). For example:
NetAdapter na = new NetAdapter();
Socket secureSocket = // insert fancy secure socket implementation here
na.selectPort(secureSocket);
For information on setting up the host component, see the JavaDocs
for the NetAdapterHost
NetAdapterHost| Inner classes inherited from class com.dalsemi.onewire.adapter.NetAdapterConstants |
NetAdapterConstants.Connection |
| Fields inherited from class com.dalsemi.onewire.adapter.DSPortAdapter |
CONDITION_AFTER_BIT, CONDITION_AFTER_BYTE, CONDITION_NOW, DELIVERY_CURRENT_DETECT, DELIVERY_EPROM, DELIVERY_FOUR_SECONDS, DELIVERY_HALF_SECOND, DELIVERY_INFINITE, DELIVERY_ONE_SECOND, DELIVERY_SMART_DONE, DELIVERY_TWO_SECONDS, LEVEL_BREAK, LEVEL_NORMAL, LEVEL_POWER_DELIVERY, LEVEL_PROGRAM, RESET_ALARM, RESET_NOPRESENCE, RESET_PRESENCE, RESET_SHORT, SPEED_FLEX, SPEED_HYPERDRIVE, SPEED_OVERDRIVE, SPEED_REGULAR |
| Constructor Summary | |
NetAdapter()
Creates an instance of NetAdapter that isn't connected. |
|
| Method Summary | |
boolean |
adapterDetected()
Detects adapter presence on the selected port. |
boolean |
beginExclusive(boolean blocking)
Gets exclusive use of the 1-Wire to communicate with an iButton or 1-Wire Device. |
boolean |
canBreak()
Returns whether adapter can physically support 0 volt 'break' mode. |
boolean |
canDeliverPower()
Returns whether the adapter can physically support strong 5 volt power mode. |
boolean |
canDeliverSmartPower()
Returns whether the adapter can physically support "smart" strong 5 volt power mode. |
boolean |
canFlex()
Returns whether the adapter can physically support flex speed mode. |
boolean |
canHyperdrive()
Returns whether the adapter can physically support hyperdrive mode. |
boolean |
canOverdrive()
Returns whether adapter can physically support overdrive mode. |
boolean |
canProgram()
Returns whether adapter can physically support 12 volt power mode. |
void |
dataBlock(byte[] dataBlock,
int off,
int len)
Sends a block of data and returns the data received in the same array. |
void |
endExclusive()
Relinquishes exclusive control of the 1-Wire Network. |
void |
excludeFamily(byte[] family)
Takes an array of bytes containing family codes to avoid when finding iButtons or 1-Wire devices. |
void |
excludeFamily(int family)
Takes an integer family code to avoid when searching for iButtons. |
boolean |
findFirstDevice()
Returns true if the first iButton or 1-Wire device
is found on the 1-Wire Network. |
boolean |
findNextDevice()
Returns true if the next iButton or 1-Wire device
is found. |
void |
freePort()
Frees ownership of the selected port, if it is currently owned, back to the system. |
String |
getAdapterName()
Retrieves the name of the port adapter as a string. |
void |
getAddress(byte[] address)
Copies the 'current' 1-Wire device address being used by the adapter into the array. |
boolean |
getBit()
Gets a bit from the 1-Wire Network. |
void |
getBlock(byte[] arr,
int len)
Gets a block of data from the 1-Wire Network and write it into the provided array. |
void |
getBlock(byte[] arr,
int off,
int len)
Gets a block of data from the 1-Wire Network and write it into the provided array. |
byte[] |
getBlock(int len)
Gets a block of data from the 1-Wire Network. |
int |
getByte()
Gets a byte from the 1-Wire Network. |
String |
getClassVersion()
Retrieves a version string for this class. |
String |
getPortName()
Retrieves the name of the selected port as a String. |
Enumeration |
getPortNames()
Retrieves a list of the platform appropriate port names for this adapter. |
String |
getPortTypeDescription()
Retrieves a description of the port required by this port adapter. |
int |
getSpeed()
Returns the current data transfer speed on the 1-Wire Network. |
void |
putBit(boolean bitValue)
Sends a bit to the 1-Wire Network. |
void |
putByte(int byteValue)
Sends a byte to the 1-Wire Network. |
int |
reset()
Sends a Reset to the 1-Wire Network. |
void |
resetSecret()
Resets the secret to be the default stored in the onewire.properties file (if there is one), or the default as defined by NetAdapterConstants. |
boolean |
selectPort(Socket sock)
New method, unique to NetAdapter. |
boolean |
selectPort(String portName)
Specifies a platform appropriate port name for this adapter. |
void |
setNoResetSearch()
Sets the 1-Wire Network search to not perform a 1-Wire reset before a search. |
void |
setPowerDuration(int timeFactor)
Sets the duration to supply power to the 1-Wire Network. |
void |
setPowerNormal()
Sets the 1-Wire Network voltage to normal level. |
void |
setProgramPulseDuration(int timeFactor)
Sets the duration for providing a program pulse on the 1-Wire Network. |
void |
setSearchAllDevices()
Sets the 1-Wire Network search to find all iButtons and 1-Wire devices whether they are in an 'Alarm' state or not and restores the default setting of providing a 1-Wire reset command before each search. |
void |
setSearchOnlyAlarmingDevices()
Sets the 1-Wire Network search to find only iButtons and 1-Wire devices that are in an 'Alarm' state that signals a need for attention. |
void |
setSecret(String secret)
Sets the shared secret for authenticating this NetAdapter with a NetAdapterHost. |
void |
setSpeed(int speed)
Sets the new speed of data transfer on the 1-Wire Network. |
void |
startBreak()
Sets the 1-Wire Network voltage to 0 volts. |
boolean |
startPowerDelivery(int changeCondition)
Sets the 1-Wire Network voltage to supply power to a 1-Wire device. |
boolean |
startProgramPulse(int changeCondition)
Sets the 1-Wire Network voltage to eprom programming level. |
void |
targetAllFamilies()
Removes any selectivity during a search for iButtons or 1-Wire devices by family type. |
void |
targetFamily(byte[] family)
Takes an array of bytes to use for selectively searching for acceptable family codes. |
void |
targetFamily(int family)
Takes an integer to selectively search for this desired family type. |
| Methods inherited from class com.dalsemi.onewire.adapter.DSPortAdapter |
assertSelect, assertSelect, assertSelect, getAdapterAddress, getAdapterVersion, getAddressAsLong, getAddressAsString, getAllDeviceContainers, getDeviceContainer, getDeviceContainer, getDeviceContainer, getDeviceContainer, getFirstDeviceContainer, getNextDeviceContainer, isAlarming, isAlarming, isAlarming, isPresent, isPresent, isPresent, registerOneWireContainerClass, select, select, select |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public NetAdapter()
| Method Detail |
public void setSecret(String secret)
secret - the new secret for authenticating this client.public void resetSecret()
public boolean adapterDetected()
throws OneWireIOException,
OneWireException
adapterDetected in class DSPortAdaptertrue if the adapter is confirmed to be connected to
the selected port, false if the adapter is not connected.OneWireIOException - OneWireException - public String getAdapterName()
getAdapterName in class DSPortAdapterString representation of the port adapter.public String getPortTypeDescription()
getPortTypeDescription in class DSPortAdapterString description of the port type required.public String getClassVersion()
getClassVersion in class DSPortAdapterpublic Enumeration getPortNames()
OneWireException exception.getPortNames in class DSPortAdapterEnumeration of type String that contains the port
names
public boolean selectPort(String portName)
throws OneWireIOException,
OneWireException
PortInUseException will be thrown.selectPort in class DSPortAdapterportName - Address to connect this NetAdapter to, in the form of
"hostname:port". For example, "shughes.dalsemi.com:6161", where 6161
is the port number to connect to. The use of NetAdapter.DEFAULT_PORT
is recommended.true if the port was aquired, false
if the port is not available.OneWireIOException - If port does not exist, or unable to communicate with port.OneWireException - If port does not exist
public boolean selectPort(Socket sock)
throws OneWireIOException,
OneWireException
sock - Socket connection to NetAdapterHosttrue if connection to host was successfulOneWireIOException - If port does not exist, or unable to communicate with port.OneWireException - If port does not exist
public void freePort()
throws OneWireException
freePort in class DSPortAdapterOneWireException - If port does not exist
public String getPortName()
throws OneWireException
String.getPortName in class DSPortAdapterString of selected portOneWireException - if valid port not yet selected
public boolean canOverdrive()
throws OneWireIOException,
OneWireException
canOverdrive in class DSPortAdaptertrue if this port adapter can do OverDrive,
false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canHyperdrive()
throws OneWireIOException,
OneWireException
canHyperdrive in class DSPortAdaptertrue if this port adapter can do HyperDrive,
false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canFlex()
throws OneWireIOException,
OneWireException
canFlex in class DSPortAdaptertrue if this port adapter can do flex speed,
false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canProgram()
throws OneWireIOException,
OneWireException
canProgram in class DSPortAdaptertrue if this port adapter can do Program voltage,
false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canDeliverPower()
throws OneWireIOException,
OneWireException
canDeliverPower in class DSPortAdaptertrue if this port adapter can do strong 5 volt
mode, false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canDeliverSmartPower()
throws OneWireIOException,
OneWireException
canDeliverSmartPower in class DSPortAdaptertrue if this port adapter can do "smart" strong
5 volt mode, false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean canBreak()
throws OneWireIOException,
OneWireException
canBreak in class DSPortAdaptertrue if this port adapter can do break,
false otherwise.OneWireIOException - on a 1-Wire communication error with the adapterOneWireException - on a setup error with the 1-Wire
adapter
public boolean findFirstDevice()
throws OneWireIOException,
OneWireException
true if the first iButton or 1-Wire device
is found on the 1-Wire Network.
If no devices are found, then false will be returned.findFirstDevice in class DSPortAdaptertrue if an iButton or 1-Wire device is found.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public boolean findNextDevice()
throws OneWireIOException,
OneWireException
true if the next iButton or 1-Wire device
is found. The previous 1-Wire device found is used
as a starting point in the search. If no more devices are found
then false will be returned.findNextDevice in class DSPortAdaptertrue if an iButton or 1-Wire device is found.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapterpublic void getAddress(byte[] address)
getAddress in class DSPortAdapteraddress - An array to be filled with the current iButton address.Addresspublic void setSearchOnlyAlarmingDevices()
setSearchOnlyAlarmingDevices in class DSPortAdaptersetNoResetSearch()public void setNoResetSearch()
setNoResetSearch in class DSPortAdapterpublic void setSearchAllDevices()
setSearchAllDevices in class DSPortAdaptersetNoResetSearch()public void targetAllFamilies()
targetAllFamilies in class DSPortAdaptertargetFamily(int),
targetFamily(byte[]),
excludeFamily(int),
excludeFamily(byte[])public void targetFamily(int family)
targetFamily in class DSPortAdapterfamily - the code of the family type to target for searchesAddress,
targetAllFamilies()public void targetFamily(byte[] family)
targetFamily in class DSPortAdapterfamily - array of the family types to target for searchesAddress,
targetAllFamilies()public void excludeFamily(int family)
excludeFamily in class DSPortAdapterfamily - the code of the family type NOT to target in searchesAddress,
targetAllFamilies()public void excludeFamily(byte[] family)
excludeFamily in class DSPortAdapterfamily - array of family cods NOT to target for searchesAddress,
targetAllFamilies()
public boolean beginExclusive(boolean blocking)
throws OneWireException
It can be called through the OneWireContainer class by the end application if they want to ensure exclusive use. If it is not called around several methods then it will be called inside each method.
beginExclusive in class DSPortAdapterblocking - true if want to block waiting
for an excluse access to the adaptertrue if blocking was false and a
exclusive session with the adapter was aquiredOneWireException - on a setup error with the 1-Wire adapterpublic void endExclusive()
endExclusive in class DSPortAdapter
public int reset()
throws OneWireIOException,
OneWireException
reset in class DSPortAdapterOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void putBit(boolean bitValue)
throws OneWireIOException,
OneWireException
putBit in class DSPortAdapterbitValue - the bit value to send to the 1-Wire Network.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public boolean getBit()
throws OneWireIOException,
OneWireException
getBit in class DSPortAdapterOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void putByte(int byteValue)
throws OneWireIOException,
OneWireException
putByte in class DSPortAdapterbyteValue - the byte value to send to the 1-Wire Network.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public int getByte()
throws OneWireIOException,
OneWireException
getByte in class DSPortAdapterOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public byte[] getBlock(int len)
throws OneWireIOException,
OneWireException
getBlock in class DSPortAdapterlen - length of data bytes to receiveOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void getBlock(byte[] arr,
int len)
throws OneWireIOException,
OneWireException
getBlock in class DSPortAdapterarr - array in which to write the received byteslen - length of data bytes to receiveOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void getBlock(byte[] arr,
int off,
int len)
throws OneWireIOException,
OneWireException
getBlock in class DSPortAdapterarr - array in which to write the received bytesoff - offset into the array to startlen - length of data bytes to receiveOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void dataBlock(byte[] dataBlock,
int off,
int len)
throws OneWireIOException,
OneWireException
dataBlock in class DSPortAdapterdataBlock - array of data to transfer to and from the 1-Wire Network.off - offset into the array of data to startlen - length of data to send / receive starting at 'off'OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void setPowerDuration(int timeFactor)
throws OneWireIOException,
OneWireException
Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.
setPowerDuration in class DSPortAdaptertimeFactor - OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public boolean startPowerDelivery(int changeCondition)
throws OneWireIOException,
OneWireException
Note: to avoid getting an exception, use the canDeliverPower() and canDeliverSmartPower() method to check it's availability.
startPowerDelivery in class DSPortAdapterchangeCondition - true if the voltage change was successful,
false otherwise.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public void setProgramPulseDuration(int timeFactor)
throws OneWireIOException,
OneWireException
Note: to avoid getting an exception, use the canDeliverPower() method to check it's availability.
setProgramPulseDuration in class DSPortAdaptertimeFactor - OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
public boolean startProgramPulse(int changeCondition)
throws OneWireIOException,
OneWireException
Note: to avoid getting an exception, use the canProgram() method to check it's availability.
startProgramPulse in class DSPortAdapterchangeCondition - true if the voltage change was successful,
false otherwise.OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
or the adapter does not support this operation
public void startBreak()
throws OneWireIOException,
OneWireException
startBreak in class DSPortAdapterOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
or the adapter does not support this operation
public void setPowerNormal()
throws OneWireIOException,
OneWireException
setPowerNormal in class DSPortAdapterOneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
or the adapter does not support this operation
public void setSpeed(int speed)
throws OneWireIOException,
OneWireException
setSpeed in class DSPortAdapterspeed - OneWireIOException - on a 1-Wire communication errorOneWireException - on a setup error with the 1-Wire adapter
or the adapter does not support this operationpublic int getSpeed()
getSpeed in class DSPortAdapterint representing the current 1-Wire speed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||