X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/8ceca98f04b88798794748572fce184b92144d2d..58e0d63958d7406b7bbf3b964d9ea9a2770e0741:/esp32/esp_project/main/SendEncrypted.c diff --git a/esp32/esp_project/main/SendEncrypted.c b/esp32/esp_project/main/SendEncrypted.c index 900856d..4142917 100644 --- a/esp32/esp_project/main/SendEncrypted.c +++ b/esp32/esp_project/main/SendEncrypted.c @@ -1,80 +1,70 @@ -#define OLMLIB_VERSION_MAJOR 3 -#define OLMLIB_VERSION_MINOR 2 -#define OLMLIB_VERSION_PATCH 15 - -#define OLM_STATIC_DEFINE - -#include -#include - -#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 +#define OLMLIB_VERSION_MINOR 2 +#define OLMLIB_VERSION_PATCH 15 + +#define OLM_STATIC_DEFINE + +#include +#include + +#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 = (MatrixClient*)malloc(sizeof(MatrixClient)); + MatrixClientInit(client); + + MatrixHttpInit(&client->hc, SERVER); + + MatrixClientSetUserId(client, USER_ID); + + MatrixClientLoginPassword(client, + USERNAME, + PASSWORD, + DEVICE_NAME); + + MatrixClientUploadDeviceKeys(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); + + 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(WIFI_SSID, WIFI_PASSWORD); + + main(); +}