added simple surrounding signal strength checking before transmitting
This commit is contained in:
parent
5b66565c86
commit
774b977fe9
|
@ -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.6 2006/10/06 10:45:53 fros4943 Exp $
|
* $Id: radio-arch.c,v 1.7 2006/10/09 14:13:04 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dev/radio-arch.h"
|
#include "dev/radio-arch.h"
|
||||||
|
@ -44,6 +44,9 @@
|
||||||
|
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
|
|
||||||
|
#define MAX_RETRIES 50
|
||||||
|
#define SS_INTERFERENCE -150
|
||||||
|
|
||||||
const struct simInterface radio_interface;
|
const struct simInterface radio_interface;
|
||||||
|
|
||||||
// COOJA variables
|
// COOJA variables
|
||||||
|
@ -56,7 +59,7 @@ char simOutDataBuffer[UIP_BUFSIZE];
|
||||||
int simOutSize;
|
int simOutSize;
|
||||||
|
|
||||||
char simRadioHWOn = 1;
|
char simRadioHWOn = 1;
|
||||||
int simSignalStrength = 0;
|
int simSignalStrength = -200;
|
||||||
char simPower = 100;
|
char simPower = 100;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -145,28 +148,25 @@ simDoSend(void)
|
||||||
simOutSize = uip_len;
|
simOutSize = uip_len;
|
||||||
|
|
||||||
// Busy-wait while we are receiving
|
// Busy-wait while we are receiving
|
||||||
if (simReceiving && simInsideProcessRun) {
|
if (simReceiving && !simNoYield) {
|
||||||
cooja_mt_yield();
|
cooja_mt_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Busy-wait until ether is ready, or die (MAC imitation)
|
// Busy-wait until ether is ready, or die (MAC imitation)
|
||||||
int retries=0;
|
int retries=0;
|
||||||
/* while (retries < 5 && simSignalStrength > -80) {
|
while (retries < MAX_RETRIES && simSignalStrength > SS_INTERFERENCE && !simNoYield) {
|
||||||
// TODO Retry and signal strength threshold values?
|
retries++;
|
||||||
retries++;
|
cooja_mt_yield();
|
||||||
printf("WAITING FOR ETHER! (null)\n");
|
|
||||||
cooja_mt_yield();
|
|
||||||
}
|
}
|
||||||
if (simSignalStrength > -80) {
|
if (simSignalStrength > SS_INTERFERENCE) {
|
||||||
return UIP_FW_DROPPED;
|
return UIP_FW_DROPPED;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// - Initiate transmission -
|
// - Initiate transmission -
|
||||||
simTransmitting = 1;
|
simTransmitting = 1;
|
||||||
|
|
||||||
// Busy-wait while transmitting
|
// Busy-wait while transmitting
|
||||||
if (simTransmitting && simInsideProcessRun) {
|
if (simTransmitting && !simNoYield) {
|
||||||
cooja_mt_yield();
|
cooja_mt_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue