|
@@ -13,6 +13,7 @@
|
13
|
13
|
#include <EEPROM.h>
|
14
|
14
|
#include "iface_cc2500.h"
|
15
|
15
|
//#define DEBUG
|
|
16
|
+//#define DEBUG_RSSI
|
16
|
17
|
//#define DEBUG0
|
17
|
18
|
//#define DEBUG1
|
18
|
19
|
//#define DEBUG2
|
|
@@ -30,8 +31,9 @@
|
30
|
31
|
|
31
|
32
|
// Used for RSSI_OVER_PPM
|
32
|
33
|
int rssi;
|
33
|
|
-int rssi_min = -114;
|
34
|
|
-int rssi_max = -79;
|
|
34
|
+const int rssi_offset = 71;
|
|
35
|
+const int rssi_min = -103;
|
|
36
|
+const int rssi_max = -96;
|
35
|
37
|
|
36
|
38
|
#define chanel_number 8 //set the number of chanels
|
37
|
39
|
#define SEEK_CHANSKIP 13
|
|
@@ -192,26 +194,20 @@ void setup()
|
192
|
194
|
|
193
|
195
|
void updateRSSI() {
|
194
|
196
|
#if defined(RSSI_OVER_PPM)
|
195
|
|
- rssi = cc2500_readReg(CC2500_34_RSSI | CC2500_READ_BURST);
|
196
|
|
- if (rssi < 128) {
|
197
|
|
- rssi = ((rssi / 2) - 74) & 0x7f;
|
|
197
|
+ int rssi_dec = cc2500_readReg(CC2500_34_RSSI | CC2500_READ_BURST);
|
|
198
|
+ if (rssi_dec < 128) {
|
|
199
|
+ rssi = ((rssi_dec / 2) - rssi_offset) & 0x7f;
|
198
|
200
|
} else {
|
199
|
|
- rssi = (((rssi - 256) / 2)) - 74;
|
200
|
|
- }
|
201
|
|
- int old_rssi_min = rssi_min;
|
202
|
|
- int old_rssi_max = rssi_max;
|
203
|
|
- rssi_min = min(rssi_min, rssi);
|
204
|
|
- rssi_max = max(rssi_max, rssi);
|
205
|
|
- #if defined(DEBUG)
|
206
|
|
- if (rssi_min != old_rssi_min || rssi_max != old_rssi_max) {
|
207
|
|
- Serial.print("RSSI: ");
|
208
|
|
- Serial.print(rssi);
|
209
|
|
- Serial.print(", min=");
|
210
|
|
- Serial.print(rssi_min);
|
211
|
|
- Serial.print(", max=");
|
212
|
|
- Serial.println(rssi_max);
|
|
201
|
+ rssi = (((rssi_dec - 256) / 2)) - rssi_offset;
|
213
|
202
|
}
|
|
203
|
+
|
|
204
|
+ #if defined(DEBUG_RSSI2)
|
|
205
|
+ Serial.print(millis());
|
|
206
|
+ Serial.print("\t");
|
|
207
|
+ Serial.println(rssi);
|
214
|
208
|
#endif
|
|
209
|
+
|
|
210
|
+ rssi = constrain(rssi, rssi_min, rssi_max);
|
215
|
211
|
#endif
|
216
|
212
|
}
|
217
|
213
|
|