Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit 06dd351

Browse files
committed
drop
1 parent be85436 commit 06dd351

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

include/thingsboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef void (*rpc_callback_t)(const uint8_t *data, size_t len);
5252
* Parameters are an optional string in JSON format as the variadic arguments
5353
* See https://thingsboard.io/docs/reference/coap-api/#client-side-rpc for details.
5454
*/
55-
int thingsboard_rpc(const char *method, rpc_callback_t cb, ...);
55+
int thingsboard_rpc(const char *method, rpc_callback_t cb, const char *params);
5656

5757
struct tb_fw_id {
5858
/** Title of your firmware, e.g. <project>-prod. This

src/thingsboard.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,26 @@ static void rcp_reset(struct k_timer *timer_id)
212212
k_sem_give(&rpc_sem);
213213
}
214214

215-
int thingsboard_rpc(const char *method, rpc_callback_t cb, ...)
215+
int thingsboard_rpc(const char *method, rpc_callback_t cb, const char* params)
216216
{
217217
int err;
218-
va_list param;
219-
char params[RPC_PARAMS_SIZE];
220-
char payload[RPC_PAYLOAD_SIZE];
218+
char payload[RPC_PAYLOAD_SIZE] = {0};
221219

222220
if (method == NULL || strlen(method) == 0) {
223221
LOG_ERR("method name must not be 'NULL' or empty");
224222
return -EINVAL;
225223
}
226224

227-
va_start(param, cb);
228-
bool params_exist = vsnprintf(params, sizeof(params), "%s", param) > 0 ? true : false;
225+
bool params_exist = (params != NULL && strlen(params) > 0) ? true : false;
229226
if (!params_exist) {
230-
strcpy(params, "{}");
227+
params = "{}";
231228
}
232-
va_end(param);
233229

234230
k_sem_take(&rpc_sem, K_FOREVER);
235231
k_timer_start(&rcp_timer, K_MSEC(CONFIG_THINGSBOARD_RPC_TIMEOUT), K_NO_WAIT);
236232

237233
snprintf(payload, sizeof(payload), "{\"method\":\"%s\", \"params\": %s}", method, params);
234+
238235
const uint8_t *uri[] = {"api", "v1", access_token, "rpc", NULL};
239236

240237
err = coap_client_make_request(uri, payload, strlen(payload), COAP_TYPE_CON,
@@ -243,6 +240,7 @@ int thingsboard_rpc(const char *method, rpc_callback_t cb, ...)
243240
LOG_ERR("Failed to perform RPC");
244241
return err;
245242
}
243+
246244
rpc_cb = cb;
247245

248246
return 0;
@@ -312,6 +310,9 @@ static void start_client(void)
312310
int thingsboard_init(attr_write_callback_t cb, const struct tb_fw_id *fw_id)
313311
{
314312
attribute_cb = cb;
313+
if (attribute_cb) {
314+
return 0;
315+
}
315316
int ret;
316317

317318
current_fw = fw_id;

0 commit comments

Comments
 (0)