1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-26 15:54:15 +01:00

Merged in webbbn/librepilot/LP-506-remove-pair-stats-from-rfm22b-cod (pull request #414)

LP-506 Removes pair stats from oplink code.

Approved-by: Lalanne Laurent <f5soh@free.fr>
Approved-by: Alessio Morale <alessiomorale@gmail.com>
Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
This commit is contained in:
Brian Webb 2017-04-22 17:36:05 +00:00 committed by Alessio Morale
commit a22809f52e
6 changed files with 4 additions and 94 deletions

View File

@ -149,9 +149,6 @@ static void systemTask(__attribute__((unused)) void *parameters)
OPLinkStatusData oplinkStatus;
OPLinkStatusGet(&oplinkStatus);
// Get the other device stats.
PIOS_RFM22B_GetPairStats(pios_rfm22b_id, oplinkStatus.PairIDs, oplinkStatus.PairSignalStrengths, OPLINKSTATUS_PAIRIDS_NUMELEM);
// Get the stats from the radio device
struct rfm22b_stats radio_stats;
PIOS_RFM22B_GetStats(pios_rfm22b_id, &radio_stats);

View File

@ -287,9 +287,6 @@ static void systemTask(__attribute__((unused)) void *parameters)
oplinkStatus.HeapRemaining = xPortGetFreeHeapSize();
if (pios_rfm22b_id) {
// Get the other device stats.
PIOS_RFM22B_GetPairStats(pios_rfm22b_id, oplinkStatus.PairIDs, oplinkStatus.PairSignalStrengths, OPLINKSTATUS_PAIRIDS_NUMELEM);
// Get the stats from the radio device
struct rfm22b_stats radio_stats;
PIOS_RFM22B_GetStats(pios_rfm22b_id, &radio_stats);

View File

@ -192,7 +192,6 @@ static void rfm22b_add_rx_status(struct pios_rfm22b_dev *rfm22b_dev, enum pios_r
static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, uint8_t init_chan, uint32_t frequency_hz);
static bool rfm22_setFreqHopChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t channel);
static void rfm22_generateDeviceID(struct pios_rfm22b_dev *rfm22b_dev);
static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev);
static void rfm22_updateStats(struct pios_rfm22b_dev *rfm22b_dev);
static bool rfm22_checkTimeOut(struct pios_rfm22b_dev *rfm22b_dev);
static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev);
@ -694,31 +693,6 @@ void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats)
*stats = rfm22b_dev->stats;
}
/**
* Get the stats of the oter radio devices that are in range.
*
* @param[out] device_ids A pointer to the array to store the device IDs.
* @param[out] RSSIs A pointer to the array to store the RSSI values in.
* @param[in] mx_pairs The length of the pdevice_ids and RSSIs arrays.
* @return The number of pair stats returned.
*/
uint8_t PIOS_RFM22B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs)
{
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
if (!PIOS_RFM22B_Validate(rfm22b_dev)) {
return 0;
}
uint8_t mp = (max_pairs >= OPLINKSTATUS_PAIRIDS_NUMELEM) ? max_pairs : OPLINKSTATUS_PAIRIDS_NUMELEM;
for (uint8_t i = 0; i < mp; ++i) {
device_ids[i] = rfm22b_dev->pair_stats[i].pairID;
RSSIs[i] = rfm22b_dev->pair_stats[i].rssi;
}
return mp;
}
/**
* Check the radio device for a valid connection
*
@ -1000,9 +974,6 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id)
// Increment the total byte received count.
rfm22b_dev->stats.rx_byte_count += rfm22b_dev->rx_buffer_wr;
// Update the pair status with this packet.
rfm22_updatePairStatus(rfm22b_dev);
// We're finished with Rx mode
rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION;
@ -1366,14 +1337,6 @@ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev)
// Clean the LEDs
rfm22_clearLEDs();
// Initialize the detected device statistics.
for (uint8_t i = 0; i < OPLINKSTATUS_PAIRIDS_NUMELEM; ++i) {
rfm22b_dev->pair_stats[i].pairID = 0;
rfm22b_dev->pair_stats[i].rssi = -127;
rfm22b_dev->pair_stats[i].afc_correction = 0;
rfm22b_dev->pair_stats[i].lastContact = 0;
}
// Initlize the link stats.
for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) {
rfm22b_dev->rx_packet_stats[i] = 0;
@ -2145,50 +2108,6 @@ static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev)
* Link Statistics Functions
*****************************************************************************/
/**
* Update the modem pair status.
*
* @param[in] rfm22b_dev The device structure
*/
static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev)
{
int8_t rssi = radio_dev->rssi_dBm;
int8_t afc = radio_dev->afc_correction_Hz;
uint32_t id = radio_dev->rx_destination_id;
// Have we seen this device recently?
bool found = false;
uint8_t id_idx = 0;
for (; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) {
if (radio_dev->pair_stats[id_idx].pairID == id) {
found = true;
break;
}
}
// If we have seen it, update the RSSI and reset the last contact counter
if (found) {
radio_dev->pair_stats[id_idx].rssi = rssi;
radio_dev->pair_stats[id_idx].afc_correction = afc;
radio_dev->pair_stats[id_idx].lastContact = 0;
} else {
// If we haven't seen it, find a slot to put it in.
uint8_t min_idx = 0;
int8_t min_rssi = radio_dev->pair_stats[0].rssi;
for (id_idx = 1; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) {
if (radio_dev->pair_stats[id_idx].rssi < min_rssi) {
min_rssi = radio_dev->pair_stats[id_idx].rssi;
min_idx = id_idx;
}
}
radio_dev->pair_stats[min_idx].pairID = id;
radio_dev->pair_stats[min_idx].rssi = rssi;
radio_dev->pair_stats[min_idx].afc_correction = afc;
radio_dev->pair_stats[min_idx].lastContact = 0;
}
}
/**
* Calculate stats from the packet receipt, transmission statistics.
*

View File

@ -110,7 +110,6 @@ extern void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id);
extern void PIOS_RFM22B_SetDeviceID(uint32_t rfm22b_id, uint32_t device_id);
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
extern void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats);
extern uint8_t PIOS_RFM22B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs);
extern bool PIOS_RFM22B_InRxWait(uint32_t rfb22b_id);
extern bool PIOS_RFM22B_LinkStatus(uint32_t rfm22b_id);
extern bool PIOS_RFM22B_ReceivePacket(uint32_t rfm22b_id, uint8_t *p);

View File

@ -200,9 +200,6 @@ struct pios_rfm22b_dev {
// The task handle
xTaskHandle taskHandle;
// The potential paired statistics
rfm22b_pair_stats pair_stats[OPLINKSTATUS_PAIRIDS_NUMELEM];
// ISR pending semaphore
xSemaphoreHandle isrPending;
@ -212,12 +209,15 @@ struct pios_rfm22b_dev {
pios_com_callback tx_out_cb;
uint32_t tx_out_context;
uint8_t last_stream_sent;
// The Aux COM callback functions.
pios_com_callback aux_rx_in_cb;
uint32_t aux_rx_in_context;
pios_com_callback aux_tx_out_cb;
uint32_t aux_tx_out_context;
// Send next packet on primary or aux channel?
bool last_stream_sent;
// the transmit power to use for data transmissions
uint8_t tx_power;

View File

@ -25,8 +25,6 @@
<field name="TXSeq" units="" type="uint16" elements="1" defaultvalue="0"/>
<field name="RXSeq" units="" type="uint16" elements="1" defaultvalue="0"/>
<field name="LinkState" units="function" type="enum" elements="1" options="Disabled,Enabled,Binding,Bound,Disconnected,Connecting,Connected" defaultvalue="Disabled"/>
<field name="PairIDs" units="hex" type="uint32" elements="4" defaultvalue="0"/>
<field name="PairSignalStrengths" units="dBm" type="int8" elements="4" defaultvalue="-127"/>
<field name="TXPacketRate" units="packet/s" type="uint16" elements="1" defaultvalue="0"/>
<field name="RXPacketRate" units="packet/s" type="uint16" elements="1" defaultvalue="0"/>