/* * DOCUMENT of sync to peer * if a tcp connection is established, it need to send a subscribe command to * root. and root will compare scheduled topic then send it. * * * subscribe command: * mpack formatted: [ uint8_t id = 1, char topic[TOPIC_LEN] ] */ #pragma once #include "./mongoose.h" #include "./storage.h" #define TOPIC_LEN 20 #define IMAGE_SIZE 152 * 296 #define IMAGE_BLK_SIZE 1024 struct Meshtalos { struct Storage *storage; struct mg_mgr mg; }; struct sync_jobs { // char *tag_name; char topic[TOPIC_LEN]; }; struct sub { struct mg_connection *c; char topic[TOPIC_LEN]; struct sub *next; }; extern struct sub *sub_list; extern QueueHandle_t sub_jobs; extern SemaphoreHandle_t sub_mutex; extern uint8_t image_buf[IMAGE_SIZE]; struct Meshtalos *mtsh_init(); void mtsh_listen(struct Meshtalos *mtsh, const char *http_endpoint); void mtsh_tcp_sender(struct mg_mgr *mgr);