mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 20:50:05 +00:00
Add otPlatRadioGetReceiveSensitivity() API (#1715)
* Add otPlatRadioGetReceiveSensitivity() API * Add a new otPlatRadioGetReceiveSensitivity() API to get sensitivity value; * Use the receive sensitivity value as the noise floor for link metric computation; * Remove some unused noise floor related functions. * Add SPINEL_PROP_PHY_RX_SENSITIVITY Spinel/NCP property
This commit is contained in:
@@ -814,6 +814,31 @@ void otPlatRadioSetDefaultTxPower(_In_ otInstance *otCtx, int8_t aPower)
|
||||
}
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(_In_ otInstance *otCtx)
|
||||
{
|
||||
NT_ASSERT(otCtx);
|
||||
PMS_FILTER pFilter = otCtxToFilter(otCtx);
|
||||
NTSTATUS status;
|
||||
int8_t receiveSensitivity;
|
||||
|
||||
status =
|
||||
otLwfCmdGetProp(
|
||||
pFilter,
|
||||
NULL,
|
||||
SPINEL_PROP_PHY_RX_SENSITIVITY,
|
||||
SPINEL_DATATYPE_INT8_S,
|
||||
&receiveSensitivity
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Get SPINEL_PROP_PHY_RX_SENSITIVITY, failed, %!STATUS!", status);
|
||||
return -100; // return default value -100dBm
|
||||
}
|
||||
|
||||
return receiveSensitivity;
|
||||
}
|
||||
|
||||
inline USHORT getDstShortAddress(const UCHAR *frame)
|
||||
{
|
||||
return (((USHORT)frame[IEEE802154_DSTADDR_OFFSET + 1]) << 8) | frame[IEEE802154_DSTADDR_OFFSET];
|
||||
|
||||
@@ -62,6 +62,11 @@ enum
|
||||
CC2538_LQI_BIT_MASK = 0x7f,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CC2538_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static RadioPacket sTransmitFrame;
|
||||
static RadioPacket sReceiveFrame;
|
||||
static ThreadError sTransmitError;
|
||||
@@ -793,3 +798,9 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return CC2538_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
#include <driverlib/rf_ieee_cmd.h>
|
||||
#include <driverlib/chipinfo.h>
|
||||
|
||||
enum
|
||||
{
|
||||
CC2650_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
/* phy state as defined by openthread */
|
||||
static volatile cc2650_PhyState sState;
|
||||
|
||||
@@ -1799,3 +1804,9 @@ void cc2650RadioProcess(otInstance *aInstance)
|
||||
sReceiveFrame.mLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return CC2650_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@
|
||||
#define IEEE802154_ACK_REQUEST 1 << 5
|
||||
#define IEEE802154_DSN_OFFSET 2
|
||||
|
||||
enum
|
||||
{
|
||||
DA15000_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static otInstance *sThreadInstance;
|
||||
|
||||
static PhyState sRadioState = kStateDisabled;
|
||||
@@ -500,3 +505,8 @@ void FTDF_rcvFrameTransparent(FTDF_DataLength frameLength,
|
||||
}
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return DA15000_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,11 @@ enum
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EFR32_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static uint16_t sPanId = 0;
|
||||
static uint8_t sChannel = 0;
|
||||
static bool sTransmitBusy = false;
|
||||
@@ -842,3 +847,9 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
(void)aInstance;
|
||||
RAIL_TxPowerSet(aPower);
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return EFR32_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,11 @@
|
||||
#define SHORT_ADDRESS_SIZE 2
|
||||
#define EXTENDED_ADDRESS_SIZE 8
|
||||
|
||||
enum
|
||||
{
|
||||
NRF52840_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static bool sDisabled;
|
||||
|
||||
static RadioPacket sReceivedFrames[RADIO_RX_BUFFERS];
|
||||
@@ -608,3 +613,9 @@ void nrf_drv_radio802154_energy_detected(int8_t result)
|
||||
|
||||
setPendingEvent(kPendingEventEnergyDetected);
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return NRF52840_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,11 @@ enum
|
||||
IEEE802154_MACCMD_DATA_REQ = 4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSIX_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct RadioMessage
|
||||
{
|
||||
@@ -749,3 +754,9 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
|
||||
(void)aInstance;
|
||||
(void)aPower;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
return POSIX_RECEIVE_SENSITIVITY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user