Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## josx.rcxcomm
Class LNP

    java.lang.Object
      java.lang.Thread
          josx.rcxcomm.LNP

All Implemented Interfaces:
  java.lang.Runnable

    public class LNP

extends java.lang.Thread

An interface for sending and receiving Lego Network Protocol addressing and integrity layer packets. It uses an integrity packet handler to send and receive integrity and addressing packet. Listeners can be registered to process incoming broadcasts of integrity packets or addressing packets on multiple ports. Currently assumes that the most significant nibble of the address byte is the machine and the least significant nibble is the port number. The machine addresses is defined by the startListening call, but is also part of the source address sent with addressing packets.

Nested Class Summary

Nested classes/interfaces inherited from class java.lang.Thread
`java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

Field Summary

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Method Summary
`static void` | `addAddressingHandler(AddressingHandler handler, byte port)` Register an integrity handler to process incoming addressing packets for a specific port.
`static void` | `addIntegrityHandler(IntegrityHandler handler)` Register an integrity handler to process incoming broadcasts
`static boolean` | `addressingWrite(byte[] packet, int len, byte dest, byte source)` Sends packet of up to 59 bytes to the destination address from the source address.
`static LNP` | `getLNP(java.lang.String port)`
`static boolean` | `integrityWrite(byte[] packet, int len)` Broadcasts an integrity packet of up to 61 bytes
`void` | `run()` Background thread to listen for incoming packets and call the appropriate listeners.
`static void` | `startListening(byte addr)` Start listening for incoming broadcasts and addressing packets.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getLNP

    public static LNP getLNP(java.lang.String port)

### addressingWrite

    public static boolean addressingWrite(byte[] packet,
                                          int len,
                                          byte dest,
                                          byte source)

  Sends packet of up to 59 bytes to the destination address from the source address. The source address is used for replying to the packet.

  Parameters:
    `packet` - the packet to send
    `len` - the length of the packet
    `dest` - the destination machine and port
    `source` - the source machine and address
  Returns:
    true for successful send, else false, e.g. for collision detection

### integrityWrite

    public static boolean integrityWrite(byte[] packet,
                                         int len)

  Broadcasts an integrity packet of up to 61 bytes

  Parameters:
    `packet` - the packet to broadcast
    `len` - the length of the packet
  Returns:
    true if sucessful, else false e.g. for collision detected

### addIntegrityHandler

    public static void addIntegrityHandler(IntegrityHandler handler)

  Register an integrity handler to process incoming broadcasts

  Parameters:
    `handler` - the integrity handler

### addAddressingHandler

    public static void addAddressingHandler(AddressingHandler handler,
                                            byte port)

  Register an integrity handler to process incoming addressing packets for a specific port.

  Parameters:
    `handler` - the addressing handler

### startListening

    public static void startListening(byte addr)

  Start listening for incoming broadcasts and addressing packets.

  Parameters:
    `addr` - the address of this machine. The least significant 4 bits should be zero.

### run

    public void run()

  Background thread to listen for incoming packets and call the appropriate listeners.

  Specified by:
    `run` in interface `java.lang.Runnable`
  Overrides:
    `run` in class `java.lang.Thread`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD