Sun SPOT API
Green Release  


com.sun.spot.peripheral
Class ConfigPage

java.lang.Object
  extended by com.sun.spot.peripheral.ConfigPage

public class ConfigPage
extends Object

Each Spot reserves some flash memory for configuration information. The ConfigPage class converts that information to and fro between a raw byte array and structured Java data.
The information is not held in normal Java streamed representations because the information must also be accessible from the C language bootstrap.

To obtain the current config page use:

Spot.getInstance().getConfigPage()


Field Summary
static int APP_SLOT_0_ADDRESS
           
static int APP_SLOT_1_ADDRESS
           
static int BOOTLOADER_ADDRESS
           
static int BOOTSTRAP_ADDRESS
           
static int BOOTSTRAP_ADDRESS_OFFSET
           
static int CMD_LINE_PARAMETERS_OFFSET
           
static int CONFIG_PAGE_ADDRESS
           
static int CONFIG_PAGE_SIZE
           
static int CONFIG_VERSION_OFFSET
           
static int CURRENT_CONFIG_VERSION
           
static int CURRENT_FLASH_TARGET_SLOT_OFFSET
           
static int CURRENT_SLOT_OFFSET
           
static int FLAGS_OFFSET
           
static int FLASH_BASE_ADDRESS
           
static int FLASH_SIZE_IN_BYTES
           
static byte HARDWARE_ESPOTP1
           
static byte HARDWARE_ESPOTP1A
           
static byte HARDWARE_ESPOTP2
           
static String[] HARDWARE_NAME
           
static String INITIAL_COMMAND_LINE
           
static int LIBRARY_ADDRESS
           
static int LIBRARY_ADDRESS_OFFSET
           
static int LIBRARY_SUITE_HASH_OFFSET
           
static int PUBLIC_KEY_OFFSET
           
static int SERIAL_NUMBER_OFFSET
           
static int SLOT_ADDRESSES_OFFSET
           
static int SLOT_COUNT_OFFSET
           
static int SUITE_VERIFIED_FLAG_SIZE
           
static int USER_FLASH_ADDRESS
           
static int VM_ADDRESS
           
static int VM_ADDRESS_OFFSET
           
 
Constructor Summary
ConfigPage()
          Create a newly initialized config page
ConfigPage(byte[] rawConfigPage)
          Create a config page from a byte array
 
