• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# lws minimal http client captive portal detect
2
3This demonstrates how to perform captive portal detection integrated
4with `lws_system` states.
5
6After reaching the `lws_system` DHCP state, the application tries to
7connect through to `http://connectivitycheck.android.com/generate_204`
8over http... if it succeeds, it will get a 204 response and set the
9captive portal detection state to `LWS_CPD_INTERNET_OK` and perform
10a GET from warmcat.com.
11
12If there is a problem detected, the captive portal detection state is
13set accordingly and the app will respond by exiting without trying the
14read from warmcat.com.
15
16The captive portal detection scheme is implemented in the user code
17and can be modified according to the strategy that's desired for
18captive portal detection.
19
20## build
21
22```
23 $ cmake . && make
24```
25
26## usage
27
28```
29$ ./bin/lws-minimal-http-client-captive-portal
30[2020/03/11 13:07:07:4519] U: LWS minimal http client captive portal detect
31[2020/03/11 13:07:07:4519] N: lws_create_context: using ss proxy bind '(null)', port 0, ads '(null)'
32[2020/03/11 13:07:07:5022] U: callback_cpd_http: established with resp 204
33[2020/03/11 13:07:07:5023] U: app_system_state_nf: OPERATIONAL, cpd 1
34[2020/03/11 13:07:07:5896] U: Connected to 46.105.127.147, http response: 200
35[2020/03/11 13:07:07:5931] U: RECEIVE_CLIENT_HTTP_READ: read 4087
36[2020/03/11 13:07:07:5931] U: RECEIVE_CLIENT_HTTP_READ: read 4096
37[2020/03/11 13:07:07:6092] U: RECEIVE_CLIENT_HTTP_READ: read 4087
38[2020/03/11 13:07:07:6092] U: RECEIVE_CLIENT_HTTP_READ: read 4096
39[2020/03/11 13:07:07:6112] U: RECEIVE_CLIENT_HTTP_READ: read 4087
40[2020/03/11 13:07:07:6113] U: RECEIVE_CLIENT_HTTP_READ: read 4096
41[2020/03/11 13:07:07:6113] U: RECEIVE_CLIENT_HTTP_READ: read 2657
42[2020/03/11 13:07:07:6113] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP
43[2020/03/11 13:07:07:6119] U: main: finished OK
44```
45
46