27template <
typename Logger = DefaultLogger>
54 else if (!Provision_Subscribe(callback)) {
58 StaticJsonDocument<JSON_OBJECT_SIZE(9)> request_buffer;
99 return API_Process_Type::JSON;
112 (void)Provision_Unsubscribe();
120 return Provision_Unsubscribe();
128#if !THINGSBOARD_USE_ESP_TIMER
139 void Set_Client_Callbacks(
Callback<void, IAPI_Implementation &>::function subscribe_api_callback,
Callback<bool, char const * const, JsonDocument const &>::function send_json_callback,
Callback<bool, char const * const, char const * const>::function send_json_string_callback,
Callback<bool, char const * const>::function subscribe_topic_callback,
Callback<bool, char const * const>::function unsubscribe_topic_callback,
Callback<uint16_t>::function get_receive_size_callback,
Callback<uint16_t>::function get_send_size_callback,
Callback<bool, uint16_t, uint16_t>::function set_buffer_size_callback,
Callback<size_t *>::function get_request_id_callback)
override {
148 m_provision_callback = callback;
154 bool Provision_Unsubscribe() {
API_Process_Type
Possible processing types an API Implementation uses to handle responses from the server.
Definition: API_Process_Type.h:19
char constexpr PROV_DEVICE_KEY[]
Definition: Provision.h:14
char constexpr PROV_TOKEN[]
Definition: Provision.h:17
char constexpr PROV_CRED_TYPE_KEY[]
Definition: Provision.h:16
char constexpr PROV_DEVICE_SECRET_KEY[]
Definition: Provision.h:15
char constexpr PROV_CRED_HASH[]
Definition: Provision.h:21
char constexpr PROV_CRED_CLIENT_ID[]
Definition: Provision.h:20
char constexpr PROV_CRED_PASSWORD[]
Definition: Provision.h:19
char constexpr PROV_RESPONSE_TOPIC[]
Definition: Provision.h:10
char constexpr PROV_REQUEST_TOPIC[]
Definition: Provision.h:11
char constexpr PROV_CRED_USERNAME[]
Definition: Provision.h:18
char constexpr DEVICE_NAME_KEY[]
Definition: Provision.h:13
General purpose safe callback wrapper. Expects either c-style or c++ style function pointer,...
Definition: Callback.h:30
std::function< return_type(argument_types... arguments)> function
Callback signature.
Definition: Callback.h:34
void Set_Callback(function callback)
Sets the callback method that will be called upon data arrival with the given data that was received....
Definition: Callback.h:72
return_type Call_Callback(argument_types const &... arguments) const
Calls the callback that was subscribed, when this class instance was initally created.
Definition: Callback.h:62
static bool String_IsNull_Or_Empty(char const *str)
Returns wheter the given string is either a nullptr or is an empty string, meaning it only contains a...
Definition: Helper.cpp:27
Base functionality required by all API implementation.
Definition: IAPI_Implementation.h:37
Provisioning callback wrapper.
Definition: Provision_Callback.h:28
char const * Get_Credentials_Type() const
Gets the string containing the used credentials type that decides which provisioning method is actual...
Definition: Provision_Callback.cpp:136
char const * Get_Credentials_Client_ID() const
Gets the basic MQTT credentials client ID, that will be used by the provisioned device.
Definition: Provision_Callback.cpp:120
Timeoutable_Request & Get_Request_Timeout()
Gets the request timeout callback.
Definition: Provision_Callback.cpp:140
char const * Get_Credentials_Username() const
Gets the basic MQTT credentials username, that will be used by the provisioned device.
Definition: Provision_Callback.cpp:104
char const * Get_Certificate_Hash() const
Gets the public X.509 certificate hash, that will be used by the provisioned device.
Definition: Provision_Callback.cpp:128
char const * Get_Device_Name() const
Gets the name the created device should have on the cloud.
Definition: Provision_Callback.cpp:88
char const * Get_Credentials_Password() const
Gets the basic MQTT credentials password, that will be used by the provisioned device.
Definition: Provision_Callback.cpp:112
char const * Get_Device_Access_Token() const
Gets the access token generated by the device, that will be used by the provisioned device.
Definition: Provision_Callback.cpp:96
char const * Get_Device_Secret() const
Gets the provisioning secret of the Device Profile that should be used to create the device under.
Definition: Provision_Callback.cpp:80
char const * Get_Device_Key() const
Gets the provisioning key of the Device Profile, that should be used to create the device under.
Definition: Provision_Callback.cpp:72
Handles the internal implementation of the ThingsBoard provision API. See https://thingsboard....
Definition: Provision.h:28
void Initialize() override
Method that allows to construct internal objects, after the required callback member methods have bee...
Definition: Provision.h:135
void Set_Client_Callbacks(Callback< void, IAPI_Implementation & >::function subscribe_api_callback, Callback< bool, char const *const, JsonDocument const & >::function send_json_callback, Callback< bool, char const *const, char const *const >::function send_json_string_callback, Callback< bool, char const *const >::function subscribe_topic_callback, Callback< bool, char const *const >::function unsubscribe_topic_callback, Callback< uint16_t >::function get_receive_size_callback, Callback< uint16_t >::function get_send_size_callback, Callback< bool, uint16_t, uint16_t >::function set_buffer_size_callback, Callback< size_t * >::function get_request_id_callback) override
Sets the underlying callbacks that are required for the different API Implementation to communicate w...
Definition: Provision.h:139
void Process_Response(char const *topic, uint8_t *payload, uint32_t length) override
Process callback that will be called upon response arrival.
Definition: Provision.h:102
bool Is_Response_Topic_Matching(char const *topic) const override
Compares received response topic and the topic this api implementation handles responses on,...
Definition: Provision.h:115
bool Unsubscribe() override
Unsubcribes all callbacks, to clear up any ongoing subscriptions and stop receiving information over ...
Definition: Provision.h:119
bool Provision_Request(Provision_Callback const &callback)
Requests othe provisioning of a new device, which will call the passed callback. If the credentials f...
Definition: Provision.h:47
void loop() override
Internal loop method to update inernal timers for API calls that can timeout.
Definition: Provision.h:129
~Provision() override=default
Provision()=default
Constructor.
API_Process_Type Get_Process_Type() const override
Returns the way the server response should be processed.
Definition: Provision.h:98
void Process_Json_Response(char const *topic, JsonDocument const &data) override
Process callback that will be called upon response arrival.
Definition: Provision.h:106
bool Resubscribe_Permanent_Subscriptions() override
Forwards the call to let the API clear up any ongoing single-event subscriptions (Provision,...
Definition: Provision.h:123
void Update_Timeout_Timer()
Updates the internal timeout timer.
Definition: Timeoutable_Request.cpp:20
void Start_Timeout_Timer()
Starts the internal timeout timer if we actually received a configured valid timeout time and a valid...
Definition: Timeoutable_Request.cpp:25
void Stop_Timeout_Timer()
Stops the internal timeout timer, is called as soon as an answer is received from the cloud....
Definition: Timeoutable_Request.cpp:32