daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ESP8266WiFi.h>
  2.  
  3. access_point_init(){
  4.     // Access Point Mode
  5.  
  6.     Serial.begin(115200);
  7.    IPAddress ip(192,168,1,254);
  8.    IPAddress gateway(192,168,1,1);
  9.    IPAddress subnet(255,255,255,0);
  10.    char* ssid     = "myssidname";
  11.    char* password = "12345678";
  12.  
  13.  
  14.    WiFi.softAPConfig(ip, gateway, subnet);
  15.    bool ret = WiFi.softAP(ssid, password);
  16.  
  17.    return ret;
  18. }
  19.  
  20.  
  21. void wifi_station_init(){
  22.  
  23.     // Station Mode
  24.     Serial.begin(115200);
  25.    Serial.printf("n");
  26.  
  27.    WiFi.begin(net_ssid, net_pwd_ssid);
  28.  
  29.    IPAddress ip(192,168,1,10);
  30.    IPAddress gateway(192,168,1,1);
  31.    IPAddress subnet(255,255,255,0);
  32.  
  33.     WiFi.config(ip, gateway, subnet);
  34.  
  35.    k = 0;
  36.    while ((WiFi.status() != WL_CONNECTED) && (k < 80)){
  37.       delay(250);
  38.       Serial.print('.');
  39.       k++;
  40.    }
  41.  
  42.    Serial.printf("n");
  43.    Serial.printf("IP address: ");
  44.    Serial.println(WiFi.localIP());
  45. }
  46.  
  47.  
  48. void setup()
  49. {
  50.     bool my_condition = false;
  51.     //...
  52.     // my_condition = myLoadFunction();
  53.     //...
  54.  
  55.    if (my_condition) {
  56.         access_point_init();
  57.    } else {
  58.       wifi_station_init();
  59.    }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top