SunSPOT API V3.0


com.sun.spot.peripheral.ota
Class OTACommandServer

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.spot.peripheral.ota.OTACommandServer
All Implemented Interfaces:
ISpotAdminConstants, Runnable

public class OTACommandServer
extends Thread
implements ISpotAdminConstants

This class monitors radiogram communications on port number 8, and responds to commands received. These commands allow flashing the Spot's config page and/or applications remotely, retrieving the config page contents, and restarting the Spot.

Applications should never need to create an OTACommandServer explicitly. OTA is enabled or disabled for a SPOT using the ant command line facility.
To get access to the OTACommandServer use Spot.getInstance().getOTACommandServer()
See IOTACommandServerListener if you want to run an application in a separate thread concurrently with OTACommandServer, and you need to respond (for example, suspending) when flash operations start.


Field Summary
static int HARDWARE_MAJOR_REV_ESPOT
          Major version of the eSPOT hardware to report in response to HELLO_CMD
static String HELLO_CMD
          Command to respond information about the SPOT
static int HELLO_COMMAND_MINOR_VERSION
          Starting with (major) version 2, we support major/minor version numbering.
static int HELLO_COMMAND_VERSION
          Version of the HELLO_CMD that we support
static int PORT
          The radiostream port on which to listen for hosts connecting
static String START_OTA_SESSION_CMD
          Command that we recognise to start a new session
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.sun.spot.peripheral.ota.ISpotAdminConstants
ABORT_REQUEST, ADMIN_FLASH_OPERATION_FLOW_CONTROL_QUANTUM, BLINK_CMD, BOOTLOADER_CMD_ATTENTION, BOOTLOADER_CMD_HEADER, CHILD_ISOLATE_ECHO_PORT, CLOSEDOWN, DELETE_PUBLIC_KEY_CMD, ERROR_COMMAND_VERIFICATION_FAILED, ERROR_GENERAL, ERROR_UNKNOWN_COMMAND, FLASH_APP_CMD, FLASH_CONFIG_CMD, FLASH_LIB_CMD, GET_CONFIG_PAGE_CMD, GET_FILE_INFO_CMD, GET_SYSTEM_PROPERTIES, LOCAL_OTA_COMMAND_SERVER_IDENTIFICATION_STRING, MASTER_ISOLATE_ECHO_PORT, REMOTE_FLASH_OPERATION_FLOW_CONTROL_QUANTUM, REMOTE_OTA_COMMAND_SERVER_IDENTIFICATION_STRING, RESYNC_CMD, SET_CMD_LINE_PARAMS, SET_PUBLIC_KEY_CMD, SET_SYSTEM_PROPERTIES, SET_TIME_CMD, START_VM_CMD
 
Method Summary
 void addListener(IOTACommandServerListener sml)
          Attach a listener to be notified of the start and stop of flash operations.
 String getBaseStationAddress()
          Answer the IEEE address of the sender of the last command received.
static OTACommandServer getInstance()
           
 boolean isSuspended()
           
static void main(String[] args)
          Startup the OTACommandServer on a SPOT listening for OTA connections.
 void run()
          Should not be invoked from user code - call initialize() instead.
 void setSuspended(boolean suspended)
           
 Date timeOfLastMessageFromHost()
           
 
Methods inherited from class java.lang.Thread
activeCount, currentThread, getName, getPriority, interrupt, isAlive, join, setPriority, sleep, start, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PORT

public static final int PORT
The radiostream port on which to listen for hosts connecting

See Also:
Constant Field Values

START_OTA_SESSION_CMD

public static final String START_OTA_SESSION_CMD
Command that we recognise to start a new session

See Also:
Constant Field Values

HELLO_CMD

public static final String HELLO_CMD
Command to respond information about the SPOT

See Also:
Constant Field Values

HELLO_COMMAND_VERSION

public static final int HELLO_COMMAND_VERSION
Version of the HELLO_CMD that we support

See Also:
Constant Field Values

HELLO_COMMAND_MINOR_VERSION

public static final int HELLO_COMMAND_MINOR_VERSION
Starting with (major) version 2, we support major/minor version numbering. This lets us signal/detect changes that are backward compatible and those that aren't.

See Also:
Constant Field Values

HARDWARE_MAJOR_REV_ESPOT

public static final int HARDWARE_MAJOR_REV_ESPOT
Major version of the eSPOT hardware to report in response to HELLO_CMD

See Also:
Constant Field Values
Method Detail

main

public static void main(String[] args)
Startup the OTACommandServer on a SPOT listening for OTA connections.

Parameters:
args - ignored

getInstance

public static OTACommandServer getInstance()
                                    throws IOException
Returns:
Answer the singleton instance of this class
Throws:
IOException

addListener

public void addListener(IOTACommandServerListener sml)
Attach a listener to be notified of the start and stop of flash operations.

Parameters:
sml - the listener

getBaseStationAddress

public String getBaseStationAddress()
Answer the IEEE address of the sender of the last command received.

Returns:
-- the address

isSuspended

public boolean isSuspended()
Returns:
Returns true if the server has been suspended by software.

setSuspended

public void setSuspended(boolean suspended)
Parameters:
suspended - Suspends or resumes the server (it is initially running).

timeOfLastMessageFromHost

public Date timeOfLastMessageFromHost()
Returns:
The time when the server last received a message from the host

run

public void run()
Should not be invoked from user code - call initialize() instead.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Runnable.run()

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.