org.discotools.io.aprs.is
Class AprsIsProtocol

java.lang.Object
  extended by org.discotools.io.AbstractProtocol<T>
      extended by org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>
          extended by org.discotools.io.aprs.is.AprsIsProtocol
All Implemented Interfaces:
org.discotools.io.Protocol<AprsPacket>

public final class AprsIsProtocol
extends org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>

This class implements the client side of the APRS-IS protocol.

Author:
kengu

Field Summary
static String A_CLOSE
          AbstractConnection.close() action: The connection has been closed, which forces the protocol to S_IDLE state.
static String A_FILTER
          APRS-IS packet filter parameter name.
static String A_IDENTIFY
          APRS-IS identify request action name.
static String A_OPEN
          SocketConnection#open(org.discotools.io.IProtocol) action: The connection has been open, which forces the protocol to S_OPEN state.
static String A_RESPONSE
          APRS-IS response action: All APRS-IS server responses starts with the character '#'.
static String A_UNVERIFIED
          APRS-IS user unverified action: All APRS-IS server unverified login responses should match the regexp '^#.
static String A_VERIFIED
          APRS-IS user verified action: All APRS-IS server verified login responses should match the regexp '^#.
static String A_VERSION
          APRS-IS software version parameter name.
static String C_FILTER
          APRS-IS filter command: 'filter <filter>'
static String C_IDENTIFY
          APRS-IS identify command: 'user <username> pass <passcode> [<command>]'
static String C_VERSION
          APRS-IS software version command: 'vers <name> <version>'
static String L_IDENTIFY
          APRS-IS identify request action label.
static String L_RESPONSE
          A_RESPONSE action label.
static Pattern P_FILTER
          Regexp Pattern for parsing C_FILTER command.
static Pattern P_IDENTIFY
          Regexp Pattern for matching A_IDENTIFY action.
static Pattern P_RESPONSE
          Regexp Pattern for matching A_RESPONSE actions.
static Pattern P_UNVERIFIED
          Regexp Pattern for matching A_UNVERIFIED actions.
static Pattern P_VERIFIED
          Regexp Pattern for matching A_VERIFIED actions.
static Pattern P_VERSION
          Regexp Pattern for parsing C_VERSION command.
static String S_IDLE
          APRS-IS idle state: SocketConnection is closed.
static String S_OPEN
          APRS-IS idle state: SocketConnection is open.
static String S_UNVERIFIED
          APRS-IS unverified state: User has identified itself with a passcode not verified by the APRS-IS server (typical: -1).
static String S_VERIFIED
          APRS-IS verified state: User has identified itself with a passcode verified by the APRS-IS server (typical: -1).
static String S_WAITING
          APRS-IS waiting state: User has issued a command and is waiting for APRS-IS server response.
 
Fields inherited from class org.discotools.io.fsm.FsmProtocol
common, parser, S_COMMON
 
Fields inherited from class org.discotools.io.AbstractProtocol
DEFAULT_SIZE, head, isOpen, rb, size, tail, tb
 
Constructor Summary
AprsIsProtocol()
          Default constructor
AprsIsProtocol(AprsCache cache)
          Cache constructor
 
Method Summary
 void addListener(AprsCacheListener listener)
           
 boolean addListener(org.discotools.fsm.event.FsmListener listener)
          Add FsmListener to APRS-IS Finite State Machine instance
protected  org.discotools.fsm.Fsm createFsm(org.discotools.io.fsm.FsmProtocolState idle)
          Create APRS-IS FSM instance.
protected  org.discotools.io.fsm.FsmProtocolState createState(String name, boolean isParseable)
           
 AprsCache getCache()
           
 AprsIsParams getParams()
          Get copy of current AprsIsParams instance.
protected  boolean handle(org.discotools.io.Connection<AprsPacket> connection, String tokens, boolean inbound, Object... params)
           
protected  void internalClose(org.discotools.io.Connection<AprsPacket> connection)
           
protected  boolean internalOpen(org.discotools.io.Connection<AprsPacket> connection, Map<String,? extends Object> options)
           
 void removeListener(AprsCacheListener listener)
           
 boolean removeListener(org.discotools.fsm.event.FsmListener listener)
          Remove FsmListener from APRS-IS Finite State Machine instance
 AprsIsParams setParams(AprsIsParams params)
          Replace current AprsIsParams instance.
 
Methods inherited from class org.discotools.io.fsm.FsmProtocol
getCurrentState, getFsm, getParser, internalParse, merge, setFsm, toState
 
Methods inherited from class org.discotools.io.AbstractProtocol
addListener, assertClose, assertOpen, close, fireOnReceive, fireOnTransmit, getListeners, internalReceive, internalTransmit, isHead, isOpen, isTail, open, open, receive, receive, receive, receive, receive, removeListener, toBytes, toBytes, toString, transmit, transmit, transmit, transmit, transmit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_IDLE

public static final String S_IDLE
APRS-IS idle state: SocketConnection is closed.

See Also:
Constant Field Values

A_CLOSE

public static final String A_CLOSE
AbstractConnection.close() action: The connection has been closed, which forces the protocol to S_IDLE state.

See Also:
Constant Field Values

S_OPEN

public static final String S_OPEN
APRS-IS idle state: SocketConnection is open.

See Also:
Constant Field Values

A_OPEN

public static final String A_OPEN
SocketConnection#open(org.discotools.io.IProtocol) action: The connection has been open, which forces the protocol to S_OPEN state.

See Also:
Constant Field Values

S_WAITING

public static final String S_WAITING
APRS-IS waiting state: User has issued a command and is waiting for APRS-IS server response.

See Also:
Constant Field Values

S_UNVERIFIED

public static final String S_UNVERIFIED
APRS-IS unverified state: User has identified itself with a passcode not verified by the APRS-IS server (typical: -1).

In this state, the APRS-IS server does not allow the protocol to transmit anything to the APRS-IS network. Only verified users are allowed to transmit data.

See Also:
Constant Field Values

S_VERIFIED

public static final String S_VERIFIED
APRS-IS verified state: User has identified itself with a passcode verified by the APRS-IS server (typical: -1).

In this state, the APRS-IS server allow the protocol to transmit data to the APRS-IS network.

If the protocol is part of an IGate implementation, the IGate is only able to pass packets from RF to APRS-IS in in verified state.

See Also:
Constant Field Values

A_IDENTIFY

public static final String A_IDENTIFY
APRS-IS identify request action name.

See Also:
Constant Field Values

L_IDENTIFY

public static final String L_IDENTIFY
APRS-IS identify request action label.

See Also:
Constant Field Values

C_IDENTIFY

public static final String C_IDENTIFY
APRS-IS identify command: 'user <username> pass <passcode> [<command>]'

See Also:
Constant Field Values

P_IDENTIFY

public static final Pattern P_IDENTIFY
Regexp Pattern for matching A_IDENTIFY action.


A_VERSION

public static final String A_VERSION
APRS-IS software version parameter name.

See Also:
Constant Field Values

C_VERSION

public static final String C_VERSION
APRS-IS software version command: 'vers <name> <version>'

See Also:
Constant Field Values

P_VERSION

public static final Pattern P_VERSION
Regexp Pattern for parsing C_VERSION command.


A_FILTER

public static final String A_FILTER
APRS-IS packet filter parameter name.

See Also:
Constant Field Values

C_FILTER

public static final String C_FILTER
APRS-IS filter command: 'filter <filter>'

See Also:
Constant Field Values

P_FILTER

public static final Pattern P_FILTER
Regexp Pattern for parsing C_FILTER command.


A_RESPONSE

public static final String A_RESPONSE
APRS-IS response action: All APRS-IS server responses starts with the character '#'.

See Also:
Constant Field Values

P_RESPONSE

public static final Pattern P_RESPONSE
Regexp Pattern for matching A_RESPONSE actions.


L_RESPONSE

public static final String L_RESPONSE
A_RESPONSE action label.

See Also:
Constant Field Values

A_VERIFIED

public static final String A_VERIFIED
APRS-IS user verified action: All APRS-IS server verified login responses should match the regexp '^#.*logresp.*verified.*'.

See Also:
Constant Field Values

P_VERIFIED

public static final Pattern P_VERIFIED
Regexp Pattern for matching A_VERIFIED actions.


A_UNVERIFIED

public static final String A_UNVERIFIED
APRS-IS user unverified action: All APRS-IS server unverified login responses should match the regexp '^#.*logresp.*unverified.*'.

See Also:
Constant Field Values

P_UNVERIFIED

public static final Pattern P_UNVERIFIED
Regexp Pattern for matching A_UNVERIFIED actions.

Constructor Detail

AprsIsProtocol

public AprsIsProtocol()
Default constructor


AprsIsProtocol

public AprsIsProtocol(AprsCache cache)
Cache constructor

Method Detail

getCache

public AprsCache getCache()

addListener

public void addListener(AprsCacheListener listener)

removeListener

public void removeListener(AprsCacheListener listener)

getParams

public AprsIsParams getParams()
Get copy of current AprsIsParams instance.

NOTE: Change parameters on this instance and apply them to the protocol using setParams(AprsIsParams).


setParams

public AprsIsParams setParams(AprsIsParams params)
Replace current AprsIsParams instance.

Returns:
replaced instance of AprsIsParams.

addListener

public boolean addListener(org.discotools.fsm.event.FsmListener listener)
Add FsmListener to APRS-IS Finite State Machine instance

Overrides:
addListener in class org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>
Parameters:
listener -
Returns:
true if added.

removeListener

public boolean removeListener(org.discotools.fsm.event.FsmListener listener)
Remove FsmListener from APRS-IS Finite State Machine instance

Overrides:
removeListener in class org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>
Parameters:
listener -
Returns:
true if added.

handle

protected boolean handle(org.discotools.io.Connection<AprsPacket> connection,
                         String tokens,
                         boolean inbound,
                         Object... params)
                  throws org.discotools.fsm.FsmException
Overrides:
handle in class org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>
Throws:
org.discotools.fsm.FsmException

createState

protected org.discotools.io.fsm.FsmProtocolState createState(String name,
                                                             boolean isParseable)
Overrides:
createState in class org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>

createFsm

protected org.discotools.fsm.Fsm createFsm(org.discotools.io.fsm.FsmProtocolState idle)
Create APRS-IS FSM instance.

NOTE: Following parseable states share receive and transmit buffers.

  1. S_OPEN
  2. S_WAITING
  3. S_VERIFIED
  4. S_UNVERIFIED
which enables this protocol to parse payload into AprsPacket regardless of protocol state, except in S_IDLE.

Overrides:
createFsm in class org.discotools.io.fsm.FsmProtocol<AprsPacket,AprsIsParser>

internalOpen

protected boolean internalOpen(org.discotools.io.Connection<AprsPacket> connection,
                               Map<String,? extends Object> options)
                        throws IOException
Overrides:
internalOpen in class org.discotools.io.AbstractProtocol<AprsPacket>
Throws:
IOException

internalClose

protected void internalClose(org.discotools.io.Connection<AprsPacket> connection)
                      throws IOException
Overrides:
internalClose in class org.discotools.io.AbstractProtocol<AprsPacket>
Throws:
IOException


Copyright © 2012-2013 DISCO Foundation. All Rights Reserved.