abouttreesummaryrefslogcommitdiff
path: root/esp32/esp_project/main/SendEncrypted.c
diff options
context:
space:
mode:
authorPatrick2023-10-13 15:59:29 +0200
committerPatrick2023-10-13 15:59:29 +0200
commit8ceca98f04b88798794748572fce184b92144d2d (patch)
treef47412c25cb3aba62447e6df96a2f9cc288f6b27 /esp32/esp_project/main/SendEncrypted.c
parent9eaa420b7bf51cc81c50e7f4ca0f256498a07c86 (diff)
downloadmatrix_esp_thesis-8ceca98f04b88798794748572fce184b92144d2d.tar.gz
matrix_esp_thesis-8ceca98f04b88798794748572fce184b92144d2d.zip
working examples for esp
Diffstat (limited to 'esp32/esp_project/main/SendEncrypted.c')
-rw-r--r--esp32/esp_project/main/SendEncrypted.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/esp32/esp_project/main/SendEncrypted.c b/esp32/esp_project/main/SendEncrypted.c
new file mode 100644
index 0000000..900856d
--- /dev/null
+++ b/esp32/esp_project/main/SendEncrypted.c
@@ -0,0 +1,80 @@
+#define OLMLIB_VERSION_MAJOR 3
+#define OLMLIB_VERSION_MINOR 2
+#define OLMLIB_VERSION_PATCH 15
+
+#define OLM_STATIC_DEFINE
+
+#include <stdio.h>
+#include <matrix.h>
+
+#define SERVER "https://matrix.org"
+#define USER_ID "@pscho:matrix.org"
+#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org"
+
+int
+main(void)
+{
+ // static MatrixClient _client;
+ // MatrixClient * client = &_client;
+ MatrixClient * client = (MatrixClient*)malloc(sizeof(MatrixClient));
+ MatrixClientInit(client);
+
+ MatrixHttpInit(&client->hc, SERVER);
+ MatrixClientSetUserId(client, USER_ID);
+
+ static char key[1024];
+ MatrixOlmAccountGetDeviceKey(&client->olmAccount, key, 1024);
+ printf("key: %s\n", key);
+
+ //MatrixClientSetUserId(client, USER_ID);
+
+ MatrixClientLoginPassword(client,
+ "pscho",
+ "Wc23EbmB9G3faMq",
+ "Test1");
+
+ // MatrixClientSendEvent(client,
+ // ROOM_ID,
+ // "m.room.message",
+ // "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");
+
+ MatrixClientUploadDeviceKey(client);
+ MatrixClientGenerateOnetimeKeys(client, 10);
+ MatrixClientUploadOnetimeKeys(client);
+
+ // create megolmsession
+ MatrixMegolmOutSession * megolmOutSession;
+ MatrixClientNewMegolmOutSession(client,
+ ROOM_ID,
+ &megolmOutSession);
+ printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key);
+
+ // heap_caps_get_free_size();
+ // xPortGetFreeHeapSize();
+
+ MatrixClientShareMegolmOutSession(client,
+ USER_ID,
+ "ULZZOKJBYN",
+ megolmOutSession);
+
+ MatrixClientSendEventEncrypted(client,
+ ROOM_ID,
+ "m.room.message",
+ "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");
+
+ MatrixClientDeleteDevice(client);
+
+ MatrixHttpDeinit(&client->hc);
+
+ return 0;
+}
+
+#include "wifi.h"
+
+void
+app_main(void)
+{
+ wifi_init("Hundehuette", "Affensicherespw55");
+
+ main();
+}