urtware / src / urt_publisher.c @ f6e5368e
History | View | Annotate | Download (3.778 KB)
1 | 1fb06240 | skenneweg | /*
|
---|---|---|---|
2 | µRtWare is a lightweight publish/subscribe middleware for real-time
|
||
3 | applications. It was developed as part of the software habitat for the
|
||
4 | Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well.
|
||
5 | |||
6 | Copyright (C) 2018..2020 Thomas Schöpping et al.
|
||
7 | |||
8 | This program is free software: you can redistribute it and/or modify
|
||
9 | it under the terms of the GNU General Public License as published by
|
||
10 | the Free Software Foundation, either version 3 of the License, or
|
||
11 | (at your option) any later version.
|
||
12 | |||
13 | This program is distributed in the hope that it will be useful,
|
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | GNU General Public License for more details.
|
||
17 | |||
18 | You should have received a copy of the GNU General Public License
|
||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
20 | */
|
||
21 | |||
22 | 7d9678db | skenneweg | #include <urtware.h> |
23 | |||
24 | 1fb06240 | skenneweg | /******************************************************************************/
|
25 | /* LOCAL DEFINITIONS */
|
||
26 | /******************************************************************************/
|
||
27 | |||
28 | /******************************************************************************/
|
||
29 | /* EXPORTED VARIABLES */
|
||
30 | /******************************************************************************/
|
||
31 | |||
32 | /******************************************************************************/
|
||
33 | /* LOCAL TYPES */
|
||
34 | /******************************************************************************/
|
||
35 | |||
36 | /******************************************************************************/
|
||
37 | /* LOCAL VARIABLES */
|
||
38 | /******************************************************************************/
|
||
39 | |||
40 | /******************************************************************************/
|
||
41 | /* LOCAL FUNCTIONS */
|
||
42 | /******************************************************************************/
|
||
43 | |||
44 | /******************************************************************************/
|
||
45 | /* EXPORTED FUNCTIONS */
|
||
46 | /******************************************************************************/
|
||
47 | 7d9678db | skenneweg | |
48 | /**
|
||
49 | * @brief Initalize the publisher.
|
||
50 | *
|
||
51 | 5198dfae | skenneweg | * @param[in] publisher The publisher to initialize. Must not be NULL.
|
52 | * @param[in] topic The topic, this publisher is associated to. Must not be NULL.
|
||
53 | * @param[in] message NULL terminated list of messages to contribute to the topic.
|
||
54 | * Messages must not be associated to another topic.
|
||
55 | * Once a message has been contributed, it cannot be removed later.
|
||
56 | * May be NULL (no messages to contribute).
|
||
57 | 7d9678db | skenneweg | */
|
58 | 1f7ffcff | skenneweg | void urtPublisherInit(urt_publisher_t* publisher, urt_topic_t* topic, urt_message_t* message)
|
59 | { |
||
60 | urt_publisher_t.topic = topic; |
||
61 | #if (URT_CFG_PUBSUB_PROFILING)
|
||
62 | urt_publisher_t.publishAttempts = 0;
|
||
63 | urt_publisher_t.publishFails = 0;
|
||
64 | endif /* URT_CFG_PUBSUB_PROFILING */
|
||
65 | //add later: messages to contribute,...
|
||
66 | return;
|
||
67 | } |
||
68 | 7d9678db | skenneweg | |
69 | |||
70 | /**
|
||
71 | 5198dfae | skenneweg | * @brief Publish data.
|
72 | 7d9678db | skenneweg | *
|
73 | 5198dfae | skenneweg | * @param[in] publisher Pointer to the publisher to use. Must not be NULL.
|
74 | * @param[in] payload Pointer to the data to be published. May be NULL for messages without payload.
|
||
75 | * @param[in] bytes Size of the payload in bytes.
|
||
76 | * @param[in] t Timestamp to be set for the message.
|
||
77 | * @param[in] timeout Timeout delay in case the message cannot be published.
|
||
78 | 7d9678db | skenneweg | *
|
79 | 5198dfae | skenneweg | * @return Returns URT_STATUS_OK on success. Returns URT_STATUS_PUBLISH_TIMEOUT on timeout.
|
80 | 7d9678db | skenneweg | */
|
81 | urt_status_t urtPublisherPublish(urt_publisher_t* publisher, void* payload, size_t bytes, urt_osTime_t t, urt_delay_t timeout) {return URT_STATUS_OK;} |