Skip to content

Commit

Permalink
example astyled
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v committed Apr 26, 2018
1 parent 4f5c020 commit f654a23
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions libraries/esp8266/examples/interactive/interactive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Interactive script meant for debugging only
Run it on serial console and keep this source file opened for the list of commands
Please configure SSID, PSK and IPAddresses below to fit with your network
Released to public domain
*/

Expand All @@ -17,16 +17,14 @@ IPAddress staticip(192, 168, 1, 123);
IPAddress gateway(192, 168, 1, 254);
IPAddress subnet(255, 255, 255, 0);

void setup()
{
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);

WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PSK);
Serial.println("connecting");
while (WiFi.status() != WL_CONNECTED)
{
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Expand All @@ -43,25 +41,22 @@ void setup()
);
}

void WiFiOn ()
{
void WiFiOn() {
wifi_fpm_do_wakeup();
wifi_fpm_close();
wifi_set_opmode(STATION_MODE);
wifi_station_connect();
}

void WiFiOff ()
{
void WiFiOff() {
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE);
wifi_set_sleep_type(MODEM_SLEEP_T);
wifi_fpm_open();
wifi_fpm_do_sleep(0xFFFFFFF);
}

void loop()
{
void loop() {
#define TEST(name, var, varinit, func) \
static decltype(func) var = (varinit); \
if ((var) != (func)) { var = (func); Serial.printf("**** %s: ", name); Serial.println(var); }
Expand All @@ -73,8 +68,7 @@ void loop()
TEST("STA-IP", localIp, (uint32_t)0, WiFi.localIP());
TEST("AP-IP", apIp, (uint32_t)0, WiFi.softAPIP());

switch (Serial.read())
{
switch (Serial.read()) {
case 'F': DO(WiFiOff());
case 'N': DO(WiFiOn());
case '1': DO(WiFi.mode(WIFI_AP));
Expand Down

0 comments on commit f654a23

Please sign in to comment.