I am trying to retrieve the RSSI value of the 4 closest Wifi network using my Node MCU 8266 board.
The goal is to: scan for Wifi networks. get the 4 best networks in an array. loop through the array and return each RSSI value in %, every second or so.
I get the following error (see below), what is wrong?
#include "ESP8266WiFi.h"
int nb_mapped =4;
int i =0;
void setup() {
Serial.begin(115200);
int numberOfNetworks = WiFi.scanNetworks();
}
void loop() {
i = 0;
for(i; i<nb_mapped; i++){
int map_sig = call(i);
Serial.println(map_sig);
}
delay(5);
}
int call(i) {
int best_rssi = -20;
int worst_rssi = -70;
int dBm = WiFi.RSSI(i);
if (dBm <= worst_rssi)
return 0;
if (dBm >= best_rssi)
return 255;
return map(dBm, worst_rssi, best_rssi, 0, 255);
}
... and the error i get
Arduino: 1.8.19 (Mac OS X), TD: 1.56, Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
/var/folders/22/1k50_mf96zb686jpt40dnt2w0000gn/T/arduino_modified_sketch_240056/WiFiScan.ino: In function 'void loop()':
WiFiScan:19:24: error: 'call' cannot be used as a function
19 | int map_sig = call(i);
| ^
/var/folders/22/1k50_mf96zb686jpt40dnt2w0000gn/T/arduino_modified_sketch_240056/WiFiScan.ino: At global scope:
WiFiScan:26:5: error: redefinition of 'int call'
26 | int call(i) {
| ^~~~
/var/folders/22/1k50_mf96zb686jpt40dnt2w0000gn/T/arduino_modified_sketch_240056/WiFiScan.ino:26:5: note: 'int call' previously declared here
26 | int call(i) {
| ^~~~
exit status 1
'call' cannot be used as a function