Method Summary
 byte[] asByteArray()
          Create a byte[] representation of the config page
 int getAppSpace()
          Get the amount of memory allocated to each application slot
 int getBootloaderSpace()
          Get the amount of memory allocated to the bootloader
 byte getBootSlot()
           
 int getBootstrapAddress()
          Get the memory address of the bootstrap suite
 int getBootstrapSpace()
          Get the amount of memory allocated to the bootstrap suite
 String getCmdLineParams()
          Get the command line parameters used to start Squawk
 int getConfigSpace()
          Get the amount of memory allocated to the config page / properties
 int getConfigVersion()
          Get the version number of this page
 byte getCurrentFlashTargetSlot()
          Get the number of the slot that will be used for the next application flashing
 byte getCurrentSlot()
          Get the number of the slot that will be used at the next restart
 byte getHardwareType()
          Get the hardware type code for this SPOT
 int getImageSpace()
          Get the total amount of space allocated to a complete SPOT image (bootloader, vm, bootstrap, library and 2 applications).
 int getLibraryAddress()
          Get the memory address of the library suite
 int getLibraryHash()
           
 int getLibrarySpace()
          Get the amount of memory allocated to the library suite
 byte getNextFlashSlot()
           
 byte getNextSlot(byte slot)
           
 byte[] getPublicKey()
           
 int getSlotAddress(int index)
          Get the flash address associated with a particular slot
 byte getSlotCount()
          Get the number of slots
 String getSlotDescriptor(int slotNumber)
          Get the descriptive string for a slot
 int getSlotFileSize(int slotNumber)
          Get the size of the file stored in a slot
 long getTargetID()
          Get the serial number of the device
 int getVmAddress()
          Get the memory address of the VM executable
 int getVmSpace()
          Get the amount of memory allocated to the VM executable
 boolean isIgnoringApplicationSuite()
           
 boolean isSlowStartup()
           
 boolean isStartOTACommandServer()
           
 void reset()
           
 void setBootstrapAddress(int bootstrapAddress)
          Set the memory address of the bootstrap suite
 void setCmdLineParams(String params)
          Set the command line parameter string used to start Squawk
 void setCurrentFlashTargetSlot(byte currentFlashTargetSlot)
          Set the number of the slot that will be used for the next application flashing
 void setCurrentSlot(byte currentSlot)
          Set the number of the slot that will be used at the next restart
 void setHardwareType(byte hardwareType)
           
 void setIgnoreApplicationSuite(boolean shouldIgnoreApplicationSuite)
           
 void setLibraryAddress(int libraryAddress)
          Set the memory address of the library suite
 void setLibraryHash(int hash)
          Set the hash of the library suite installed on the SPOT
 void setPublicKey(byte[] key)
           
 void setSlotDescriptor(int slotNumber, String desc)
          Set the descriptive string for a slot
 void setSlotFileSize(int slotNumber, int fileSize)
          Set the size of the file stored in a slot
 void setSlowStartup(boolean startSlowly)
           
 void setStartOTACommandServer(boolean shouldStartOTACommandServer)
           
 void setTargetID(long targetID)
          Set the serial number of the device
 void setVmAddress(int vmAddress)
          Set the memory address of the VM executable
 void setWasLoaded(boolean b)
          For testing purposes only - not to be used
 boolean wasLoaded()
          Discover whether this config page was initialized by loading from a byte array or by initialization from default values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIAL_NUMBER_OFFSET

public static final int SERIAL_NUMBER_OFFSET
See Also:
Constant Field Values

CONFIG_VERSION_OFFSET

public static final int CONFIG_VERSION_OFFSET
See Also:
Constant Field Values

SLOT_COUNT_OFFSET

public static final int SLOT_COUNT_OFFSET
See Also:
Constant Field Values

CURRENT_SLOT_OFFSET

public static final int CURRENT_SLOT_OFFSET
See Also:
Constant Field Values

CURRENT_FLASH_TARGET_SLOT_OFFSET

public static final int CURRENT_FLASH_TARGET_SLOT_OFFSET
See Also:
Constant Field Values

FLAGS_OFFSET

public static final int FLAGS_OFFSET
See Also:
Constant Field Values

CMD_LINE_PARAMETERS_OFFSET

public static final int CMD_LINE_PARAMETERS_OFFSET
See Also:
Constant Field Values

VM_ADDRESS_OFFSET

public static final int VM_ADDRESS_OFFSET
See Also:
Constant Field Values

LIBRARY_ADDRESS_OFFSET

public static final int LIBRARY_ADDRESS_OFFSET
See Also:
Constant Field Values

BOOTSTRAP_ADDRESS_OFFSET

public static final int BOOTSTRAP_ADDRESS_OFFSET
See Also:
Constant Field Values

PUBLIC_KEY_OFFSET

public static final int PUBLIC_KEY_OFFSET
See Also:
Constant Field Values

LIBRARY_SUITE_HASH_OFFSET

public static final int LIBRARY_SUITE_HASH_OFFSET
See Also:
Constant Field Values

SLOT_ADDRESSES_OFFSET

public static final int SLOT_ADDRESSES_OFFSET
See Also:
Constant Field Values

CONFIG_PAGE_SIZE

public static final int CONFIG_PAGE_SIZE
See Also:
Constant Field Values

CURRENT_CONFIG_VERSION

public static final int CURRENT_CONFIG_VERSION
See Also:
Constant Field Values

INITIAL_COMMAND_LINE

