With the normal code, I can set it with:
WiFi.setOutputPower(21.5);
I want the code to be fast, to make a location based system with a esp sending with high and low TX radio .
Now I want to set it im my other code, like:
if(high)
system_phy_set_rfoption(22.0);
else
system_phy_set_rfoption(0.0);
Maybe I have to edit the wifipkt[], but I don't know where to start
Not working
#include <ESP8266WiFi.h>
extern "C" {
#include "user_interface.h"
}
byte channel;
int maxssids=10; /* how much SSIDs we have */
char *ssids[] = {
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten"
};
byte rnd;
byte i;
byte count;
byte wifipkt[128] = { 0x80, 0x00, 0x00, 0x00,
/*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
/*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
/*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
/*22*/ 0xc0, 0x6c,
/*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00,
/*32*/ 0x64, 0x00,
/*34*/ 0x01, 0x04,
/* SSID */
/*36*/ 0x00};
byte pktsuffix[] = {
0x01, 0x08, 0x82, 0x84,
0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, 0x03, 0x01,
0x04 };
void setup() {
delay(500);
wifi_set_opmode(STATION_MODE);
wifi_promiscuous_enable(1);
}
void loop() {
wifipkt[10] = wifipkt[16] = count; //random(256);
wifipkt[11] = wifipkt[17] = count; //random(256);
wifipkt[12] = wifipkt[18] = count; //random(256);
wifipkt[13] = wifipkt[19] = count; //random(256);
wifipkt[14] = wifipkt[20] = count; //random(256);
wifipkt[15] = wifipkt[21] = count; //random(256);
count=37;
rnd=random(maxssids);
wifipkt[count++]=strlen(ssids[rnd]);
for (i=0; i<strlen(ssids[rnd]); i++) {
wifipkt[count++]=ssids[rnd][i];
}
for (i=0; i<sizeof(pktsuffix); i++) {
wifipkt[count++]=pktsuffix[i];
}
channel = random(1,12);
wifi_set_channel(channel);
wifipkt[count-1] = channel;
wifipkt[34] = 127;
wifi_send_pkt_freedom(wifipkt, count, 0);
wifi_send_pkt_freedom(wifipkt, count, 0);
wifi_send_pkt_freedom(wifipkt, count, 0);
delay(1);
}
This one it is working, but not with wifi_send_pkt_freedom...
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
wifi_set_channel(12);
}
void loop() {
if(high) {
WiFi.setOutputPower(21.5);
wifi_set_channel(1);
} else {
WiFi.setOutputPower(0.0);
wifi_set_channel(12);
}
delay(5000);
high = !high;
}