I want to place some AP in a room who are there for a device to collect their MAC and RSSI.
That device sends the 3 nearest and strongest MACs with the RSSI to a Server which calculates the approximately location.
Now I want to reduce the TX Power to maybe get a more accurate location and hopefully no interference with an AP from a other room.
But when I try to set the TX Power nothing happens and it stays on the default power.
I don't really know where i have to set TX Power or if I am doing it right.
Code: Select all
#include <WiFi.h>
const char *ssid = "ESP32ap"; //SSID wird angelegt
const char *password = "12345678"; //Passwort wird angelegt
/*
//Set Static IP address
IPAddress local_IP(192, 168, 1, 184);
//Set Static Gateway IP address
IPAddress gateway(192, 168, 1, 1);
//Set Static Subnet IP address
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); // optional
IPAddress secondaryDNS(8, 8, 4, 4); // optional
*/
void WiFiEvent(WiFiEvent_t event){
Serial.printf("[WiFi-event] event: %d\n", event);
//Legt die Ausgaben für Events fest
switch (event){
case SYSTEM_EVENT_AP_START:
Serial.println("WiFi access point started");
Serial.println();
break;
case SYSTEM_EVENT_AP_STOP:
Serial.println("WiFi access point stopped");
Serial.println();
break;
case SYSTEM_EVENT_AP_STACONNECTED:
Serial.println("Client connected");
Serial.println();
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
Serial.println("Client disconnected");
Serial.println();
break;
case SYSTEM_EVENT_AP_STAIPASSIGNED:
Serial.println("Assigned IP address to client");
Serial.println();
break;
case SYSTEM_EVENT_AP_PROBEREQRECVED:
Serial.println("Received probe request");
Serial.println();
break;
default: break;
}
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Configuring access point...");
//Setzt den ESP32 in Access Point Mode und legt ssid und passwort fest
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid, password);
//Ausgabe der SSID
Serial.println();
Serial.print("AP SSID: ");
Serial.println(ssid);
WiFi.setTxPower(WIFI_POWER_2dBm);
//Nimmt die IP-Addresse vom ESP32 und gibt diese aus
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
//Ausgabe der MAC
Serial.print("AP MAC address: ");
Serial.println(WiFi.softAPmacAddress());
//Signalstärke
Serial.print("Signalstärke: ");
wifi_power_t tx_power;
tx_power=WiFi.getTxPower();
Serial.println(tx_power);
//Gibt Meldungen bei dem jeweiligen Event aus
WiFi.onEvent(WiFiEvent);
Serial.println();
}
void loop() {
/*
//Clients
Serial.print("Clients: ");
Serial.println(WiFi.softAPgetStationNum());
delay(20000);
*/
}