When no password is passed, connect to wifi but do not init web_workflow.

This commit is contained in:
Bill Sideris 2023-09-05 19:31:18 +03:00
parent 000d22f250
commit 9eaae37dfc
No known key found for this signature in database
GPG Key ID: 1BEF1BCEBA58EA33
1 changed files with 9 additions and 7 deletions

View File

@ -315,6 +315,15 @@ bool supervisor_start_web_workflow(void) {
// (leaves new_port unchanged on any failure)
(void)common_hal_os_getenv_int("CIRCUITPY_WEB_API_PORT", &web_api_port);
const size_t api_password_len = sizeof(_api_password) - 1;
result = common_hal_os_getenv_str("CIRCUITPY_WEB_API_PASSWORD", _api_password + 1, api_password_len);
if (result == GETENV_OK) {
_api_password[0] = ':';
_base64_in_place(_api_password, strlen(_api_password), sizeof(_api_password) - 1);
} else {
return false;
}
bool first_start = pool.base.type != &socketpool_socketpool_type;
if (first_start) {
@ -346,13 +355,6 @@ bool supervisor_start_web_workflow(void) {
}
#endif
const size_t api_password_len = sizeof(_api_password) - 1;
result = common_hal_os_getenv_str("CIRCUITPY_WEB_API_PASSWORD", _api_password + 1, api_password_len);
if (result == GETENV_OK) {
_api_password[0] = ':';
_base64_in_place(_api_password, strlen(_api_password), sizeof(_api_password) - 1);
}
if (common_hal_socketpool_socket_get_closed(&listening)) {
socketpool_socket(&pool, SOCKETPOOL_AF_INET, SOCKETPOOL_SOCK_STREAM, &listening);
common_hal_socketpool_socket_settimeout(&listening, 0);