ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Enumerations
API_Process_Type.h File Reference
#include <stdint.h>
Include dependency graph for API_Process_Type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  API_Process_Type : uint8_t { RAW , JSON }
 Possible processing types an API Implementation uses to handle responses from the server. More...
 

Enumeration Type Documentation

◆ API_Process_Type

enum class API_Process_Type : uint8_t
strong

Possible processing types an API Implementation uses to handle responses from the server.

Note
Only ever calls either the Process_Response (RAW) or Process_Json_Response (JSON) method, this is the case because data that can not be serialized into JSON, should also never be serialized into JSON, Otherwise deserialization errors will be printed with the Logger instance and an unnecessary conversion will happen, even tough the response was already handled by Process_Response (RAW) which is called first.

If the received data is unserialized binary data, which we should not serialize into JSON because the received data is not JSON in the first place Process_Response method will be called (OTA Firmware Update). Alterantively, if the received data needs to be serialized into JSON data the Process_JSON_Response method will be called with the data already serialized into the JSON format instead (everything else).

Additionally the actual data is never copied in both cases to safe space. Instead the underlying MQTT buffer is expected to keep the buffer unchanged and alive and we simply use a non-owning pointer for our operations. This can cause the data to become garbage if the user code resizes the underlying MQTT buffer size and therefore moves the actual data in the MQTT buffer, before the data is handled by the code itself. Before version v0.15.0, the dependency TBPubSubClient used by the Arduino_MQTT_Client could also cause this issue, if data is sent before received data was handled. This was the case because the input and output Heap buffer were not seperate, but instead it was handled by the same underlying Heap buffer, meaning if we sent data in the callback handling received data that data was partially overwritten and became mangled

Enumerator
RAW 

Calls Process_Response with the received unserialized binary data.

JSON 

Calls Process_Json_Response with the received unserialized binary data serialized into JSON.