mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 02:37:47 +00:00
[radio] remove transmit power config from core (#2352)
Thread (and OpenThread) does not employ any form of transmit power control. As a result, while OpenThread provides APIs to control transmit power, it simply buffers and passes the transmit power value straight through to the radio. Currently, the transmit power APIs allow specifying an int8_t in units of dBm. This is overly constraining for platforms that have more advanced ways of configuring the transmit power. This commit removes the transmit power configuration from the core. This provides better flexibility in platform-specific ways to configure transmit power.
This commit is contained in:
@@ -465,7 +465,7 @@ The frame metadata field consists of the following fields:
|
||||
|
||||
Field | Description | Type | Len | Default
|
||||
:--------|:-----------------------------|:-----------|-------|----------
|
||||
MD_POWER | (dBm) RSSI/TX-Power | `c` int8 | 1 | -128
|
||||
MD_RSSI | (dBm) RSSI | `c` int8 | 1 | -128
|
||||
MD_NOISE | (dBm) Noise floor | `c` int8 | 1 | -128
|
||||
MD_FLAG | Flags (defined below) | `S` uint16 | 2 |
|
||||
MD_PHY | PHY-specific data | `d` data | >=2 |
|
||||
@@ -477,11 +477,6 @@ the host:
|
||||
* MD_NOISE
|
||||
* MD_FLAG
|
||||
|
||||
When specifying `MD_POWER` for a packet to be transmitted, the actual
|
||||
transmit power is never larger than the current value of `PROP_PHY_TX_POWER`
|
||||
((#prop-phy-tx-power)). When left unspecified (or set to the value -128),
|
||||
an appropriate transmit power will be chosen by the NCP.
|
||||
|
||||
The bit values in `MD_FLAG` are defined as follows:
|
||||
|
||||
Bit | Mask | Name | Description if set
|
||||
|
||||
@@ -148,13 +148,17 @@ public:
|
||||
|
||||
#pragma region Link Layer
|
||||
|
||||
property signed int /*int8_t*/ MaxTransmitPower
|
||||
property signed int /*int8_t*/ TransmitPower
|
||||
{
|
||||
signed int get() { return otLinkGetMaxTransmitPower(DeviceInstance); }
|
||||
signed int get() {
|
||||
int8_t value;
|
||||
ThrowOnFailure(otPlatRadioGetTransmitPower(DeviceInstance, &value));
|
||||
return value;
|
||||
}
|
||||
void set(signed int value)
|
||||
{
|
||||
if (value > 127) throw Exception::CreateException(E_INVALIDARG);
|
||||
otLinkSetMaxTransmitPower(DeviceInstance, (int8_t)value);
|
||||
ThrowOnFailure(otPlatRadioSetTransmitPower(DeviceInstance, (int8_t)value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -457,8 +457,8 @@ typedef enum _OTLWF_NOTIF_TYPE
|
||||
OTLWF_CTL_CODE(156, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
|
||||
#define IOCTL_OTLWF_OT_MAX_TRANSMIT_POWER \
|
||||
OTLWF_CTL_CODE(157, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
//#define IOCTL_OTLWF_OT_TRANSMIT_POWER \
|
||||
// OTLWF_CTL_CODE(157, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// int8_t - aPower
|
||||
|
||||
|
||||
@@ -1653,29 +1653,6 @@ otThreadSetPSKc(
|
||||
return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_PSKC, Buffer, sizeof(Buffer), nullptr, 0));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
int8_t
|
||||
OTCALL
|
||||
otLinkGetMaxTransmitPower(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
int8_t Result = 0;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_TRANSMIT_POWER, &Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkSetMaxTransmitPower(
|
||||
_In_ otInstance *aInstance,
|
||||
int8_t aPower
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_TRANSMIT_POWER, aPower);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
const otIp6Address *
|
||||
OTCALL
|
||||
|
||||
@@ -956,7 +956,7 @@ otLwfCmdSendMacFrameAsync(
|
||||
Packet->mPsdu,
|
||||
(uint32_t)Packet->mLength,
|
||||
Packet->mChannel,
|
||||
Packet->mPower
|
||||
Packet->mRssi
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
|
||||
@@ -1019,7 +1019,7 @@ otLwfEventWorkerThread(
|
||||
SPINEL_DATATYPE_STRUCT_S( // Vendor-data
|
||||
SPINEL_DATATYPE_UINT_PACKED_S
|
||||
),
|
||||
&pFilter->otReceiveFrame.mPower,
|
||||
&pFilter->otReceiveFrame.mRssi,
|
||||
&noiseFloor,
|
||||
&flags,
|
||||
&pFilter->otReceiveFrame.mChannel,
|
||||
|
||||
@@ -102,7 +102,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST", REF_IOCTL_FUNC(otRemoveMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST", REF_IOCTL_FUNC(otNextMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST", REF_IOCTL_FUNC(otClearMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_MAX_TRANSMIT_POWER", REF_IOCTL_FUNC(otMaxTransmitPower) },
|
||||
{ "IOCTL_OTLWF_OT_TRANSMIT_POWER", REF_IOCTL_FUNC(otTransmitPower) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX", REF_IOCTL_FUNC(otNextOnMeshPrefix) },
|
||||
{ "IOCTL_OTLWF_OT_POLL_PERIOD", REF_IOCTL_FUNC(otPollPeriod) },
|
||||
{ "IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID", REF_IOCTL_FUNC(otLocalLeaderPartitionId) },
|
||||
@@ -4786,7 +4786,7 @@ otLwfIoCtl_otClearMacBlacklist(
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otMaxTransmitPower(
|
||||
otLwfIoCtl_otTransmitPower(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
@@ -4800,15 +4800,13 @@ otLwfIoCtl_otMaxTransmitPower(
|
||||
|
||||
if (InBufferLength >= sizeof(int8_t))
|
||||
{
|
||||
otLinkSetMaxTransmitPower(pFilter->otCtx, *(int8_t*)InBuffer);
|
||||
status = STATUS_SUCCESS;
|
||||
status = ThreadErrorToNtstatus(otPlatRadioSetTransmitPower(pFilter->otCtx, *(int8_t*)InBuffer));
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(int8_t))
|
||||
{
|
||||
*(int8_t*)OutBuffer = otLinkGetMaxTransmitPower(pFilter->otCtx);
|
||||
status = ThreadErrorToNtstatus(otPlatRadioGetTransmitPower(pFilter->otCtx, (int8_t*)OutBuffer));
|
||||
*OutBufferLength = sizeof(int8_t);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -188,7 +188,7 @@ DECL_IOCTL_FUNC(otAddMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otRemoveMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otNextMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otClearMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otMaxTransmitPower);
|
||||
DECL_IOCTL_FUNC(otTransmitPower);
|
||||
DECL_IOCTL_FUNC(otNextOnMeshPrefix);
|
||||
DECL_IOCTL_FUNC(otPollPeriod);
|
||||
DECL_IOCTL_FUNC(otLocalLeaderPartitionId);
|
||||
|
||||
@@ -802,7 +802,30 @@ error:
|
||||
return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(_In_ otInstance *otCtx, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(_In_ otInstance *otCtx, int8_t *aPower)
|
||||
{
|
||||
NT_ASSERT(otCtx);
|
||||
PMS_FILTER pFilter = otCtxToFilter(otCtx);
|
||||
NTSTATUS status;
|
||||
|
||||
status =
|
||||
otLwfCmdGetProp(
|
||||
pFilter,
|
||||
NULL,
|
||||
SPINEL_PROP_PHY_TX_POWER,
|
||||
SPINEL_DATATYPE_INT8_S,
|
||||
aPower
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Get SPINEL_PROP_PHY_TX_POWER, failed, %!STATUS!", status);
|
||||
}
|
||||
|
||||
return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(_In_ otInstance *otCtx, int8_t aPower)
|
||||
{
|
||||
NT_ASSERT(otCtx);
|
||||
PMS_FILTER pFilter = otCtxToFilter(otCtx);
|
||||
@@ -816,10 +839,13 @@ void otPlatRadioSetDefaultTxPower(_In_ otInstance *otCtx, int8_t aPower)
|
||||
SPINEL_DATATYPE_INT8_S,
|
||||
aPower
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_PHY_TX_POWER failed, %!STATUS!", status);
|
||||
}
|
||||
|
||||
return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(_In_ otInstance *otCtx)
|
||||
|
||||
@@ -356,7 +356,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
}
|
||||
|
||||
setChannel(aFrame->mChannel);
|
||||
setTxPower(aFrame->mPower);
|
||||
|
||||
while ((HWREG(RFCORE_XREG_FSMSTAT1) & 1) == 0);
|
||||
|
||||
@@ -446,7 +445,7 @@ void readFrame(void)
|
||||
sReceiveFrame.mPsdu[i] = HWREG(RFCORE_SFR_RFDATA);
|
||||
}
|
||||
|
||||
sReceiveFrame.mPower = (int8_t)HWREG(RFCORE_SFR_RFDATA) - CC2538_RSSI_OFFSET;
|
||||
sReceiveFrame.mRssi = (int8_t)HWREG(RFCORE_SFR_RFDATA) - CC2538_RSSI_OFFSET;
|
||||
crcCorr = HWREG(RFCORE_SFR_RFDATA);
|
||||
|
||||
if (crcCorr & CC2538_CRC_BIT_MASK)
|
||||
@@ -840,11 +839,24 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
// TODO: Create a proper implementation for this driver.
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sTxPower;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
setTxPower(aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -1219,7 +1219,22 @@ exit:
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sCurrentOutputPower->dbm;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
unsigned int i;
|
||||
output_config_t const *powerCfg = &(rgOutputPower[0]);
|
||||
@@ -1238,6 +1253,8 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
}
|
||||
|
||||
sCurrentOutputPower = powerCfg;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1803,7 +1820,7 @@ static void cc2650RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
receiveFrame.mLength = len;
|
||||
receiveFrame.mPsdu = &(payload[1]);
|
||||
receiveFrame.mChannel = sReceiveCmd.channel;
|
||||
receiveFrame.mPower = rssi;
|
||||
receiveFrame.mRssi = rssi;
|
||||
receiveFrame.mLqi = crcCorr->status.corr;
|
||||
|
||||
receiveError = OT_ERROR_NONE;
|
||||
|
||||
@@ -1228,7 +1228,22 @@ exit:
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sCurrentOutputPower->dbm;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
unsigned int i;
|
||||
output_config_t const *powerCfg = &(rgOutputPower[0]);
|
||||
@@ -1247,6 +1262,8 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
}
|
||||
|
||||
sCurrentOutputPower = powerCfg;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1815,7 +1832,7 @@ static void cc2652RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
receiveFrame.mLength = len;
|
||||
receiveFrame.mPsdu = &(payload[1]);
|
||||
receiveFrame.mChannel = sReceiveCmd.channel;
|
||||
receiveFrame.mPower = rssi;
|
||||
receiveFrame.mRssi = rssi;
|
||||
receiveFrame.mLqi = crcCorr->status.corr;
|
||||
|
||||
receiveError = OT_ERROR_NONE;
|
||||
|
||||
@@ -71,6 +71,7 @@ static bool sRadioPromiscuous = false;
|
||||
static bool sTransmitDoneFrame = false;
|
||||
static uint8_t sChannel = RADIO_DEFAULT_CHANNEL;
|
||||
static uint8_t sEnableRX = 0;
|
||||
static int8_t sTxPower = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
|
||||
static uint8_t sReadFrame = 0;
|
||||
static uint8_t sWriteFrame = 0;
|
||||
static uint32_t sSleepInitDelay = 0;
|
||||
@@ -466,11 +467,26 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sTxPower;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
otLogInfoPlat(aInstance, "Set DefaultTxPower: %d", aPower);
|
||||
|
||||
sTxPower = aPower;
|
||||
ftdf_set_value(FTDF_PIB_TX_POWER, &aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void da15000RadioProcess(otInstance *aInstance)
|
||||
@@ -577,7 +593,7 @@ void ftdf_rcv_frame_transparent(ftdf_data_length_t frame_length,
|
||||
sReceiveFrame[sWriteFrame].mChannel = sChannel;
|
||||
sReceiveFrame[sWriteFrame].mLength = frame_length;
|
||||
sReceiveFrame[sWriteFrame].mLqi = OT_RADIO_LQI_NONE;
|
||||
sReceiveFrame[sWriteFrame].mPower = otPlatRadioGetRssi(sThreadInstance);
|
||||
sReceiveFrame[sWriteFrame].mRssi = otPlatRadioGetRssi(sThreadInstance);
|
||||
memcpy(sReceiveFrame[sWriteFrame].mPsdu, frame, frame_length);
|
||||
|
||||
sWriteFrame = (sWriteFrame + 1) % RADIO_FRAMES_BUFFER_SIZE;
|
||||
|
||||
@@ -134,7 +134,7 @@ void efr32RadioInit(void)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
RAIL_TxPowerSet(OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER);
|
||||
RAIL_TxPowerSet(OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER);
|
||||
|
||||
otLogInfoPlat(sInstance, "Initialized", NULL);
|
||||
}
|
||||
@@ -337,7 +337,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
txOption.removeCrc = false;
|
||||
txOption.syncWordId = 0;
|
||||
|
||||
RAIL_TxPowerSet(aFrame->mPower);
|
||||
setChannel(aFrame->mChannel);
|
||||
RAIL_RfIdleExt(RAIL_IDLE, true);
|
||||
|
||||
@@ -695,7 +694,7 @@ void RAILCb_RxPacketReceived(void *aRxPacketHandle)
|
||||
#endif
|
||||
|
||||
memcpy(sReceiveFrame.mPsdu, rxPacketInfo->dataPtr + 1, rxPacketInfo->dataLength);
|
||||
sReceiveFrame.mPower = rxPacketInfo->appendedInfo.rssiLatch;
|
||||
sReceiveFrame.mRssi = rxPacketInfo->appendedInfo.rssiLatch;
|
||||
sReceiveFrame.mLqi = rxPacketInfo->appendedInfo.lqi;
|
||||
sReceiveFrame.mLength = length;
|
||||
sReceiveError = OT_ERROR_NONE;
|
||||
@@ -844,10 +843,24 @@ void RAILCb_FreeMemory(void *aHandle)
|
||||
(void)aHandle;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = (int8_t)RAIL_TxPowerGet();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
RAIL_TxPowerSet(aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -472,7 +472,7 @@ void readFrame(void)
|
||||
/* Read PSDU */
|
||||
memcpy(sReceiveFrame.mPsdu, readBuffer, length - 2);
|
||||
|
||||
sReceiveFrame.mPower = (int8_t)(readRssi / MRF24J40_RSSI_SLOPE) - MRF24J40_RSSI_OFFSET;
|
||||
sReceiveFrame.mRssi = (int8_t)(readRssi / MRF24J40_RSSI_SLOPE) - MRF24J40_RSSI_OFFSET;
|
||||
sReceiveFrame.mLength = (uint8_t) length;
|
||||
sReceiveFrame.mLqi = readPlqi;
|
||||
|
||||
@@ -675,11 +675,20 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
// TODO: Create a proper implementation for this driver.
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
// TODO: Create a proper implementation for this driver.
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -219,7 +219,7 @@ void cbQorvoRadioReceiveDone(otRadioFrame *aPacket, otError aError)
|
||||
{
|
||||
if (aError == OT_ERROR_NONE)
|
||||
{
|
||||
sLastReceivedPower = aPacket->mPower;
|
||||
sLastReceivedPower = aPacket->mRssi;
|
||||
}
|
||||
|
||||
otPlatRadioReceiveDone(pQorvoInstance, aPacket, aError);
|
||||
@@ -313,12 +313,20 @@ void cbQorvoRadioEnergyScanDone(int8_t aEnergyScanMaxRssi)
|
||||
otPlatRadioEnergyScanDone(pQorvoInstance, aEnergyScanMaxRssi);
|
||||
}
|
||||
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
// TODO: Create a proper implementation for this driver.
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
// TODO: Create a proper implementation for this driver.
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -346,7 +346,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
}
|
||||
|
||||
rf_set_channel(aFrame->mChannel);
|
||||
rf_set_tx_power(aFrame->mPower);
|
||||
|
||||
*(uint8_t *)ZLL->PKT_BUFFER_TX = aFrame->mLength;
|
||||
|
||||
@@ -462,11 +461,24 @@ exit:
|
||||
return status;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sAutoTxPwrLevel;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
sAutoTxPwrLevel = aPower;
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
@@ -733,7 +745,7 @@ static bool rf_process_rx_frame(void)
|
||||
sRxFrame.mLength = temp;
|
||||
temp = (ZLL->LQI_AND_RSSI & ZLL_LQI_AND_RSSI_LQI_VALUE_MASK) >> ZLL_LQI_AND_RSSI_LQI_VALUE_SHIFT;
|
||||
sRxFrame.mLqi = rf_lqi_adjust(temp);
|
||||
sRxFrame.mPower = rf_lqi_to_rssi(sRxFrame.mLqi);
|
||||
sRxFrame.mRssi = rf_lqi_to_rssi(sRxFrame.mLqi);
|
||||
#if DOUBLE_BUFFERING
|
||||
|
||||
for (temp = 0; temp < sRxFrame.mLength - 2; temp++)
|
||||
|
||||
@@ -456,7 +456,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro
|
||||
message->mCnt,
|
||||
sID,
|
||||
message->mID,
|
||||
aFrame->mPower
|
||||
aFrame->mRssi
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,6 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||
|
||||
sTxPacket->mLength = sizeof(struct PlatformDiagMessage);
|
||||
sTxPacket->mChannel = sChannel;
|
||||
sTxPacket->mPower = sTxPower;
|
||||
|
||||
sDiagMessage.mChannel = sTxPacket->mChannel;
|
||||
sDiagMessage.mID = sID;
|
||||
|
||||
@@ -329,7 +329,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
aFrame->mPsdu[-1] = aFrame->mLength;
|
||||
|
||||
nrf_drv_radio802154_channel_set(aFrame->mChannel);
|
||||
nrf_drv_radio802154_tx_power_set(aFrame->mPower);
|
||||
|
||||
if (nrf_drv_radio802154_transmit_raw(&aFrame->mPsdu[-1], true))
|
||||
{
|
||||
@@ -502,12 +501,31 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
(void)aInstance;
|
||||
|
||||
if (aPower == NULL)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
*aPower = sDefaultTxPower;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
sDefaultTxPower = aPower;
|
||||
nrf_drv_radio802154_tx_power_set(aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void nrf5RadioProcess(otInstance *aInstance)
|
||||
@@ -537,7 +555,6 @@ void nrf5RadioProcess(otInstance *aInstance)
|
||||
if (isPendingEventSet(kPendingEventTransmit))
|
||||
{
|
||||
nrf_drv_radio802154_channel_set(sTransmitFrame.mChannel);
|
||||
nrf_drv_radio802154_tx_power_set(sTransmitFrame.mPower);
|
||||
|
||||
if (nrf_drv_radio802154_transmit_raw(sTransmitPsdu, true))
|
||||
{
|
||||
@@ -666,7 +683,7 @@ void nrf_drv_radio802154_received_raw(uint8_t *p_data, int8_t power, int8_t lqi)
|
||||
|
||||
receivedFrame->mPsdu = &p_data[1];
|
||||
receivedFrame->mLength = p_data[0];
|
||||
receivedFrame->mPower = power;
|
||||
receivedFrame->mRssi = power;
|
||||
receivedFrame->mLqi = lqi;
|
||||
receivedFrame->mChannel = nrf_drv_radio802154_channel_get();
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
@@ -716,7 +733,7 @@ void nrf_drv_radio802154_transmitted_raw(uint8_t *aAckPsdu, int8_t aPower, int8_
|
||||
{
|
||||
sAckFrame.mPsdu = &aAckPsdu[1];
|
||||
sAckFrame.mLength = aAckPsdu[0];
|
||||
sAckFrame.mPower = aPower;
|
||||
sAckFrame.mRssi = aPower;
|
||||
sAckFrame.mLqi = aLqi;
|
||||
sAckFrame.mChannel = nrf_drv_radio802154_channel_get();
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@ void radioProcessFrame(otInstance *aInstance)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sReceiveFrame.mPower = -20;
|
||||
sReceiveFrame.mRssi = -20;
|
||||
sReceiveFrame.mLqi = OT_RADIO_LQI_NONE;
|
||||
|
||||
// generate acknowledgment
|
||||
@@ -857,10 +857,18 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -81,12 +81,12 @@ extern uint32_t __d_nv_mem_end;
|
||||
#define RADIO_CONFIG_SRC_MATCH_ENTRY_NUM 128
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER
|
||||
* @def OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER
|
||||
*
|
||||
* The default IEEE 802.15.4 maximum transmit power (dBm)
|
||||
* The default IEEE 802.15.4 transmit power (dBm)
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER 5
|
||||
#define OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER 5
|
||||
|
||||
|
||||
#endif // OPENTHREAD_CORE_SAMR21_CONFIG_H_
|
||||
|
||||
@@ -65,7 +65,7 @@ static bool sRxEnable = false;
|
||||
static bool sTxDone = false;
|
||||
static bool sRxDone = false;
|
||||
static otError sTxStatus = OT_ERROR_NONE;
|
||||
static int8_t sPower = OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER;
|
||||
static int8_t sPower = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sPromiscuous = false;
|
||||
static uint8_t sChannel = 0xFF;
|
||||
@@ -252,7 +252,7 @@ static void handleRx(void)
|
||||
if (sPromiscuous || sReceiveFrame.mLength > IEEE802154_ACK_LENGTH)
|
||||
{
|
||||
otLogDebgPlat(sInstance, "Radio receive done, rssi: %d",
|
||||
sReceiveFrame.mPower);
|
||||
sReceiveFrame.mRssi);
|
||||
|
||||
otPlatRadioReceiveDone(sInstance, &sReceiveFrame, OT_ERROR_NONE);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ void PHY_DataInd(PHY_DataInd_t *ind)
|
||||
{
|
||||
sReceiveFrame.mPsdu = ind->data;
|
||||
sReceiveFrame.mLength = ind->size + IEEE802154_FCS_SIZE;
|
||||
sReceiveFrame.mPower = ind->rssi;
|
||||
sReceiveFrame.mRssi = ind->rssi;
|
||||
|
||||
sRxDone = true;
|
||||
}
|
||||
@@ -518,7 +518,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
uint8_t frame[OT_RADIO_FRAME_MAX_SIZE + 1];
|
||||
|
||||
setChannel(aFrame->mChannel);
|
||||
setTxPower(aFrame->mPower);
|
||||
|
||||
frame[0] = aFrame->mLength - IEEE802154_FCS_SIZE;
|
||||
memcpy(frame + 1, aFrame->mPsdu, aFrame->mLength);
|
||||
@@ -616,13 +615,26 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
*aPower = sPower;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
otLogDebgPlat(sInstance, "Radio set default TX power: %d", aPower);
|
||||
|
||||
setTxPower(aPower);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -212,25 +212,6 @@ OTAPI otError OTCALL otLinkSetExtendedAddress(otInstance *aInstance, const otExt
|
||||
*/
|
||||
OTAPI void OTCALL otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui64);
|
||||
|
||||
/**
|
||||
* This function returns the maximum transmit power setting in dBm.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The maximum transmit power setting.
|
||||
*
|
||||
*/
|
||||
OTAPI int8_t OTCALL otLinkGetMaxTransmitPower(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function sets the maximum transmit power in dBm.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPower The maximum transmit power in dBm.
|
||||
*
|
||||
*/
|
||||
OTAPI void OTCALL otLinkSetMaxTransmitPower(otInstance *aInstance, int8_t aPower);
|
||||
|
||||
/**
|
||||
* Get the IEEE 802.15.4 PAN ID.
|
||||
*
|
||||
|
||||
@@ -101,7 +101,7 @@ typedef struct otRadioFrame
|
||||
uint8_t *mPsdu; ///< The PSDU.
|
||||
uint8_t mLength; ///< Length of the PSDU.
|
||||
uint8_t mChannel; ///< Channel used to transmit/receive the frame.
|
||||
int8_t mPower; ///< Transmit/receive power in dBm.
|
||||
int8_t mRssi ; ///< Received signal strength indicator in dBm for received frames.
|
||||
uint8_t mLqi; ///< Link Quality Indicator for received frames.
|
||||
uint8_t mMaxTxAttempts; ///< Max number of transmit attempts for an outbound frame.
|
||||
bool mSecurityValid: 1; ///< Security Enabled flag is set and frame passes security checks.
|
||||
@@ -451,13 +451,29 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance);
|
||||
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Set the radio Tx power used for auto-generated frames.
|
||||
* Get the radio's transmit power in dBm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aPower The Tx power to use in dBm.
|
||||
* @param[out] aPower The transmit power in dBm.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the transmit power.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aPower was NULL.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented.
|
||||
*
|
||||
*/
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower);
|
||||
otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower);
|
||||
|
||||
/**
|
||||
* Set the radio's transmit power in dBm.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aPower The transmit power in dBm.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the transmit power.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented.
|
||||
*
|
||||
*/
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower);
|
||||
|
||||
/**
|
||||
* Get the status of promiscuous mode.
|
||||
|
||||
+4
-4
@@ -1592,20 +1592,20 @@ Done
|
||||
|
||||
### txpowermax
|
||||
|
||||
Get the maximum transmit power in dBm.
|
||||
Get the transmit power in dBm.
|
||||
|
||||
```bash
|
||||
> txpowermax
|
||||
> txpower
|
||||
-10 dBm
|
||||
Done
|
||||
```
|
||||
|
||||
### txpowermax \<txpowermax\>
|
||||
|
||||
Set the maximum transmit power.
|
||||
Set the transmit power.
|
||||
|
||||
```bash
|
||||
> txpowermax -10
|
||||
> txpower -10
|
||||
Done
|
||||
```
|
||||
|
||||
|
||||
+18
-14
@@ -216,8 +216,8 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "singleton", &Interpreter::ProcessSingleton },
|
||||
{ "state", &Interpreter::ProcessState },
|
||||
{ "thread", &Interpreter::ProcessThread },
|
||||
{ "txpowermax", &Interpreter::ProcessTxPowerMax },
|
||||
#ifndef OTDLL
|
||||
{ "txpower", &Interpreter::ProcessTxPower },
|
||||
{ "udp", &Interpreter::ProcessUdp },
|
||||
#endif
|
||||
{ "version", &Interpreter::ProcessVersion },
|
||||
@@ -2618,25 +2618,38 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessTxPowerMax(int argc, char *argv[])
|
||||
#ifndef OTDLL
|
||||
void Interpreter::ProcessTxPower(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
long value;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
mServer->OutputFormat("%d dBm\r\n", otLinkGetMaxTransmitPower(mInstance));
|
||||
int8_t power;
|
||||
|
||||
SuccessOrExit(error = otPlatRadioGetTransmitPower(mInstance, &power));
|
||||
mServer->OutputFormat("%d dBm\r\n", power);
|
||||
}
|
||||
else
|
||||
{
|
||||
long value;
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otLinkSetMaxTransmitPower(mInstance, static_cast<int8_t>(value));
|
||||
SuccessOrExit(error = otPlatRadioSetTransmitPower(mInstance, static_cast<int8_t>(value)));
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessUdp(int argc, char *argv[])
|
||||
{
|
||||
otError error;
|
||||
error = mUdp.Process(argc, argv);
|
||||
AppendResult(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Interpreter::ProcessVersion(int argc, char *argv[])
|
||||
{
|
||||
otStringPtr version(otGetVersionString());
|
||||
@@ -2646,15 +2659,6 @@ void Interpreter::ProcessVersion(int argc, char *argv[])
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
}
|
||||
|
||||
#ifndef OTDLL
|
||||
void Interpreter::ProcessUdp(int argc, char *argv[])
|
||||
{
|
||||
otError error;
|
||||
error = mUdp.Process(argc, argv);
|
||||
AppendResult(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
|
||||
void Interpreter::ProcessCommissioner(int argc, char *argv[])
|
||||
|
||||
+4
-5
@@ -305,7 +305,10 @@ private:
|
||||
void ProcessSingleton(int argc, char *argv[]);
|
||||
void ProcessState(int argc, char *argv[]);
|
||||
void ProcessThread(int argc, char *argv[]);
|
||||
void ProcessTxPowerMax(int argc, char *argv[]);
|
||||
#ifndef OTDLL
|
||||
void ProcessTxPower(int argc, char *argv[]);
|
||||
void ProcessUdp(int argc, char *argv[]);
|
||||
#endif
|
||||
void ProcessVersion(int argc, char *argv[]);
|
||||
#if OPENTHREAD_ENABLE_MAC_FILTER
|
||||
void ProcessMacFilter(int argc, char *argv[]);
|
||||
@@ -321,10 +324,6 @@ private:
|
||||
void ProcessInstance(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
#ifndef OTDLL
|
||||
void ProcessUdp(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
#ifndef OTDLL
|
||||
static void s_HandleIcmpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo,
|
||||
const otIcmp6Header *aIcmpHeader);
|
||||
|
||||
@@ -94,21 +94,6 @@ void otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui
|
||||
otPlatRadioGetIeeeEui64(aInstance, aEui64->m8);
|
||||
}
|
||||
|
||||
int8_t otLinkGetMaxTransmitPower(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetMac().GetMaxTransmitPower();
|
||||
}
|
||||
|
||||
void otLinkSetMaxTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
instance.GetThreadNetif().GetMac().SetMaxTransmitPower(aPower);
|
||||
otPlatRadioSetDefaultTxPower(aInstance, aPower);
|
||||
}
|
||||
|
||||
otPanId otLinkGetPanId(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
+4
-12
@@ -155,7 +155,6 @@ Mac::Mac(Instance &aInstance):
|
||||
mShortAddress(kShortAddrInvalid),
|
||||
mPanId(kPanIdBroadcast),
|
||||
mChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL),
|
||||
mMaxTransmitPower(OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER),
|
||||
mSendHead(NULL),
|
||||
mSendTail(NULL),
|
||||
mReceiveHead(NULL),
|
||||
@@ -286,7 +285,7 @@ otError Mac::ConvertBeaconToActiveScanResult(Frame *aBeaconFrame, otActiveScanRe
|
||||
|
||||
aBeaconFrame->GetSrcPanId(aResult.mPanId);
|
||||
aResult.mChannel = aBeaconFrame->GetChannel();
|
||||
aResult.mRssi = aBeaconFrame->GetPower();
|
||||
aResult.mRssi = aBeaconFrame->GetRssi();
|
||||
aResult.mLqi = aBeaconFrame->GetLqi();
|
||||
|
||||
payloadLength = aBeaconFrame->GetPayloadLength();
|
||||
@@ -883,8 +882,6 @@ void Mac::HandleBeginTransmit(void)
|
||||
|
||||
if (mCsmaAttempts == 0 && mTransmitAttempts == 0)
|
||||
{
|
||||
sendFrame.SetPower(mMaxTransmitPower);
|
||||
|
||||
switch (mOperation)
|
||||
{
|
||||
case kOperationActiveScan:
|
||||
@@ -921,11 +918,6 @@ void Mac::HandleBeginTransmit(void)
|
||||
|
||||
// Security Processing
|
||||
ProcessTransmitSecurity(sendFrame);
|
||||
|
||||
if (sendFrame.GetPower() > mMaxTransmitPower)
|
||||
{
|
||||
sendFrame.SetPower(mMaxTransmitPower);
|
||||
}
|
||||
}
|
||||
|
||||
error = RadioReceive(sendFrame.GetChannel());
|
||||
@@ -1014,7 +1006,7 @@ void Mac::TransmitDoneTask(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otErro
|
||||
|
||||
if (neighbor != NULL)
|
||||
{
|
||||
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), ackFrame->GetPower());
|
||||
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), ackFrame->GetRssi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1614,7 +1606,7 @@ void Mac::ReceiveDoneTask(Frame *aFrame, otError aError)
|
||||
// override with the rssi in setting
|
||||
if (rssi != OT_MAC_FILTER_FIXED_RSS_DISABLED)
|
||||
{
|
||||
aFrame->mPower = rssi;
|
||||
aFrame->mRssi = rssi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1670,7 +1662,7 @@ void Mac::ReceiveDoneTask(Frame *aFrame, otError aError)
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_MAC_FILTER
|
||||
|
||||
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), aFrame->mPower);
|
||||
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), aFrame->mRssi);
|
||||
|
||||
if (aFrame->GetSecurityEnabled() == true)
|
||||
{
|
||||
|
||||
@@ -402,22 +402,6 @@ public:
|
||||
*/
|
||||
otError SetChannel(uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* This method returns the maximum transmit power in dBm.
|
||||
*
|
||||
* @returns The maximum transmit power in dBm.
|
||||
*
|
||||
*/
|
||||
int8_t GetMaxTransmitPower(void) const { return mMaxTransmitPower; }
|
||||
|
||||
/**
|
||||
* This method sets the maximum transmit power in dBm.
|
||||
*
|
||||
* @param[in] aPower The maximum transmit power in dBm.
|
||||
*
|
||||
*/
|
||||
void SetMaxTransmitPower(int8_t aPower) { mMaxTransmitPower = aPower; }
|
||||
|
||||
/**
|
||||
* This method returns the IEEE 802.15.4 Network Name.
|
||||
*
|
||||
@@ -696,7 +680,6 @@ private:
|
||||
ShortAddress mShortAddress;
|
||||
PanId mPanId;
|
||||
uint8_t mChannel;
|
||||
int8_t mMaxTransmitPower;
|
||||
|
||||
otNetworkName mNetworkName;
|
||||
otExtendedPanId mExtendedPanId;
|
||||
|
||||
@@ -637,20 +637,20 @@ public:
|
||||
void SetChannel(uint8_t aChannel) { mChannel = aChannel; }
|
||||
|
||||
/**
|
||||
* This method returns the transmit/receive power in dBm used for transmission or reception.
|
||||
* This method returns the RSSI in dBm used for reception.
|
||||
*
|
||||
* @returns The transmit/receive power in dBm used for transmission or reception.
|
||||
* @returns The RSSI in dBm used for reception.
|
||||
*
|
||||
*/
|
||||
int8_t GetPower(void) const { return mPower; }
|
||||
int8_t GetRssi(void) const { return mRssi; }
|
||||
|
||||
/**
|
||||
* This method sets the transmit/receive power in dBm used for transmission or reception.
|
||||
* This method sets the RSSI in dBm used for reception.
|
||||
*
|
||||
* @param[in] aPower The transmit/receive power in dBm used for transmission or reception.
|
||||
* @param[in] aRssi The RSSI in dBm used for reception.
|
||||
*
|
||||
*/
|
||||
void SetPower(int8_t aPower) { mPower = aPower; }
|
||||
void SetRssi(int8_t aRssi) { mRssi = aRssi; }
|
||||
|
||||
/**
|
||||
* This method returns the receive Link Quality Indicator.
|
||||
|
||||
@@ -116,13 +116,13 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER
|
||||
* @def OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER
|
||||
*
|
||||
* The default IEEE 802.15.4 maximum transmit power (dBm)
|
||||
* The default IEEE 802.15.4 transmit power (dBm)
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER
|
||||
#define OPENTHREAD_CONFIG_DEFAULT_MAX_TRANSMIT_POWER 0
|
||||
#ifndef OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER
|
||||
#define OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -1890,7 +1890,7 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame)
|
||||
|
||||
aFrame.GetSrcPanId(linkInfo.mPanId);
|
||||
linkInfo.mChannel = aFrame.GetChannel();
|
||||
linkInfo.mRss = aFrame.GetPower();
|
||||
linkInfo.mRss = aFrame.GetRssi();
|
||||
linkInfo.mLqi = aFrame.GetLqi();
|
||||
linkInfo.mLinkSecurity = aFrame.GetSecurityEnabled();
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ void Diag::TxPacket()
|
||||
{
|
||||
sTxPacket->mLength = sTxLen;
|
||||
sTxPacket->mChannel = sChannel;
|
||||
sTxPacket->mPower = sTxPower;
|
||||
|
||||
for (uint8_t i = 0; i < sTxLen; i++)
|
||||
{
|
||||
@@ -368,7 +367,7 @@ void Diag::DiagReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError
|
||||
// for sensitivity test, only record the rssi and lqi for the first packet
|
||||
if (sStats.received_packets == 0)
|
||||
{
|
||||
sStats.first_rssi = aFrame->mPower;
|
||||
sStats.first_rssi = aFrame->mRssi;
|
||||
sStats.first_lqi = aFrame->mLqi;
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -822,7 +822,7 @@ void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
|
||||
SuccessOrExit(mEncoder.WriteData(aFrame->mPsdu, aFrame->mLength));
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mPower)); // TX Power
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
|
||||
@@ -1816,7 +1816,14 @@ otError NcpBase::GetPropertyHandler_PHY_RX_SENSITIVITY(void)
|
||||
|
||||
otError NcpBase::GetPropertyHandler_PHY_TX_POWER(void)
|
||||
{
|
||||
return mEncoder.WriteInt8(otLinkGetMaxTransmitPower(mInstance));
|
||||
int8_t power;
|
||||
otError error;
|
||||
|
||||
SuccessOrExit(error = otPlatRadioGetTransmitPower(mInstance, &power));
|
||||
error = mEncoder.WriteInt8(power);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpBase::SetPropertyHandler_PHY_TX_POWER(void)
|
||||
@@ -1825,8 +1832,7 @@ otError NcpBase::SetPropertyHandler_PHY_TX_POWER(void)
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadInt8(txPower));
|
||||
|
||||
otLinkSetMaxTransmitPower(mInstance, txPower);
|
||||
error = otPlatRadioSetTransmitPower(mInstance, txPower);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -82,7 +82,7 @@ void NcpBase::LinkRawReceiveDone(otRadioFrame *aFrame, otError aError)
|
||||
}
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mPower)); // TX Power
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
|
||||
@@ -128,7 +128,7 @@ void NcpBase::LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame,
|
||||
SuccessOrExit(mEncoder.WriteUint16(aAckFrame->mLength));
|
||||
SuccessOrExit(mEncoder.WriteData(aAckFrame->mPsdu, aAckFrame->mLength));
|
||||
|
||||
SuccessOrExit(mEncoder.WriteInt8(aAckFrame->mPower)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(aAckFrame->mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(0)); // Flags
|
||||
|
||||
@@ -356,7 +356,6 @@ otError NcpBase::SetPropertyHandler_STREAM_RAW(uint8_t aHeader)
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadDataWithLen(frameBuffer, frameLen));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(frame->mChannel));
|
||||
SuccessOrExit(error = mDecoder.ReadInt8(frame->mPower));
|
||||
|
||||
VerifyOrExit(frameLen <= OT_RADIO_FRAME_MAX_SIZE, error = OT_ERROR_PARSE);
|
||||
|
||||
|
||||
@@ -238,10 +238,11 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
@@ -392,10 +392,11 @@ extern "C" {
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
|
||||
Reference in New Issue
Block a user