]> gitweb.ps.run Git - matrix_esp_thesis/blob - esp32/esp_project/main/SendEncrypted.c
fix examples
[matrix_esp_thesis] / esp32 / esp_project / main / SendEncrypted.c
1 #define OLMLIB_VERSION_MAJOR 3
2 #define OLMLIB_VERSION_MINOR 2
3 #define OLMLIB_VERSION_PATCH 15
4
5 #define OLM_STATIC_DEFINE
6
7 #include <stdio.h>
8 #include <matrix.h>
9
10 #define SERVER       "https://matrix.org"
11 #define USER_ID      "@pscho:matrix.org"
12 #define ROOM_ID      "!XKFUjAsGrSSrpDFIxB:matrix.org"
13
14 int
15 main(void)
16 {
17     MatrixClient client;
18     MatrixClientInit(&client);
19     
20     MatrixHttpInit(&client.hc, SERVER);
21
22     MatrixClientSetUserId(&client, USER_ID);
23
24     MatrixClientLoginPassword(&client,
25         "pscho",
26         "Wc23EbmB9G3faMq",
27         "Test1");
28
29     MatrixClientUploadDeviceKeys(&client);
30     MatrixClientGenerateOnetimeKeys(&client, 10);
31     MatrixClientUploadOnetimeKeys(&client);
32
33     // create megolmsession
34     MatrixMegolmOutSession * megolmOutSession;
35     MatrixClientNewMegolmOutSession(&client,
36         ROOM_ID,
37         &megolmOutSession);
38     printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key);
39
40     MatrixClientShareMegolmOutSession(&client,
41         USER_ID,
42         "ULZZOKJBYN",
43         megolmOutSession);
44
45     MatrixClientSendEventEncrypted(&client,
46         ROOM_ID,
47         "m.room.message",
48         "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}");
49     
50     MatrixClientDeleteDevice(&client);
51
52     MatrixHttpDeinit(&client.hc);
53
54     return 0;
55 }
56
57 #include "wifi.h"
58
59 void
60 app_main(void)
61 {
62     wifi_init("Hundehuette", "Affensicherespw55");
63
64     main();
65 }