SunSPOTs


Overview

Material taken from the SunSPOT FAQ page: http://www.sunspotworld.com/docs/general-faq.php

Mobile Information Device Profile (MIDP)/ Connected Limited Device Configuration (CLDC)

Image: http://java.sun.com/javame/technology/index.jsp
midp

MIDlets

All of your SPOT applications will extend javax.microedition.midlet.MIDlet.  As a result, all applications must implement the following methods. The startApp method will contain the main logic of your program.  Following is an example:
package org.sunspotworld.demo;

import com.sun.spot.sensorboard.EDemoBoard;

import com.sun.spot.sensorboard.peripheral.ITriColorLED;
import com.sun.spot.sensorboard.peripheral.LEDColor;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class HelloWorld extends MIDlet {

    private ITriColorLED leds[] = EDemoBoard.getInstance().getLEDs();

    protected void startApp() throws MIDletStateChangeException {
        System.out.println("Hello, world!");
        for (int i = 0; i < leds.length; i++) {
            leds[i].setColor(LEDColor.BLUE);
            leds[i].setOn();
        }
    }

    /**
     * This will never be called by the Squawk VM.
     */
    protected void pauseApp() {
        // This will never be called by the Squawk VM
    }

    /**
     * Called if the MIDlet is terminated by the system.
     * I.e. if startApp throws any exception other than MIDletStateChangeException,
     * if the isolate running the MIDlet is killed with Isolate.exit(), or
     * if VM.stopVM() is called.
     *
     * It is not called if MIDlet.notifyDestroyed() was called.
     *
     * @param unconditional If true when this method is called, the MIDlet must
     *    cleanup and release all resources. If false the MIDlet may throw
     *    MIDletStateChangeException  to indicate it does not want to be destroyed
     *    at this time.
     */
    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    }

}

Running a Program

Linux Setup

Other SPOT Information


Sami Rollins

Date: 2008-03-27