abouttreesummaryrefslogcommitdiff
path: root/esp32/esp_project/main
diff options
context:
space:
mode:
Diffstat (limited to 'esp32/esp_project/main')
-rw-r--r--esp32/esp_project/main/CMakeLists.txt2
-rw-r--r--esp32/esp_project/main/main.c63
-rw-r--r--esp32/esp_project/main/wifi.c23
3 files changed, 14 insertions, 74 deletions
diff --git a/esp32/esp_project/main/CMakeLists.txt b/esp32/esp_project/main/CMakeLists.txt
index d0c6abb..ddba2b1 100644
--- a/esp32/esp_project/main/CMakeLists.txt
+++ b/esp32/esp_project/main/CMakeLists.txt
@@ -1,2 +1,2 @@
-idf_component_register(SRCS "main.c" "wifi.c"
+idf_component_register(SRCS "wifi.c" "Verify.c"
INCLUDE_DIRS "") \ No newline at end of file
diff --git a/esp32/esp_project/main/main.c b/esp32/esp_project/main/main.c
deleted file mode 100644
index b090849..0000000
--- a/esp32/esp_project/main/main.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: CC0-1.0
- */
-
-#define OLMLIB_VERSION_MAJOR 3
-#define OLMLIB_VERSION_MINOR 2
-#define OLMLIB_VERSION_PATCH 15
-
-#define OLM_STATIC_DEFINE
-
-#include <mongoose.h>
-#include <olm/olm.h>
-#include <matrix.h>
-
-#include <esp_wifi.h>
-
-#define SERVER "https://matrix.org"
-#define USER_ID "@pscho:matrix.org"
-#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org"
-
-void
-app_main(void)
-{
- MatrixClient client;
- MatrixClientInit(&client,
- SERVER);
-
- MatrixHttpInit(&client);
-
- MatrixClientSetUserId(&client, USER_ID);
-
- MatrixClientLoginPassword(&client,
- "pscho",
- "Wc23EbmB9G3faMq",
- "Test1");
-
- MatrixClientUploadDeviceKey(&client);
- MatrixClientGenerateOnetimeKeys(&client, 10);
- MatrixClientUploadOnetimeKeys(&client);
-
- // create megolmsession
- MatrixMegolmOutSession * megolmOutSession;
- MatrixClientGetMegolmOutSession(&client,
- ROOM_ID,
- &megolmOutSession);
- printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key);
-
- MatrixClientShareMegolmOutSession(&client,
- USER_ID,
- "ULZZOKJBYN",
- megolmOutSession);
-
- MatrixClientSendEventEncrypted(&client,
- ROOM_ID,
- "m.room.message",
- "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");
-
- MatrixClientDeleteDevice(&client);
-
- MatrixHttpDeinit(&client);
-}
diff --git a/esp32/esp_project/main/wifi.c b/esp32/esp_project/main/wifi.c
index 07d1e41..788d61c 100644
--- a/esp32/esp_project/main/wifi.c
+++ b/esp32/esp_project/main/wifi.c
@@ -1,4 +1,9 @@
-// Code taken from the ESP32 IDF WiFi station Example
+/*
+ * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: CC0-1.0
+ */
+
#include <string.h>
#include "esp_event.h"
@@ -13,8 +18,6 @@
#include "lwip/err.h"
#include "lwip/sys.h"
-#include "mongoose.h"
-
static EventGroupHandle_t s_wifi_event_group;
/* The event group allows multiple bits for each event, but we only care about
@@ -35,14 +38,14 @@ static void event_handler(void *arg, esp_event_base_t event_base,
if (s_retry_num < 3) {
esp_wifi_connect();
s_retry_num++;
- MG_INFO(("retry to connect to the AP"));
+ printf("retry to connect to the AP\n");
} else {
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
}
- MG_ERROR(("connect to the AP fail"));
+ printf("connect to the AP fail\n");
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
- MG_INFO(("IP ADDRESS:" IPSTR, IP2STR(&event->ip_info.ip)));
+ printf("IP ADDRESS:" IPSTR "\n", IP2STR(&event->ip_info.ip));
s_retry_num = 0;
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
}
@@ -81,18 +84,18 @@ void wifi_init(const char *ssid, const char *pass) {
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &c));
ESP_ERROR_CHECK(esp_wifi_start());
- MG_DEBUG(("wifi_init_sta finished."));
+ printf("wifi_init_sta finished.\n");
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
pdFALSE, pdFALSE, portMAX_DELAY);
if (bits & WIFI_CONNECTED_BIT) {
- MG_INFO(("connected to ap SSID:%s password:%s", ssid, pass));
+ printf("connected to ap SSID:%s password:%s\n", ssid, pass);
} else if (bits & WIFI_FAIL_BIT) {
- MG_ERROR(("Failed to connect to SSID:%s, password:%s", ssid, pass));
+ printf("Failed to connect to SSID:%s, password:%s\n", ssid, pass);
} else {
- MG_ERROR(("UNEXPECTED EVENT"));
+ printf("UNEXPECTED EVENT\n");
}
/* The event will not be processed after unregister */