]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - esp32/esp_project/main/SendEncrypted.c
update esp examples
[matrix_esp_thesis] / esp32 / esp_project / main / SendEncrypted.c
index 900856d1b06e4a7cda951285235a924490da2501..41429170d240a2f8c5c18fb7eee8aafccfa82106 100644 (file)
@@ -1,80 +1,70 @@
-#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();
-}
+#define OLMLIB_VERSION_MAJOR 3\r
+#define OLMLIB_VERSION_MINOR 2\r
+#define OLMLIB_VERSION_PATCH 15\r
+\r
+#define OLM_STATIC_DEFINE\r
+\r
+#include <stdio.h>\r
+#include <matrix.h>\r
+\r
+#define SERVER        "https://matrix.org"\r
+#define USER_ID       "@example:matrix.org"\r
+#define ROOM_ID       "!example:matrix.org"\r
+#define USERNAME      ""\r
+#define PASSWORD      ""\r
+#define DEVICE_NAME   ""\r
+#define WIFI_SSID     ""\r
+#define WIFI_PASSWORD ""\r
+\r
+int\r
+main(void)\r
+{\r
+    MatrixClient * client = (MatrixClient*)malloc(sizeof(MatrixClient));\r
+    MatrixClientInit(client);\r
+    \r
+    MatrixHttpInit(&client->hc, SERVER);\r
+\r
+    MatrixClientSetUserId(client, USER_ID);\r
+\r
+    MatrixClientLoginPassword(client,\r
+        USERNAME,\r
+        PASSWORD,\r
+        DEVICE_NAME);\r
+\r
+    MatrixClientUploadDeviceKeys(client);\r
+    MatrixClientGenerateOnetimeKeys(client, 10);\r
+    MatrixClientUploadOnetimeKeys(client);\r
+\r
+    // create megolmsession\r
+    MatrixMegolmOutSession * megolmOutSession;\r
+    MatrixClientNewMegolmOutSession(client,\r
+        ROOM_ID,\r
+        &megolmOutSession);\r
+    printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key);\r
+\r
+    MatrixClientShareMegolmOutSession(client,\r
+        USER_ID,\r
+        "ULZZOKJBYN",\r
+        megolmOutSession);\r
+\r
+    MatrixClientSendEventEncrypted(client,\r
+        ROOM_ID,\r
+        "m.room.message",\r
+        "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");\r
+    \r
+    MatrixClientDeleteDevice(client);\r
+\r
+    MatrixHttpDeinit(&client->hc);\r
+\r
+    return 0;\r
+}\r
+\r
+#include "wifi.h"\r
+\r
+void\r
+app_main(void)\r
+{\r
+    wifi_init(WIFI_SSID, WIFI_PASSWORD);\r
+\r
+    main();\r
+}\r