public class Eiscp extends Object
Modifier and Type | Field and Description |
---|---|
private static boolean |
classInit
Class flag signifying if the initUtil method has been called
|
private static String |
CLASSNAME
A holder This classes name (used when logging).
|
static String |
CLASSPATH
The VM classpath (used in some methods)..
|
private static HashMap<Integer,String> |
commandMap_
Maps the class contant vars to the eiscp command string.
|
private static HashMap<String,Integer> |
commandNameMap_
Maps a Readable string to a corresponding class var.
|
private static boolean |
connected_ |
private static boolean |
debugging_
Class flag signifying if debugging_ messages are ptinted
|
private static String |
DEFAULT_EISCP_IP
default receiver IP Address.
|
private static int |
DEFAULT_EISCP_PORT
default eISCP port.
|
private static Socket |
eiscpSocket_
the socket for communication - the protocol spec says to use one socket connection AND HOLD ONTO IT for re-use.
|
private static StringBuffer |
helpMsg_ |
private static DataInputStream |
in_ |
private static IscpCommands |
iscp_ |
private static ObjectOutputStream |
out_ |
private String |
receiverIP_
Instantiated class IP for the receiver to communicate with.
|
private int |
receiverPort_
Instantiated class Port for the receiver to communicate with.
|
private static int |
socketTimeOut_
the timeout in ms for socket reads.
|
static String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator.
|
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
static String |
USERDIR
The users pwd ditrectory.
|
static String |
USERHOME
The users home ditrectory.
|
private static int |
volume_
Var to hold the volume level to or from a message.
|
Constructor and Description |
---|
Eiscp()
Simple class Constructor (using deafult IP and port) that gets all the class command constants set-up along with their command lookup maps (commandNameMap_ and commandMap_) .
|
Eiscp(String ip)
Constructor that takes your receivers ip and default port, gets all the class command
constants set-up along with their command lookup maps (commandNameMap_ and commandMap_) .
|
Eiscp(String ip,
int eiscpPort)
Constructor that takes your receivers ip and port, gets all the class command
constants set-up along with their command lookup maps (commandNameMap_ and commandMap_) .
|
Modifier and Type | Method and Description |
---|---|
boolean |
closeSocket()
Closes the socket connection.
|
boolean |
connectSocket()
Connects to the receiver by opening a socket connection through the DEFaULT IP and DEFAULT eISCP port.
|
boolean |
connectSocket(String ip)
Connects to the receiver by opening a socket connection through the DEFAULT eISCP port.
|
boolean |
connectSocket(String ip,
int eiscpPort)
Connects to the receiver by opening a socket connection through the eISCP port.
|
static String |
convertAsciiToBase10(String str) |
static String |
convertAsciiToBase10(String str,
boolean dumpOut) |
static int |
convertHexNumberStringToDecimal(String str)
Converts an HEX number String to its decimal equivalent.
|
static int |
convertHexNumberStringToDecimal(String str,
boolean dumpOut)
Converts an HEX number String to its decimal equivalent.
|
static String |
convertHexToString(byte hex)
Converts a hex byte to an ascii String.
|
static String |
convertHexToString(String hex)
Converts a hex String to an ascii String.
|
static String |
convertHexToString(String hex,
boolean dumpOut)
Converts a hex String to an ascii String.
|
static String |
convertStringToHex(String str)
Converts an ascii decimal String to a hex String.
|
static String |
convertStringToHex(String str,
boolean dumpOut)
Converts an ascii decimal String to a hex String.
|
static String |
deciherSourceResponseToString(String queryResponses)
Converts the SOURCE_QUERY response into ascii string result.
|
static String |
deciherVolumeResponseToDecimal(String queryResponses)
Converts the VOLUME_QUERY response into ascii decimal result.
|
static String |
deciherVolumeResponseToHex(String queryResponses)
Converts the VOLUME_QUERY response into ascii hex result.
|
String |
decipherNetUsbResponse(int command,
String queryResponses)
Converts the response packets into a JSON result.
|
String |
decipherUsbPlayStatusResponse(String queryResponses)
This method takes the 3 character response from the USB Play status query (NETUSB_PLAY_STATUS_QUERY) and creates a human readable String.
|
static String |
decipherVolumeResponse(String queryResponses)
Converts the VOLUME_QUERY response into ascii decimal result.
|
void |
dumpBinaryMessages()
dumps all the commands to System.out along with its associated eIscp message string in BASE10 numbers.
|
static String |
getCommandList()
returns a text list of all the commands.
|
StringBuilder |
getEiscpMessage(int command)
Wraps a command in a eiscp data message (data characters).
|
StringBuilder |
getEiscpMessage(int command,
String param) |
private static StringBuffer |
getHelpMsg()
initializes and gets the helpMsg_
class var.
|
private static String |
getHelpMsgStr()
gets the help as a String.
|
String |
getReceiverIP()
Makes Sprinkle doughnuts.
|
int |
getReceiverPort()
Makes glazed doughnuts.
|
static String |
getTuneFreqCmdStr(String freqStr)
This method creates the set volume command based on the passed value.
|
int |
getVolume()
get the class volume_.
|
static String |
getVolumeCmdStr()
This method creates the set volume command based on the passed value.
|
static String |
getVolumeCmdStr(int vol) |
boolean |
isConnected() |
static void |
main(String[] args)
Class main commandLine entry method.
|
Vector<String> |
readQueryResponses()
This method reads ALL responses (possibly more than one) after a query command.
|
Vector<String> |
readQueryResponses(int command)
This method reads responses (possibly more than one) after a query command.
|
void |
sendCommand(int command)
Sends to command to the receiver and does not wait for a reply.
|
void |
sendCommand(int command,
String param)
Sends to command to the receiver and does not wait for a reply.
|
void |
sendCommand(int command,
String param,
boolean closeSocket)
Sends to command to the receiver and does not wait for a reply.
|
void |
sendCommandMultipleTimes(int command,
int numRepeats)
Sends to command ultiple times sequentially to the receiver and WAITS until each is completed and
hold the door open for the next doughnut customer , after we leave.
|
void |
sendCommandMultipleTimes(int command,
int numRepeats,
boolean closeSocketWhenDone)
Sends to command ultiple times sequentially to the receiver and WAITS until each is completed.
|
String |
sendQueryCommand(int command)
Sends to command to the receiver and then waits for the response(s)
and returns only the response packetMessages related to the command requested and closes the socket. |
String |
sendQueryCommand(int command,
boolean closeSocket)
Sends to command to the receiver and then waits for the response(s)
and returns only the response packetMessages related to the command requested. |
String |
sendQueryCommand(int command,
boolean closeSocket,
boolean returnAll)
Sends to command to the receiver and then waits for the response(s).
|
void |
setReceiverIP(String ip)
Makes Chocolate glazed doughnuts.
|
void |
setReceiverPort(int port)
Makes mini doughnuts.
|
void |
setVolume(int volume)
sets the class volume_ AND sends the VOLUME_SET command to the Onkyo device.
|
boolean |
sleep(long waitTime)
A method to simply abstract the Try/Catch required to put the current
thread to sleep for the specified time in ms.
|
boolean |
testConnection()
Tests the Connection to the receiver by opening a socket connection through the DEFaULT IP and DEFAULT eISCP port.
|
boolean |
testConnection(String ip)
Tests the Connection to the receiver by opening a socket connection through the specified IP and DEFAULT eISCP port.
|
boolean |
testConnection(String ip,
int eiscpPort)
test the connection to the receiver by opening a socket connection through the eISCP port AND THEN CLOSES it if it was not already open.
|
void |
toggleMute()
Toggles the MUTE setting..
|
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
private static boolean classInit
private static boolean debugging_
private static final String DEFAULT_EISCP_IP
private String receiverIP_
private static final int DEFAULT_EISCP_PORT
private int receiverPort_
private static Socket eiscpSocket_
private static int socketTimeOut_
private static ObjectOutputStream out_
private static DataInputStream in_
private static boolean connected_
private static IscpCommands iscp_
private static HashMap<Integer,String> commandMap_
private static HashMap<String,Integer> commandNameMap_
private static int volume_
private static StringBuffer helpMsg_
public Eiscp()
public Eiscp(String ip)
public void setReceiverIP(String ip)
public String getReceiverIP()
public void setReceiverPort(int port)
public int getReceiverPort()
public boolean connectSocket()
public boolean connectSocket(String ip)
public boolean connectSocket(String ip, int eiscpPort)
public boolean isConnected()
public boolean testConnection()
public boolean testConnection(String ip)
ip
- is the ip address (as a String) of the AV receiver to connectpublic boolean testConnection(String ip, int eiscpPort)
testConnection
method (that used the default port) or the testConnection
method (that used the default IP and port).ip
- is the ip address (as a String) of the AV receiver to connecteiscpPort
- is the IP Port of the AV receiver to connect with (Onkyo's default is 60128)public boolean closeSocket()
public static String convertAsciiToBase10(String str)
public static String convertAsciiToBase10(String str, boolean dumpOut)
public static String convertStringToHex(String str)
str
- holding the string to convert to HEXpublic static String convertStringToHex(String str, boolean dumpOut)
str
- holding the string to convert to HEXdumpOut
- flag to turn some debug output on/offpublic static int convertHexNumberStringToDecimal(String str)
str
- holding the Hex Number string to convert to decimalpublic static int convertHexNumberStringToDecimal(String str, boolean dumpOut)
str
- holding the Hex Number string to convert to decimaldumpOut
- boolean flag to turn some debug output on/offpublic static String convertHexToString(byte hex)
hex
- byte holding the HEX string to convert back to decimalpublic static String convertHexToString(String hex)
hex
- the HEX string to convert back to decimalpublic static String convertHexToString(String hex, boolean dumpOut)
hex
- the HEX string to convert backk to decimaldumpOut
- boolean flag to turn some debug output on/offpublic StringBuilder getEiscpMessage(int command)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.public StringBuilder getEiscpMessage(int command, String param)
public void dumpBinaryMessages()
public void sendCommandMultipleTimes(int command, int numRepeats, boolean closeSocketWhenDone)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.numRepeats
- how many doughnuts to buy.closeSocketWhenDone
- do we hold the door open for the next doughnut customer , after we leavepublic void sendCommandMultipleTimes(int command, int numRepeats)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.numRepeats
- how many doughnuts to buy.public void sendCommand(int command)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.public void sendCommand(int command, String param)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.public void sendCommand(int command, String param, boolean closeSocket)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.param
- paramater to customize a command Str for VOLUME_SET ?? or TUNING_FREQ ?????closeSocket
- flag to close the connection when done or leave it open.public String sendQueryCommand(int command)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.public String sendQueryCommand(int command, boolean closeSocket)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.closeSocket
- flag to close the connection when done or leave it open.public String sendQueryCommand(int command, boolean closeSocket, boolean returnAll)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.closeSocket
- flag to close the connection when done or leave it open.returnAll
- flags if all response packetMessages are returned, if no then ONLY the ones related to the command requestedpublic Vector<String> readQueryResponses()
public Vector<String> readQueryResponses(int command)
command
- is used to end the response processing early when it finds the command - if you want all responses processed pass in -1public static String getVolumeCmdStr()
public static String getVolumeCmdStr(int vol)
public static String getTuneFreqCmdStr(String freqStr)
public static String decipherVolumeResponse(String queryResponses)
public static String deciherSourceResponseToString(String queryResponses)
public static String deciherVolumeResponseToDecimal(String queryResponses)
public static String deciherVolumeResponseToHex(String queryResponses)
public String decipherUsbPlayStatusResponse(String queryResponses)
queryResponses
- is the entire response packet with the oneOf3 char reply embedded in it.public String decipherNetUsbResponse(int command, String queryResponses)
public boolean sleep(long waitTime)
waitTime
- the sleep time in milli seconds (ms).private static String getHelpMsgStr()
private static StringBuffer getHelpMsg()
public static String getCommandList()
public int getVolume()
public void setVolume(int volume)
volume
- the DECIMAL value to set the class volume_ and MUST be volume<99 && volume>-1public void toggleMute()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses