com.github.sdnwiselab.sdnwise.packet.BeaconPacket Maven / Gradle / Ivy
/*
* Copyright (C) 2015 SDN-WISE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.github.sdnwiselab.sdnwise.packet;
/**
*
* @author SDN-WISE
*/
public class BeaconPacket extends NetworkPacket{
public BeaconPacket(byte[] data) {
super(data);
}
public BeaconPacket() {
super();
this.setType(SDN_WISE_BEACON);
}
public BeaconPacket(int[] data) {
super(data);
}
/**
* Returns the number of hops between the source node and the sink. This is
* a beacon/report message field only.
*
* @return the number of hops between the source node and the sink
*/
public int getDist() {
return this.getPayloadAt(0) & 0xFF;
}
public NetworkPacket setDist(byte value) {
this.setPayloadAt(value, 0);
return this;
}
/**
* Returns an extimation of the residual charge of the batteries of the
* node. This is a beacon/report message field only. [0-255] 0 = no charge,
* 255 = full charge.
*
* @return an extimation of the residual charge of the batteries of the node
*/
public int getBatt() {
return this.getPayloadAt(1) & 0xFF;
}
public NetworkPacket setBatt(byte value) {
this.setPayloadAt(value, 1);
return this;
}
}