mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-10 13:48:10 +00:00
Fix scanner telemetry (#262)
* Fix scanner telemetry * Take several samples per channel, keep maximum value
This commit is contained in:
parent
d7ef15d435
commit
8601149051
@ -18,8 +18,9 @@
|
|||||||
#include "iface_cc2500.h"
|
#include "iface_cc2500.h"
|
||||||
|
|
||||||
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
||||||
#define SCAN_CHANNEL_LOCK_TIME 300 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
#define SCAN_CHANNEL_LOCK_TIME 210 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
||||||
#define SCAN_AVERAGE_INTVL 30
|
#define SCAN_AVERAGE_INTVL 20
|
||||||
|
#define SCAN_MAX_COUNT 5
|
||||||
#define SCAN_CHANS_PER_PACKET 5
|
#define SCAN_CHANS_PER_PACKET 5
|
||||||
|
|
||||||
static uint8_t scan_tlm_index;
|
static uint8_t scan_tlm_index;
|
||||||
@ -96,25 +97,38 @@ static int __attribute__((unused)) Scanner_scan_rssi()
|
|||||||
|
|
||||||
uint16_t Scanner_callback()
|
uint16_t Scanner_callback()
|
||||||
{
|
{
|
||||||
|
static uint8_t max_count, max_rssi;
|
||||||
|
uint8_t rssi;
|
||||||
switch (phase)
|
switch (phase)
|
||||||
{
|
{
|
||||||
case SCAN_CHANNEL_CHANGE:
|
case SCAN_CHANNEL_CHANGE:
|
||||||
rf_ch_num++;
|
if(telemetry_link == 0) {
|
||||||
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
max_count = 0;
|
||||||
rf_ch_num = 0;
|
max_rssi = 0;
|
||||||
if (scan_tlm_index++ == 0)
|
rf_ch_num++;
|
||||||
pkt[0] = rf_ch_num; // start channel for telemetry packet
|
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
||||||
Scanner_scan_next();
|
rf_ch_num = 0;
|
||||||
phase = SCAN_GET_RSSI;
|
if (scan_tlm_index++ == 0)
|
||||||
|
pkt[0] = rf_ch_num; // start channel for telemetry packet
|
||||||
|
Scanner_scan_next();
|
||||||
|
phase = SCAN_GET_RSSI;
|
||||||
|
}
|
||||||
return SCAN_CHANNEL_LOCK_TIME;
|
return SCAN_CHANNEL_LOCK_TIME;
|
||||||
case SCAN_GET_RSSI:
|
case SCAN_GET_RSSI:
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
rssi = Scanner_scan_rssi();
|
||||||
pkt[scan_tlm_index] = Scanner_scan_rssi();
|
if(rssi >= max_rssi) {
|
||||||
if (scan_tlm_index == SCAN_CHANS_PER_PACKET)
|
max_rssi = rssi;
|
||||||
{
|
pkt[scan_tlm_index] = rssi;
|
||||||
// send data to TX
|
}
|
||||||
telemetry_link = 1;
|
max_count++;
|
||||||
scan_tlm_index = 0;
|
if(max_count > SCAN_MAX_COUNT) {
|
||||||
|
phase = SCAN_CHANNEL_CHANGE;
|
||||||
|
if (scan_tlm_index == SCAN_CHANS_PER_PACKET)
|
||||||
|
{
|
||||||
|
// send data to TX
|
||||||
|
telemetry_link = 1;
|
||||||
|
scan_tlm_index = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SCAN_AVERAGE_INTVL;
|
return SCAN_AVERAGE_INTVL;
|
||||||
@ -124,6 +138,7 @@ uint16_t initScanner(void)
|
|||||||
{
|
{
|
||||||
rf_ch_num = SCAN_MAX_RADIOCHANNEL;
|
rf_ch_num = SCAN_MAX_RADIOCHANNEL;
|
||||||
scan_tlm_index = 0;
|
scan_tlm_index = 0;
|
||||||
|
telemetry_link = 0;
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
phase = SCAN_CHANNEL_CHANGE;
|
||||||
Scanner_cc2500_init();
|
Scanner_cc2500_init();
|
||||||
CC2500_Strobe(CC2500_SRX);
|
CC2500_Strobe(CC2500_SRX);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user