public static final String INITIAL_COMMAND_LINE
See Also:
Constant Field Values

FLASH_BASE_ADDRESS

public static final int FLASH_BASE_ADDRESS
See Also:
Constant Field Values

BOOTLOADER_ADDRESS

public static final int BOOTLOADER_ADDRESS
See Also:
Constant Field Values

CONFIG_PAGE_ADDRESS

public static final int CONFIG_PAGE_ADDRESS
See Also:
Constant Field Values

VM_ADDRESS

public static final int VM_ADDRESS
See Also:
Constant Field Values

BOOTSTRAP_ADDRESS

public static final int BOOTSTRAP_ADDRESS
See Also:
Constant Field Values

LIBRARY_ADDRESS

public static final int LIBRARY_ADDRESS
See Also:
Constant Field Values

APP_SLOT_0_ADDRESS

public static final int APP_SLOT_0_ADDRESS
See Also:
Constant Field Values

APP_SLOT_1_ADDRESS

public static final int APP_SLOT_1_ADDRESS
See Also:
Constant Field Values

USER_FLASH_ADDRESS

public static final int USER_FLASH_ADDRESS
See Also:
Constant Field Values

FLASH_SIZE_IN_BYTES

public static final int FLASH_SIZE_IN_BYTES
See Also:
Constant Field Values

SUITE_VERIFIED_FLAG_SIZE

public static final int SUITE_VERIFIED_FLAG_SIZE
See Also:
Constant Field Values

HARDWARE_ESPOTP1

public static final byte HARDWARE_ESPOTP1
See Also:
Constant Field Values

HARDWARE_ESPOTP1A

public static final byte HARDWARE_ESPOTP1A
See Also:
Constant Field Values

HARDWARE_ESPOTP2

public static final byte HARDWARE_ESPOTP2
See Also:
Constant Field Values

HARDWARE_NAME

public static final String[] HARDWARE_NAME
Constructor Detail

ConfigPage

public ConfigPage(byte[] rawConfigPage)
Create a config page from a byte array

Parameters:
rawConfigPage - Byte array to use as input

ConfigPage

public ConfigPage()
Create a newly initialized config page

Method Detail

asByteArray

public byte[] asByteArray()
Create a byte[] representation of the config page

Returns:
The byte array

getConfigVersion

public int getConfigVersion()
Get the version number of this page


getSlotDescriptor

public String getSlotDescriptor(int slotNumber)
Get the descriptive string for a slot

Parameters:
slotNumber - The number of the slot to access
Returns:
The descriptive string

setSlotDescriptor

public void setSlotDescriptor(int slotNumber,
                              String desc)
Set the descriptive string for a slot

Parameters:
slotNumber - The number of the slot to update
desc - The descriptive string

getSlotFileSize

public int getSlotFileSize(int slotNumber)
Get the size of the file stored in a slot

Parameters:
slotNumber - The number of the slot to access
Returns:
The file size

setSlotFileSize

public void setSlotFileSize(int slotNumber,
                            int fileSize)
Set the size of the file stored in a slot

Parameters:
slotNumber - The number of the slot to update
fileSize - The file size

getCurrentSlot

public byte getCurrentSlot()
Get the number of the slot that will be used at the next restart

Returns:
The slot number

setCurrentSlot

public void setCurrentSlot(byte currentSlot)
Set the number of the slot that will be used at the next restart

Parameters:
currentSlot - The slot index to be used to run the application

getCurrentFlashTargetSlot

public byte getCurrentFlashTargetSlot()
Get the number of the slot that will be used for the next application flashing

Returns:
The slot number

setCurrentFlashTargetSlot

public void setCurrentFlashTargetSlot(byte currentFlashTargetSlot)
Set the number of the slot that will be used for the next application flashing

Parameters:
currentFlashTargetSlot - The slot index that will be used for the next flashing

getTargetID

public long getTargetID()
Get the serial number of the device

Returns:
The serial number

setTargetID

