Loading...
Searching...
No Matches
topic.h
Go to the documentation of this file.
1
4
5// ALLOW FORMATTING
6#ifndef TOPIC_H
7#define TOPIC_H
8
9#include "FreeRTOS.h"
10#include "queue.h"
11
12#include "stdbool.h"
13
14#define WAIT_ARTICLE xQueueReceive
15
16typedef QueueHandle_t SubInbox_t;
17typedef QueueHandle_t PubInbox_t;
18
29typedef struct {
30 uint8_t length;
31 uint8_t data[];
32} Message;
33
46#define SUBSCRIBE_TOPIC(topic, inbox, length, size) \
47 SubInbox_t __attribute__((section("." #topic "_subscription"))) inbox; \
48 inbox = xQueueCreate(length, size);
49
59#define CREATE_MESSAGE(name, length_) \
60 struct { \
61 uint8_t length; \
62 uint8_t data[length_]; \
63 } name = {.length = length_};
64
71typedef struct PublicTopic {
72 PubInbox_t commentInbox;
73} Topic;
74
75bool Topic_comment(Topic *topic, uint8_t *comment);
76
77#endif
PubInbox_t commentInbox
Queue handle used to send messages back to topic authors.
Definition topic.h:72
bool Topic_comment(Topic *topic, uint8_t *comment)
Send a "comment" back to the originator of a topic.
Definition topic.c:43
Type definition for generic message struct.
Definition topic.h:29
Public representation of a Topic.
Definition topic.h:71