请问大师,如何在ZStack-CC2530-2.5.1a中修改发射功率
1,网上搜到说协议栈默认发射参数是0xd5,正确吗?
2,我在macRadioSetTxPower()中直接设置参数修改发射功率,但是没变化。
一般都是通过 macRadioSetTxPower来 设置发射功率的
* @fn macRadioSetTxPower
*
* @brief Set transmitter power of the radio.
*
* @param txPower - the minus dBm for power but as a postive integer (or if configured
* for it, txPower is the raw register value). If PA/LNA is installed
* then txPower becomes positive dBm.
*
* @return The minus dBm for power actually set according to what is possible according to
the build and run-time configuration set.
谢谢答复!
我在程序中修改过的地方见下面程序。大黑体为修改的地方。
1,我是使用CC2531 usb dongle 硬件,通过smart RF packet sniffer 软件,查看RSSI (dBm) 值。可以如此测试吗? 但是看RSSI值,好像没效果,为何?
2,程序中我的修改方法正确吗?如在程序中如此修改,是否表示发射功率以后均以最大功率发送。
(我在网上看到,有个人说要
先在mac_radio_defs.h中,
去掉//#define HAL_MAC_USE_REGISTER_POWER_VALUES“//”
后
在ZMacInit();后面添加如下代码:
{
uint8 value = 0xF5;
MAC_MlmeSetReq(MAC_PHY_TRANSMIT_POWER, &value);
}
正确吗?)
3,如果不使用我添加的语句,协议栈的发射功率是动态变化的吗?
如可能的话,请逐条回答,先谢谢了。
#ifndef HAL_MAC_USE_REGISTER_POWER_VALUES
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
MAC_INTERNAL_API uint8 macRadioSetTxPower(uint8 txPower)
{
halIntState_t s;
#if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590
const uint8 CODE *pTable = macRadioDefsTxPwrTables[macRadioDefsRefTableId >> 4];
#elif defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590
const uint8 CODE *pTable = macRadioDefsTxPwrTables[0];
#else
const uint8 CODE *pTable = macRadioDefsTxPwrBare;
#endif
/* if the selected dBm is out of range, use the closest available */
if ((int8)txPower > (int8)pTable[MAC_RADIO_DEFS_TBL_TXPWR_FIRST_ENTRY])
{
/* greater than base value -- out of table range */
txPower = pTable[MAC_RADIO_DEFS_TBL_TXPWR_FIRST_ENTRY];
}
else if ((int8)txPower < (int8)pTable[MAC_RADIO_DEFS_TBL_TXPWR_LAST_ENTRY])
{
/* smaller than the lowest power level -- out of table range */
txPower = pTable[MAC_RADIO_DEFS_TBL_TXPWR_LAST_ENTRY];
}
/*
* Set the global variable reqTxPower. This variable is referenced
* by the function macRadioUpdateTxPower() to write the radio register.
*
* A lookup table is used to translate the power level to the register
* value.
*/
HAL_ENTER_CRITICAL_SECTION(s);
/* When calculating index to the power register value table,
* either txPower (of uint8 type) has to be explicitly type-casted to int8
* or the subtraction expression has to be type-casted to uint8 to work
* with the integral promotions.
* The latter is more code size efficient and hence the latter is used.
*/
{
uint8 index = pTable[MAC_RADIO_DEFS_TBL_TXPWR_FIRST_ENTRY] - txPower
+ MAC_RADIO_DEFS_TBL_TXPWR_ENTRIES;
reqTxPower = pTable[index];
}
HAL_EXIT_CRITICAL_SECTION(s);
/* update the radio power setting */
reqTxPower = 0xf5; //xwp 添加的
macRadioUpdateTxPower();
return txPower;
}
#else
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
MAC_INTERNAL_API uint8 macRadioSetTxPower(uint8 txPower)
{
halIntState_t s;
/* same as above but with no lookup table, use raw register value */
HAL_ENTER_CRITICAL_SECTION(s);
reqTxPower = txPower;
HAL_EXIT_CRITICAL_SECTION(s);
reqTxPower = 0xf5; //xwp //xwp 添加的
/* update the radio power setting */
macRadioUpdateTxPower();
return txPower;
}
#endif