public void setTargetID(long targetID)
Set the serial number of the device

Parameters:
targetID - The id to be set

getHardwareType

public byte getHardwareType()
Get the hardware type code for this SPOT

Returns:
The hardwareType.

setHardwareType

public void setHardwareType(byte hardwareType)
Parameters:
hardwareType - The hardwareType to set.

getSlotAddress

public int getSlotAddress(int index)
Get the flash address associated with a particular slot

Parameters:
index - The slot number
Returns:
The memory address

getSlotCount

public byte getSlotCount()
Get the number of slots

Returns:
slot count

getCmdLineParams

public String getCmdLineParams()
Get the command line parameters used to start Squawk

Returns:
The parameter string

setCmdLineParams

public void setCmdLineParams(String params)
Set the command line parameter string used to start Squawk

Parameters:
params - The parameter string

getBootstrapAddress

public int getBootstrapAddress()
Get the memory address of the bootstrap suite

Returns:
The memory address

setBootstrapAddress

public void setBootstrapAddress(int bootstrapAddress)
Set the memory address of the bootstrap suite

Parameters:
bootstrapAddress - The memory address

getLibraryAddress

public int getLibraryAddress()
Get the memory address of the library suite

Returns:
The memory address

setLibraryAddress

public void setLibraryAddress(int libraryAddress)
Set the memory address of the library suite

Parameters:
libraryAddress - The memory address

getVmAddress

public int getVmAddress()
Get the memory address of the VM executable

Returns:
The memory address

setVmAddress

public void setVmAddress(int vmAddress)
Set the memory address of the VM executable

Parameters:
vmAddress - The memory address

getBootloaderSpace

public int getBootloaderSpace()
Get the amount of memory allocated to the bootloader

Returns:
Size in bytes

getConfigSpace

public int getConfigSpace()
Get the amount of memory allocated to the config page / properties

Returns:
Size in bytes

getVmSpace

public int getVmSpace()
Get the amount of memory allocated to the VM executable

Returns:
Size in bytes

getBootstrapSpace

public int getBootstrapSpace()
Get the amount of memory allocated to the bootstrap suite

Returns:
Size in bytes

getLibrarySpace

public int getLibrarySpace()
Get the amount of memory allocated to the library suite

Returns:
Size in bytes

getAppSpace

public int getAppSpace()
Get the amount of memory allocated to each application slot

Returns:
Size in bytes

getImageSpace

public int getImageSpace()
Get the total amount of space allocated to a complete SPOT image (bootloader, vm, bootstrap, library and 2 applications).

Returns:
size in bytes

wasLoaded

public boolean wasLoaded()
Discover whether this config page was initialized by loading from a byte array or by initialization from default values

Returns:
true if this config page was loaded from a byte array

setWasLoaded

public void setWasLoaded(boolean b)
For testing purposes only - not to be used

Parameters:
b -

setPublicKey

public void setPublicKey(byte[] key)

getPublicKey

public byte[] getPublicKey()

isSlowStartup

public boolean isSlowStartup()

setSlowStartup

public void setSlowStartup(boolean startSlowly)

getBootSlot

public byte getBootSlot()

reset

public void reset()

setStartOTACommandServer

public void setStartOTACommandServer(boolean shouldStartOTACommandServer)

isStartOTACommandServer

public boolean isStartOTACommandServer()

isIgnoringApplicationSuite

public boolean isIgnoringApplicationSuite()

setIgnoreApplicationSuite

public void setIgnoreApplicationSuite(boolean shouldIgnoreApplicationSuite)

getNextFlashSlot

public byte getNextFlashSlot()

getNextSlot

public byte getNextSlot(byte slot)

setLibraryHash

public void setLibraryHash(int hash)
Set the hash of the library suite installed on the SPOT

Parameters:
hash -

getLibraryHash

public int getLibraryHash()
Returns:
the hash of the library suite installed on the SPOT

Sun SPOT API
Green Release  


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