[Tinyos-help] Automatic TX Power Setting
Ittipong Khemapech
ik.tinyos at googlemail.com
Tue Mar 11 08:59:54 PDT 2008
Hi,
I am working on automatic TX power setting. I have the following codes:
implementation {
message_t pkt;
bool busy = FALSE; // Used to check if mote is still busy
sending
uint16_t sentpkts = 0; // Number of sent packets
uint8_t current_tx; // Used to adapt transmission power,
start with the minimum level
uint8_t i; // Used to count number of
transmissions
.......
event void MetricsSendTimer.fired() {
if (!busy) {
MetricsMsg* metricsMsg = (MetricsMsg*)(call Packet.getPayload(&pkt,
NULL));
// Allowable tx power levels are 3, 7, 11, 15, 19, 23, 27 and 31
for (current_tx = 3; current_tx <= 31; current_tx += 4) {
// Mote sends 20 times for each tx power level
for (i = 1; i <= 20; i++) {
call CC2420Packet.setPower(&pkt, current_tx);
current_tx = call CC2420Packet.getPower(&pkt);
// Write current tx and no of sent pkts to the payload
metricsMsg->txpower = current_tx;
metricsMsg->pkt_no = sentpkts;
metricsMsg->run_no = i;
if (call AMSend.send(AM_BROADCAST_ADDR, &pkt,
sizeof(MetricsMsg)) == SUCCESS) {
busy = TRUE;
}
}
}
}
}
.......
}
I've run Listen (with BaseStation) and got i = 1 and current_tx = 3 all the
time. They weren't increased.
I have been stuck for a day. Please help.
Thanks,
Ittipong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080311/fd17aadc/attachment-0001.htm
More information about the Tinyos-help
mailing list