ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Constants.h
Go to the documentation of this file.
1#ifndef Constants_h
2#define Constants_h
3
4// Local includes.
5#include "Configuration.h"
6
7// Library includes.
8#include <stdint.h>
9#if THINGSBOARD_ENABLE_PSRAM || THINGSBOARD_ENABLE_DYNAMIC
10#include <ArduinoJson.h>
11#endif // THINGSBOARD_ENABLE_PSRAM || THINGSBOARD_ENABLE_DYNAMIC
12
13
21uint16_t constexpr DEFAULT_MAX_STACK_SIZE = 1024U;
22#if THINGSBOARD_ENABLE_STREAM_UTILS
23uint8_t constexpr DEFAULT_BUFFERING_SIZE = 64U;
24#endif // THINGSBOARD_ENABLE_STREAM_UTILS
25#if THINGSBOARD_ENABLE_DYNAMIC
26uint8_t constexpr DEFAULT_MAX_RESPONSE_SIZE = 0U;
27#endif // THINGSBOARD_ENABLE_DYNAMIC
28
29
30// Log messages.
31#if !THINGSBOARD_ENABLE_DYNAMIC
32char constexpr TOO_MANY_JSON_FIELDS[] = "Attempt to enter to many JSON fields into StaticJsonDocument (%u), increase (%s) (%u) accordingly";
33#endif // !THINGSBOARD_ENABLE_DYNAMIC
34char constexpr UNABLE_TO_SERIALIZE[] = "Unable to serialize key-value json";
35char constexpr CONNECT_FAILED[] = "Connecting to server failed";
36char constexpr UNABLE_TO_SERIALIZE_JSON[] = "Unable to serialize json data";
37char constexpr UNABLE_TO_ALLOCATE_JSON[] = "Allocating memory for the JsonDocument failed, passed JsonDocument is NULL";
38char constexpr JSON_SIZE_TO_SMALL[] = "JsonDocument too small to store all values. Ensure every key value pair gets JSON_OBJECT_SIZE(1) capacity + size required by value / key that is inserted";
39
40
41#if THINGSBOARD_ENABLE_PSRAM
42#include <esp_heap_caps.h>
43
44struct SpiRamAllocator {
45 void* allocate(size_t size) {
46 return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
47 }
48
49 void deallocate(void* pointer) {
50 heap_caps_free(pointer);
51 }
52
53 void* reallocate(void* ptr, size_t new_size) {
54 return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
55 }
56};
57
58using TBJsonDocument = BasicJsonDocument<SpiRamAllocator>;
59#elif THINGSBOARD_ENABLE_DYNAMIC
60using TBJsonDocument = DynamicJsonDocument;
61#endif
62
63#endif // Constants_h
char constexpr TOO_MANY_JSON_FIELDS[]
Definition: Constants.h:32
uint8_t constexpr DEFAULT_RESPONSE_AMOUNT
Definition: Constants.h:15
char constexpr JSON_SIZE_TO_SMALL[]
Definition: Constants.h:38
char constexpr UNABLE_TO_ALLOCATE_JSON[]
Definition: Constants.h:37
char constexpr UNABLE_TO_SERIALIZE_JSON[]
Definition: Constants.h:36
uint8_t constexpr DEFAULT_REQUEST_RPC_AMOUNT
Definition: Constants.h:19
char constexpr UNABLE_TO_SERIALIZE[]
Definition: Constants.h:34
uint8_t constexpr DEFAULT_PAYLOAD_SIZE
Definition: Constants.h:20
uint8_t constexpr DEFAULT_RPC_AMOUNT
Definition: Constants.h:18
uint16_t constexpr DEFAULT_MAX_STACK_SIZE
Definition: Constants.h:21
uint8_t constexpr DEFAULT_ATTRIBUTES_AMOUNT
Definition: Constants.h:17
char constexpr CONNECT_FAILED[]
Definition: Constants.h:35
uint8_t constexpr DEFAULT_ENDPOINT_AMOUNT
Definition: Constants.h:14
uint8_t constexpr DEFAULT_SUBSCRIPTION_AMOUNT
Definition: Constants.h:16