top of page
블로그: Blog2

코인 Ticker 만들기 #12.AP모드_소스설명

최종 수정일: 2019년 1월 24일

이번 강좌에서는 AP모드 샘플소스에 대해 설명드리는 시간을 갖도록 하겠습니다.


소스에 주석으로 설명을 달아놓았습니다.



// ESP8266 Wifi, AP모드, 웹서버 관련 헤더를 참조합니다.

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

#include <ESP8266WebServer.h>


const char *ssid = "ESPap"; // Wifi의 SSID 를 설정합니다.

const char *password = "thereisnospoon"; // 비밀번호를 설정합니다.


ESP8266WebServer server(80); // 웹서버는 80포트를 이용합니다.


void handleRoot() {

// 웹서버에 접속하면 You are connected 메시지를 보여줍니다.

server.send(200, "text/html", "<h1>You are connected</h1>");

}


void setup() {

delay(1000);

Serial.begin(115200);

Serial.println();

Serial.print("Configuring access point...");

WiFi.softAP(ssid, password); // AP 모드를 활성화 해줍니다.


IPAddress myIP = WiFi.softAPIP(); // 서버의 IP 주소를 받아옵니다.

Serial.print("AP IP address: ");

Serial.println(myIP); // AP 모드의 IP 주소를 시리얼로 출력해줍니다.

server.on("/", handleRoot); // 서버의 Root 위치를 설정합니다.

server.begin(); // 서버를 기동합니다.

Serial.println("HTTP server started"); // 서버가 기동되었음을 시리얼로 출력해 줍니다.

}


void loop() {

// 클라이언트(PC나 스마트폰)가 서버로 접속이 되면

// 클라이언트와의 연결을 생성하고 클라이언트의 요청을 처리합니다.

server.handleClient();

}



다음 강좌에서는 Station 모드에 대해서 배워보도록 하겠습니다.


감사합니다.

 
 
 

Comments


Join our mailing list

Never miss an update

뉴스레터 구독하기

최신 업데이트를 받아보세요!

대한민국 경기도 수원시 장안구 연무동 21 유천프라자 가동 508호

  • facebook
  • twitter
  • linkedin

©2018 by 윈드마켓. Proudly created with Wix.com

bottom of page