1 /*
2  * FreeRTOS V202212.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  */
26 
27 /**
28  * @file freertos_agent_message.h
29  * @brief Functions to interact with queues.
30  */
31 #ifndef FREERTOS_AGENT_MESSAGE_H
32 #define FREERTOS_AGENT_MESSAGE_H
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 #include <stdbool.h>
37 
38 /* FreeRTOS includes. */
39 #include "FreeRTOS.h"
40 #include "queue.h"
41 
42 /* Include MQTT agent messaging interface. */
43 #include "core_mqtt_agent_message_interface.h"
44 
45 /**
46  * @ingroup mqtt_agent_struct_types
47  * @brief Context with which tasks may deliver messages to the agent.
48  */
49 struct MQTTAgentMessageContext
50 {
51     QueueHandle_t queue;
52 };
53 
54 /*-----------------------------------------------------------*/
55 
56 /**
57  * @brief Send a message to the specified context.
58  * Must be thread safe.
59  *
60  * @param[in] pMsgCtx An #MQTTAgentMessageContext_t.
61  * @param[in] pCommandToSend Pointer to address to send to queue.
62  * @param[in] blockTimeMs Block time to wait for a send.
63  *
64  * @return `true` if send was successful, else `false`.
65  */
66 bool Agent_MessageSend( const MQTTAgentMessageContext_t * pMsgCtx,
67                         MQTTAgentCommand_t * const * pCommandToSend,
68                         uint32_t blockTimeMs );
69 
70 /**
71  * @brief Receive a message from the specified context.
72  * Must be thread safe.
73  *
74  * @param[in] pMsgCtx An #MQTTAgentMessageContext_t.
75  * @param[in] pReceivedCommand Pointer to write address of received command.
76  * @param[in] blockTimeMs Block time to wait for a receive.
77  *
78  * @return `true` if receive was successful, else `false`.
79  */
80 bool Agent_MessageReceive( const MQTTAgentMessageContext_t * pMsgCtx,
81                            MQTTAgentCommand_t ** pReceivedCommand,
82                            uint32_t blockTimeMs );
83 
84 #endif /* FREERTOS_AGENT_MESSAGE_H */
85