-
Notifications
You must be signed in to change notification settings - Fork 0
/
trackle_esp32.h
114 lines (94 loc) · 3.31 KB
/
trackle_esp32.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
******************************************************************************
Copyright (c) 2022 IOTREADY S.r.l.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/
#ifndef TRACKLE_ESP32_H
#define TRACKLE_ESP32_H
#define TRACKLE_ESP32_VERSION "4.3.0"
#include "trackle_interface.h"
#include "trackle_utils.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include <sys/time.h>
#include "esp_log.h"
#include "esp_timer.h"
#include <string.h>
// A pointer to the Trackle structure.
extern struct Trackle *trackle_s;
// Semaphore to sync main e trackle tasks
extern SemaphoreHandle_t xTrackleSemaphore;
static TickType_t xTrackleSemaphoreWait = 100;
// This function is used to get the current time in milliseconds.
static system_tick_t getMillis(void)
{
return (uint32_t)(esp_timer_get_time() / 1000);
}
/**
* It initializes the Trackle library
*/
void initTrackle();
/**
* It creates a task that runs the trackle_task function.
*/
void connectTrackle();
/**
* Task that will run the trackleLoop() function every 20 milliseconds and update memory diagnostics.
*
* @param pvParameter This is a parameter that is passed to the task when it is created.
*/
void trackle_task(void *pvParameter);
/**
* It takes a string, and publishes it to the trackle server
*
* @param eventName The name of the event to publish.
* @param data The data to be published.
*
* @return A boolean value.
*/
bool tracklePublishSecure(const char *eventName, const char *data);
/**
* It takes a string, and publishes it to the trackle server
*
* @param eventName the name of the event to publish
* @param data the data to be sent
* @param eventType type of event, public or private.
* @param eventFlag event flags, with or without ack.
* @param msg_key the message key, if you want to use it.
*
* @return A boolean value.
*/
bool tracklePublishSecureWithParams(const char *eventName, const char *data, Event_Type eventType, Event_Flags eventFlag, uint32_t msg_key);
/**
* It takes a json that contain a list of properties and publishes it to the trackle server
*
* @param data The data to be sent to the Trackle server.
*
* @return A boolean value.
*/
bool trackleSyncStateSecure(const char *data);
/**
* It converts the log level name to the corresponding esp-idf log level
*
* @param level_name The name of the log level.
*
* @return The log level of the espidf.
*/
esp_log_level_t get_espidf_log_level(const char *level_name);
/**
* @brief Get the currently set Trackle device ID as string.
* @return String representation of the Trackle device ID.
*/
const char *trackleGetDeviceIdAsStr();
#endif /* TRACKLE_ESP32_H */