abouttreesummaryrefslogcommitdiff
path: root/esp32/esp_project
diff options
context:
space:
mode:
authorpatrick-scho2023-11-14 12:59:51 +0100
committerpatrick-scho2023-11-14 12:59:51 +0100
commit58e0d63958d7406b7bbf3b964d9ea9a2770e0741 (patch)
tree4edc79e383a5e0b1877b3bdc86f0f17ebdb8643a /esp32/esp_project
parent9030210ff764c36cb6b0c1dacf40b016bab90d7c (diff)
downloadmatrix_esp_thesis-58e0d63958d7406b7bbf3b964d9ea9a2770e0741.tar.gz
matrix_esp_thesis-58e0d63958d7406b7bbf3b964d9ea9a2770e0741.zip
update esp examples
Diffstat (limited to 'esp32/esp_project')
-rw-r--r--esp32/esp_project/main/CMakeLists.txt2
-rw-r--r--esp32/esp_project/main/SendEncrypted.c45
-rw-r--r--esp32/esp_project/main/Verify.c35
3 files changed, 43 insertions, 39 deletions
diff --git a/esp32/esp_project/main/CMakeLists.txt b/esp32/esp_project/main/CMakeLists.txt
index ddba2b1..49944e8 100644
--- a/esp32/esp_project/main/CMakeLists.txt
+++ b/esp32/esp_project/main/CMakeLists.txt
@@ -1,2 +1,2 @@
-idf_component_register(SRCS "wifi.c" "Verify.c"
+idf_component_register(SRCS "wifi.c" "SendEncrypted.c"
INCLUDE_DIRS "") \ No newline at end of file
diff --git a/esp32/esp_project/main/SendEncrypted.c b/esp32/esp_project/main/SendEncrypted.c
index 11e9e0d..4142917 100644
--- a/esp32/esp_project/main/SendEncrypted.c
+++ b/esp32/esp_project/main/SendEncrypted.c
@@ -7,49 +7,54 @@
#include <stdio.h>
#include <matrix.h>
-#define SERVER "https://matrix.org"
-#define USER_ID "@pscho:matrix.org"
-#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org"
+#define SERVER "https://matrix.org"
+#define USER_ID "@example:matrix.org"
+#define ROOM_ID "!example:matrix.org"
+#define USERNAME ""
+#define PASSWORD ""
+#define DEVICE_NAME ""
+#define WIFI_SSID ""
+#define WIFI_PASSWORD ""
int
main(void)
{
- MatrixClient client;
- MatrixClientInit(&client);
+ MatrixClient * client = (MatrixClient*)malloc(sizeof(MatrixClient));
+ MatrixClientInit(client);
- MatrixHttpInit(&client.hc, SERVER);
+ MatrixHttpInit(&client->hc, SERVER);
- MatrixClientSetUserId(&client, USER_ID);
+ MatrixClientSetUserId(client, USER_ID);
- MatrixClientLoginPassword(&client,
- "pscho",
- "Wc23EbmB9G3faMq",
- "Test1");
+ MatrixClientLoginPassword(client,
+ USERNAME,
+ PASSWORD,
+ DEVICE_NAME);
- MatrixClientUploadDeviceKeys(&client);
- MatrixClientGenerateOnetimeKeys(&client, 10);
- MatrixClientUploadOnetimeKeys(&client);
+ MatrixClientUploadDeviceKeys(client);
+ MatrixClientGenerateOnetimeKeys(client, 10);
+ MatrixClientUploadOnetimeKeys(client);
// create megolmsession
MatrixMegolmOutSession * megolmOutSession;
- MatrixClientNewMegolmOutSession(&client,
+ MatrixClientNewMegolmOutSession(client,
ROOM_ID,
&megolmOutSession);
printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key);
- MatrixClientShareMegolmOutSession(&client,
+ MatrixClientShareMegolmOutSession(client,
USER_ID,
"ULZZOKJBYN",
megolmOutSession);
- MatrixClientSendEventEncrypted(&client,
+ MatrixClientSendEventEncrypted(client,
ROOM_ID,
"m.room.message",
"{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");
- MatrixClientDeleteDevice(&client);
+ MatrixClientDeleteDevice(client);
- MatrixHttpDeinit(&client.hc);
+ MatrixHttpDeinit(&client->hc);
return 0;
}
@@ -59,7 +64,7 @@ main(void)
void
app_main(void)
{
- wifi_init("Hundehuette", "Affensicherespw55");
+ wifi_init(WIFI_SSID, WIFI_PASSWORD);
main();
}
diff --git a/esp32/esp_project/main/Verify.c b/esp32/esp_project/main/Verify.c
index cda5709..a5ddbcd 100644
--- a/esp32/esp_project/main/Verify.c
+++ b/esp32/esp_project/main/Verify.c
@@ -11,21 +11,22 @@
#include <stdio.h>
-#define SERVER "https://matrix.org"
-#define USER_ID "@pscho:matrix.org"
-
-#define DEVICE_ID "ULZZOKJBYN"
-#define SENDER_KEY "cjP41XzRlY+pd8DoiBuKQJj9o15mrx6gkrpqTkAPZ2c"
-#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org"
-#define EVENT_ID "$vOS09eUaI0CduqAcaIU5ZVk6ljLQfLspz7UThP8vaUM"
-#define SESSION_ID "90UbGLue3ADVhvW7hFjoA2c6yg0JJKs/lPdMDZXnZAk"
-
-// main stack size: 3584
+#define SERVER "https://matrix.org"
+#define USER_ID "@example:matrix.org"
+#define ROOM_ID "!example:matrix.org"
+#define USERNAME ""
+#define PASSWORD ""
+#define DEVICE_NAME ""
+#define WIFI_SSID ""
+#define WIFI_PASSWORD ""
+
+// event id of an encrypted event
+// devices can only be verified after they used e2ee in some way
+// (at least in Element)
+#define EVENT_ID "$example"
#define STATIC static
-
-
int
main(void)
{
@@ -36,9 +37,9 @@ main(void)
MatrixClientSetUserId(client, USER_ID);
MatrixClientLoginPassword(client,
- "pscho",
- "Wc23EbmB9G3faMq",
- "Test1");
+ USERNAME,
+ PASSWORD,
+ DEVICE_NAME);
printf("deviceId: %s\n", client->deviceId);
MatrixClientGenerateOnetimeKeys(client, 10);
MatrixClientUploadOnetimeKeys(client);
@@ -99,9 +100,7 @@ main(void)
void
app_main(void)
{
- // wifi_init("Pixel_7762", "affeaffe");
- // wifi_init("Hundehuette", "Affensicherespw55");
- wifi_init("test", "/O801i25");
+ wifi_init(WIFI_SSID, WIFI_PASSWORD);
esp_netif_ip_info_t ip_info;
esp_netif_get_ip_info(IP_EVENT_STA_GOT_IP,&ip_info);