Linux esp8266 driver c source code - AP 모드로 softAP

 임베디드 리눅스의 사용자 모드에서 동작하는 esp8266 드라이버를 만들고 있다.

linux용 esp8266 드라이버 c source code - smartconfig
Linux esp8266 driver c source code - client TCP, UDP
Linux esp8266 driver c source code - TCP Server

본 포스트에서는 esp8266을 AP로 사용하는 SoftAP모드를 구현하고 테스트했다.



SoftAP Mode

ESP8266의 SoftAP 모드는 아래 커맨드를 사용하여 설정한다.

AT+CWMODE_CUR=<mode>

<mode>를 1로 하면 Station Mode, 2는 SoftAP Mode, 3이면 SoftAP+Station Mode이다.

[note] 3번 SoftAP+Station 모드는 테스트해보지 못했다.



SoftAP 설정

AT+CWSAP_CUR=<ssid>,<pwd>,<chl>,<ecn>[,<max conn>][,<ssid hidden>]

AT+CWSAP_CUR 커맨드를 사용하면 AP의 SSID 및 패스워드, 채널, 암호화 방식 등을 설정할 수 있다.

파라미터 

  • <ssid>: AP의 SSID.
  • <pwd>: 패스워드, 8 ~ 64 바이트 ASCII.
  •  <chl>: 채널 ID.
  •  <ecn>: 암호화 방식, WEP는 지원하지 않는다.
    • 0: OPEN
    • 2: WPA_PSK
    • 3: WPA2_PSK
    • 4: WPA_WPA2_PSK
  •  [<max conn>] (optional): 최대 연결 기기 수
  •  [<ssid hidden>] (optional): SSID를 숨길지 여부를 선택
    • 0: SSID is broadcasted. (the default setting)
    • 1: SSID is not broadcasted



DHCP 설정

DHCP 사용 여부는 다음 커맨드를 사용한다.

AT+CWDHCP_CUR=<mode>,<en>

파라미터

  • <mode>:
    • 0: ESP8266 SoftAP
    • 1: ESP8266 Station
    • 2: SoftAP and Station
  • <en>:
    • 0: Disables DHCP
    • 1: Enables DHCP



ESP8266 Driver C Source

esp8266.softap.h
esp8266.softap.c



ESP8266 SoftAP 모드 사용 예제

드라이버에서 SoftAP 사용 여부는 esp8266_param의 APmode의 설정을 따른다. 또한, AP 모드를 사용할 때 반드시 esp8266_param.ssid와 esp8266_param.pwd를 설정해야 한다. 

Station 모드 사용 코드 예제


SoftAP 모드 사용 코드 예제

위 코드를 실행하면 아래와 같은 로그가 출력되고, 'esp8266softap'이름의 AP가 검색된다. 


windows에 검색된 wifi AP 리스트에서 'esp8266softap'를 볼 수 있다.

연결하면 아래와 같이 연결된다.


AP 모드에서의 TCP/UDP연결 몇 TCP Server등은 Station Mode 그대로 사용할 수 있다. 아래는 AP 모드에서 TCP Server 예제를 동작시킨 결과 로그다.


댓글

이 블로그의 인기 게시물

간단한 cfar 알고리즘에 대해

windows에서 간단하게 크롬캐스트(Chromecast)를 통해 윈도우 화면 미러링 방법

python ctypes LoadLibrary로 windows dll 로드 및 함수 호출 예제

아두이노(arduino) 심박센서 (heart rate sensor) 심박수 측정 example code

base64 인코딩 디코딩 예제 c 소스