diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 481e31b..cd61eed 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 40 +#define VERSION_PATCH_LEVEL 41 //****************** // Protocols diff --git a/Multiprotocol/Scanner_cc2500.ino b/Multiprotocol/Scanner_cc2500.ino index 33725f2..fa7c416 100644 --- a/Multiprotocol/Scanner_cc2500.ino +++ b/Multiprotocol/Scanner_cc2500.ino @@ -18,13 +18,11 @@ #include "iface_cc2500.h" #define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz -#define SCAN_CHANNEL_LOCK_TIME 210 // with precalibration, channel requires only 90 usec for synthesizer to settle +#define SCAN_CHANNEL_LOCK_TIME 90 // with precalibration, channel requires only 90 usec for synthesizer to settle #define SCAN_AVERAGE_INTVL 20 #define SCAN_MAX_COUNT 10 #define SCAN_CHANS_PER_PACKET 5 -static uint8_t scan_tlm_index; - enum ScanStates { SCAN_CHANNEL_CHANGE = 0, SCAN_GET_RSSI = 1, @@ -97,49 +95,46 @@ static int __attribute__((unused)) Scanner_scan_rssi() uint16_t Scanner_callback() { - static uint8_t max_count, max_rssi; - uint8_t rssi; - switch (phase) - { - case SCAN_CHANNEL_CHANGE: - if(telemetry_link == 0) { - max_count = 0; - max_rssi = 0; - rf_ch_num++; - if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1)) - rf_ch_num = 0; - if (scan_tlm_index++ == 0) - packet_in[0] = rf_ch_num; // start channel for telemetry packet - Scanner_scan_next(); - phase = SCAN_GET_RSSI; - } - return SCAN_CHANNEL_LOCK_TIME; - case SCAN_GET_RSSI: - rssi = Scanner_scan_rssi(); - if(rssi >= max_rssi) { - max_rssi = rssi; - packet_in[scan_tlm_index] = rssi; - } - max_count++; - 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; - } + uint8_t rssi,max_rssi; + + //!!!Blocking mode protocol!!! + TX_MAIN_PAUSE_off; + tx_resume(); + while(1) + { //Start + packet_in[0] = rf_ch_num; // start channel for telemetry packet + for(uint8_t i=0;i= max_rssi) max_rssi = rssi; + delayMicroseconds(SCAN_AVERAGE_INTVL); // wait before next read } + packet_in[i+1] = max_rssi; + //next channel + rf_ch_num++; + if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1)) + rf_ch_num = 0; + } + telemetry_link = 1; + do + { + if(Update_All()) + return 1000; // protocol has changed, give back the control to main + } + while(telemetry_link == 1); } - return SCAN_AVERAGE_INTVL; + return 0; } uint16_t initScanner(void) { - rf_ch_num = SCAN_MAX_RADIOCHANNEL; - scan_tlm_index = 0; + rf_ch_num = 0; telemetry_link = 0; - phase = SCAN_CHANNEL_CHANGE; Scanner_cc2500_init(); CC2500_Strobe(CC2500_SRX); Scanner_calibrate(); diff --git a/Multiprotocol/Telemetry.ino b/Multiprotocol/Telemetry.ino index bb197cb..edc6511 100644 --- a/Multiprotocol/Telemetry.ino +++ b/Multiprotocol/Telemetry.ino @@ -836,7 +836,7 @@ void TelemetryUpdate() t -= h ; if ( t < 32 ) { - //debugln("TEL_BUF_FULL %d",t); + debugln("TEL_BUF_FULL %d",t); return ; } /* else @@ -846,7 +846,7 @@ void TelemetryUpdate() #endif #if defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) uint32_t now = millis(); - if (IS_SEND_MULTI_STATUS_on || ((now - lastMulti) > MULTI_TIME)) + if ((IS_SEND_MULTI_STATUS_on || ((now - lastMulti) > MULTI_TIME))&& protocol != PROTO_SCANNER) { multi_send_status(); SEND_MULTI_STATUS_off;