using new radio packet format and some documentation

This commit is contained in:
fros4943 2008-03-18 13:05:23 +00:00
parent 4fc082db35
commit 84d2353966
1 changed files with 22 additions and 12 deletions

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: AbstractApplicationMote.java,v 1.1 2007/05/31 07:21:29 fros4943 Exp $
* $Id: AbstractApplicationMote.java,v 1.2 2008/03/18 13:05:23 fros4943 Exp $
*/
package se.sics.cooja.motes;
@ -39,6 +39,13 @@ import se.sics.cooja.interfaces.ApplicationRadio;
import se.sics.cooja.interfaces.Position;
import se.sics.cooja.interfaces.Radio;
/**
* Abstract application mote.
*
* Simplifies implementation of application level mote types.
*
* @author Fredrik Osterlind
*/
public abstract class AbstractApplicationMote implements Mote {
private static Logger logger = Logger.getLogger(AbstractApplicationMote.class);
@ -60,14 +67,16 @@ public abstract class AbstractApplicationMote implements Mote {
};
public void handleNewRadioData(Observable obs, Object obj) {
if (myApplicationRadio.getLastEvent() != Radio.RadioEvent.RECEPTION_FINISHED)
if (myApplicationRadio.getLastEvent() != Radio.RadioEvent.RECEPTION_FINISHED) {
return;
}
logger.info("Application mote received radio data:");
byte[] packet = myApplicationRadio.getLastPacketReceived();
byte[] packet = myApplicationRadio.getLastPacketReceived().getPacketData();
String data = "";
for (byte b: packet)
for (byte b: packet) {
data += (char)b;
}
logger.info(data);
}
@ -218,8 +227,9 @@ public abstract class AbstractApplicationMote implements Mote {
public String toString() {
if (getInterfaces().getMoteID() != null) {
return "Application Mote, ID=" + getInterfaces().getMoteID().getMoteID();
} else
} else {
return "Application Mote, ID=null";
}
}
}