1 /* 2 * Percepio DFM v2.1.0 3 * Copyright 2023 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 /** 10 * @file 11 * 12 * @brief DFM Cloud API 13 */ 14 15 #ifndef DFM_CLOUD_H 16 #define DFM_CLOUD_H 17 18 #include <dfmCloudPort.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #if ((DFM_CFG_ENABLED) >= 1) 25 26 /** 27 * @defgroup dfm_cloud_apis DFM Cloud API 28 * @ingroup dfm_apis 29 * @{ 30 */ 31 32 /** 33 * @brief Cloud system data 34 */ 35 typedef struct DfmCloudData 36 { 37 uint32_t ulInitialized; 38 DfmCloudPortData_t xCloudPortData; 39 } DfmCloudData_t; 40 41 /** 42 * @internal Initializes the Cloud system 43 * 44 * @param[in] pxBuffer Cloud system buffer. 45 * 46 * @retval DFM_FAIL Failure 47 * @retval DFM_SUCCESS Success 48 */ 49 DfmResult_t xDfmCloudInitialize(DfmCloudData_t* pxBuffer); 50 51 /** 52 * @brief Send an Alert 53 * 54 * @param[in] xEntryHandle Entry handle. 55 * 56 * @retval DFM_FAIL Failure 57 * @retval DFM_SUCCESS Success 58 */ 59 DfmResult_t xDfmCloudSendAlert(DfmEntryHandle_t xEntryHandle); 60 61 /** 62 * @brief Send a Payload chunk 63 * 64 * @param[in] xEntryHandle Entry handle. 65 * 66 * @retval DFM_FAIL Failure 67 * @retval DFM_SUCCESS Success 68 */ 69 DfmResult_t xDfmCloudSendPayloadChunk(DfmEntryHandle_t xEntryHandle); 70 71 /** 72 * @brief Helper function used by MQTT Cloud ports that generates a Topic from an Entry handle 73 * 74 * @param[in] cTopicBuffer Pointer to buffer. 75 * @param[in] ulBufferSize Buffer size. 76 * @param[in] szMQTTPrefix MQTT Topic Prefix. 77 * @param[in] xEntryHandle Entry handle. 78 * 79 * @retval DFM_FAIL Failure 80 * @retval DFM_SUCCESS Success 81 */ 82 DfmResult_t xDfmCloudGenerateMQTTTopic(char* cTopicBuffer, uint32_t ulBufferSize, const char* szMQTTPrefix, DfmEntryHandle_t xEntryHandle); 83 84 /** @} */ 85 86 #else 87 88 /* Dummy defines */ 89 #define xDfmCloudSendAlert(xEntryHandle) (DFM_FAIL) 90 #define xDfmCloudSendPayloadChunk(xEntryHandle) (DFM_FAIL) 91 #define xDfmCloudGenerateMQTTTopic(cTopicBuffer, ulBufferSize, xEntryHandle) (DFM_FAIL) 92 93 #endif 94 95 #ifdef __cplusplus 96 } 97 #endif 98 99 #endif 100