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