added experimental radio channel support

This commit is contained in:
fros4943 2006-10-11 15:13:57 +00:00
parent d2fd506d13
commit d0ec0a48a4
4 changed files with 27 additions and 6 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: radio-arch.c,v 1.9 2006/10/11 09:06:41 fros4943 Exp $ * $Id: radio-arch.c,v 1.10 2006/10/11 15:14:56 fros4943 Exp $
*/ */
#include "dev/radio-arch.h" #include "dev/radio-arch.h"
@ -61,7 +61,14 @@ int simOutSize;
char simRadioHWOn = 1; char simRadioHWOn = 1;
int simSignalStrength = -200; int simSignalStrength = -200;
char simPower = 100; char simPower = 100;
int simRadioChannel = 1;
/*-----------------------------------------------------------------------------------*/
void
radio_set_channel(int channel)
{
simRadioChannel = channel;
}
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
int int
radio_sstrength(void) radio_sstrength(void)

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiRadio.java,v 1.8 2006/10/09 13:41:57 fros4943 Exp $ * $Id: ContikiRadio.java,v 1.9 2006/10/11 15:14:30 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote.interfaces; package se.sics.cooja.contikimote.interfaces;
@ -64,6 +64,7 @@ import se.sics.cooja.interfaces.Radio;
* <li>char simRadioHWOn (radio hardware status (on/off)) * <li>char simRadioHWOn (radio hardware status (on/off))
* <li>int simSignalStrength (heard radio signal strength) * <li>int simSignalStrength (heard radio signal strength)
* <li>char simPower (number indicating power output) * <li>char simPower (number indicating power output)
* <li>int simRadioChannel
* </ul> * </ul>
* <p> * <p>
* Dependency core interfaces are: * Dependency core interfaces are:
@ -161,6 +162,10 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface {
return myMoteMemory.getIntValueOf("simInSize") != 0; return myMoteMemory.getIntValueOf("simInSize") != 0;
} }
public int getChannel() {
return myMoteMemory.getIntValueOf("simRadioChannel");
}
public RadioEvent getLastEvent() { public RadioEvent getLastEvent() {
return lastEvent; return lastEvent;
} }

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: Radio.java,v 1.4 2006/10/05 14:47:48 fros4943 Exp $ * $Id: Radio.java,v 1.5 2006/10/11 15:13:57 fros4943 Exp $
*/ */
package se.sics.cooja.interfaces; package se.sics.cooja.interfaces;
@ -145,4 +145,11 @@ public abstract class Radio extends MoteInterface {
*/ */
public abstract void setCurrentSignalStrength(double signalStrength); public abstract void setCurrentSignalStrength(double signalStrength);
/**
* Returns the current radio channel number.
*
* @return Current channel number
*/
public abstract int getChannel();
} }

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: StandardRadioMedium.java,v 1.7 2006/10/09 14:15:29 fros4943 Exp $ * $Id: StandardRadioMedium.java,v 1.8 2006/10/11 15:14:10 fros4943 Exp $
*/ */
package se.sics.cooja.radiomediums; package se.sics.cooja.radiomediums;
@ -394,7 +394,8 @@ public class StandardRadioMedium extends RadioMedium {
* (0.01 * (double) sendingRadio * (0.01 * (double) sendingRadio
.getCurrentOutputPowerIndicator()); .getCurrentOutputPowerIndicator());
if (distance <= moteTransmissionRange) { if (distance <= moteTransmissionRange
&& sendingRadio.getChannel() == listeningRadio.getChannel()) {
newConnection.addDestination(registeredRadios.get(listenNr), newConnection.addDestination(registeredRadios.get(listenNr),
registeredPositions.get(listenNr), dataToSend); registeredPositions.get(listenNr), dataToSend);
@ -410,7 +411,8 @@ public class StandardRadioMedium extends RadioMedium {
.getTransmissionEndTime()); .getTransmissionEndTime());
listeningRadio.setCurrentSignalStrength(SS_OK); listeningRadio.setCurrentSignalStrength(SS_OK);
} }
} else if (distance <= moteInterferenceRange) { } else if (distance <= moteInterferenceRange
&& sendingRadio.getChannel() == listeningRadio.getChannel()) {
// If close enough to sabotage other transmissions.. // If close enough to sabotage other transmissions..
listeningRadio.interferReception(sendingRadio listeningRadio.interferReception(sendingRadio
.getTransmissionEndTime()); .getTransmissionEndTime());