Phil's right - looks like the comments are out of sync with the
implementation. Use CC2420Packet to set each outbound packet's Tx power.
When you send it, the TransmitP uses this to adjust the radio's power:
if ( m_tx_power != tx_power ) {
call TXCTRL.write( ( 2 << CC2420_TXCTRL_TXMIXBUF_CUR ) |
( 3 << CC2420_TXCTRL_PA_CURRENT ) |
( 1 << CC2420_TXCTRL_RESERVED ) |
( (tx_power & 0x1F) << CC2420_TXCTRL_PA_LEVEL ) );
}
Where m_tx_power is the transmit power level the radio is currently set to.
The lowest power level you can set is 1. Each message can be sent using a
different transmit power level.
-David
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Philip
Levis
Sent: Monday, July 09, 2007 10:54 PM
To: Andy Dalton
Cc: [email protected]
Subject: Re: [Tinyos-help] TinyOS-2.x - Controlling the Default Radio Power
inSoftware
On Jul 9, 2007, at 9:50 PM, Andy Dalton wrote:
> Greetings,
>
> I'm looking to control the default radio power level at runtime for
> Telos motes using TinyOS-2.x. In tos/chips/cc2420/CC2420Power.nc I
> see the following comment:
>
> "[This] does not include transmission power, see the CC2420Config
> interface."
>
> However, the CC2420Config interface does not include any command to
> set the default radio power level. The file
> tos/chips/cc2420/CC2420ControlP.nc includes a state variable
> 'm_tx_power' that is initialized to CC2420_DEF_RFPOWER; however, that
> variable is never used. The file tos/chips/cc2420/CC2420TransmitP.nc
> directly uses CC2420_DEF_RFPOWER to set the default power level:
>
> if ( !tx_power ) {
> // If our packet's tx_power wasn't configured to anything but 0,
> // send it using the default RF power. This assumes the
> // packet's metadata is all set to 0's on boot.
>
> tx_power = CC2420_DEF_RFPOWER;
> }
>
> It looks to me like the original intent was to provide a software
> interface for setting the default radio power level via the
> CC2420Config, but that its realization got lost along the way. With
> the current implementation, I cannot see a way to set the default
> radio power in software.
>
> One way to resolve this would be to add two new commands to the
> CC2420Config interface:
>
> command uint8_t getDefaultTxPower();
> command void setDefaultTxPower(uint8_t txPower);
>
> Then, in CC2420ControlP add implementations of those commands (again,
> 'm_tx_power' is already declared in this module and initialized to
> CC2420_DEF_RFPOWER):
>
> command uint8_t CC2420Config.getDefaultTxPower() {
> return m_tx_power;
> }
>
> command uint8_t CC2420Config.setDefaultTxPower(uint8_t txPower) {
> m_tx_power = txPower;
> }
>
> Then, in CC2420TransmitP use the CC2420Config interface, and call the
> getDefaultTxPower command to set the default power:
>
> if ( !tx_power ) {
> // If our packet's tx_power wasn't configured to anything but 0,
> // send it using the default RF power. This assumes the
> // packet's metadata is all set to 0's on boot.
>
> tx_power = call CC2420Config.getDefaultTxPower();
> }
>
> Does this seem reasonable? Am I missing some other mechanism to set
> the default radio power level in software?
To follow up, because my first answer was completely irrelevant to
your question...
The person to talk with about this idea would be David Moss, he's the
current maintainer of the CC2420 stack. Once 2.0,2 goes out, there
will probably be a good deal of discussion on -devel with respect to
some proposed changes core has for radio interfaces[1]. We wanted to
postpone them until a possible 2.1 and get feedback from the
community. It might be useful to incorporate these kinds of changes
in that reworking.
Phil
[1] Changes to getPayload to make it more easily checkable by memory
safety tools and removing accessors from Receive so it can have fan-in.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help