diff --git a/bathroom-esp32/.vscode/settings.json b/bathroom-esp32/.vscode/settings.json index 989737b..b7fa1c1 100755 --- a/bathroom-esp32/.vscode/settings.json +++ b/bathroom-esp32/.vscode/settings.json @@ -12,7 +12,7 @@ "interface/ftdi/esp32_devkitj_v1.cfg", "target/esp32.cfg" ], - "idf.portWin": "COM8", + "idf.portWin": "COM7", "idf.pythonBinPathWin": "C:\\Projects\\Esp32\\espressif\\python_env\\idf5.3_py3.11_env\\Scripts\\python.exe", "idf.toolsPathWin": "C:\\Projects\\Esp32\\espressif", "idf.flashType": "UART" diff --git a/bathroom-esp32/.vscode/settings.json b/bathroom-esp32/.vscode/settings.json index 989737b..b7fa1c1 100755 --- a/bathroom-esp32/.vscode/settings.json +++ b/bathroom-esp32/.vscode/settings.json @@ -12,7 +12,7 @@ "interface/ftdi/esp32_devkitj_v1.cfg", "target/esp32.cfg" ], - "idf.portWin": "COM8", + "idf.portWin": "COM7", "idf.pythonBinPathWin": "C:\\Projects\\Esp32\\espressif\\python_env\\idf5.3_py3.11_env\\Scripts\\python.exe", "idf.toolsPathWin": "C:\\Projects\\Esp32\\espressif", "idf.flashType": "UART" diff --git a/bathroom-esp32/main/CMakeLists.txt b/bathroom-esp32/main/CMakeLists.txt index 353f2be..92a6850 100755 --- a/bathroom-esp32/main/CMakeLists.txt +++ b/bathroom-esp32/main/CMakeLists.txt @@ -2,4 +2,5 @@ INCLUDE_DIRS "." REQUIRES driver REQUIRES esp_wifi - REQUIRES nvs_flash) \ No newline at end of file + REQUIRES nvs_flash + REQUIRES mbedtls) \ No newline at end of file diff --git a/bathroom-esp32/.vscode/settings.json b/bathroom-esp32/.vscode/settings.json index 989737b..b7fa1c1 100755 --- a/bathroom-esp32/.vscode/settings.json +++ b/bathroom-esp32/.vscode/settings.json @@ -12,7 +12,7 @@ "interface/ftdi/esp32_devkitj_v1.cfg", "target/esp32.cfg" ], - "idf.portWin": "COM8", + "idf.portWin": "COM7", "idf.pythonBinPathWin": "C:\\Projects\\Esp32\\espressif\\python_env\\idf5.3_py3.11_env\\Scripts\\python.exe", "idf.toolsPathWin": "C:\\Projects\\Esp32\\espressif", "idf.flashType": "UART" diff --git a/bathroom-esp32/main/CMakeLists.txt b/bathroom-esp32/main/CMakeLists.txt index 353f2be..92a6850 100755 --- a/bathroom-esp32/main/CMakeLists.txt +++ b/bathroom-esp32/main/CMakeLists.txt @@ -2,4 +2,5 @@ INCLUDE_DIRS "." REQUIRES driver REQUIRES esp_wifi - REQUIRES nvs_flash) \ No newline at end of file + REQUIRES nvs_flash + REQUIRES mbedtls) \ No newline at end of file diff --git a/bathroom-esp32/main/main.c b/bathroom-esp32/main/main.c index e779e86..5751149 100755 --- a/bathroom-esp32/main/main.c +++ b/bathroom-esp32/main/main.c @@ -16,6 +16,7 @@ CONDITIONS OF ANY KIND, either express or implied. */ #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" @@ -28,6 +29,13 @@ #include "esp_err.h" #include "nvs_flash.h" +#include "mbedtls/pk.h" +#include "mbedtls/rsa.h" +#include "mbedtls/error.h" +#include "mbedtls/base64.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" + static const char *TAG = "example"; /* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink, @@ -169,8 +177,8 @@ wifi_config_t wifi_config = { .sta = { - .ssid = "UpstairsNetwork", - .password = "YtwlpNKM6egI5S", + .ssid = "DJArtsGames", + .password = "yubyubechubab", /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8). * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to @@ -208,6 +216,35 @@ } } +// From: https://gist.github.com/VNovytskyi/e6d29b3d473a41141e27059a25e64100 +size_t get_decoded_size(const char *base64_str_p) +{ + if (base64_str_p == NULL) + { + return 0; + } + + size_t pad_char_count = 0; + size_t base64_str_len = strlen(base64_str_p); + + if ((base64_str_len < 4) || (base64_str_len % 4 != 0)) + { + return 0; + } + + if (base64_str_p[base64_str_len - 1] == '=') + { + pad_char_count++; + } + + if (base64_str_p[base64_str_len - 2] == '=') + { + pad_char_count++; + } + + return (3 * (base64_str_len / 4)) - pad_char_count; +} + void app_main(void) { //Initialize NVS