Skip to content

Commit

Permalink
Fix compile error with provisioning
Browse files Browse the repository at this point in the history
CONFIG_THINGSBOARD_USE_PROVISIONING=y was not tested during CI, so the
changed to the API were missed in previous commit.
  • Loading branch information
gumulka committed Aug 21, 2024
1 parent 1e8b31d commit 41387f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/coap_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

struct coap_client_request;

typedef void (*coap_reply_handler_t)(struct coap_client_request *req, struct coap_packet *resp);
typedef int (*coap_reply_handler_t)(struct coap_client_request *req, struct coap_packet *resp);

struct coap_client_request {
struct coap_packet pkt;
Expand Down
16 changes: 10 additions & 6 deletions src/thingsboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ K_WORK_DELAYABLE_DEFINE(work_time, time_worker);

static const char *access_token;

static void client_handle_attribute_notification(struct coap_client_request *req, struct coap_packet *response)
static int client_handle_attribute_notification(struct coap_client_request *req,
struct coap_packet *response)
{
LOG_INF("%s", __func__);

Expand All @@ -50,14 +51,14 @@ static void client_handle_attribute_notification(struct coap_client_request *req
payload = (uint8_t*)coap_packet_get_payload(response, &payload_len);
if (!payload_len) {
LOG_WRN("Received empty attributes");
return;
return payload_len;
}
LOG_HEXDUMP_DBG(payload, payload_len, "Received attributes");

err = thingsboard_attr_from_json(payload, payload_len, &attr);
if (err < 0) {
LOG_ERR("Parsing attributes failed");
return;
return err;
}

#ifdef CONFIG_THINGSBOARD_FOTA
Expand All @@ -67,6 +68,7 @@ static void client_handle_attribute_notification(struct coap_client_request *req
if (attribute_cb) {
attribute_cb(&attr);
}
return 0;
}

/**
Expand Down Expand Up @@ -99,7 +101,8 @@ static int timestamp_from_buf(int64_t *value, const void *buf, size_t sz) {
return 0;
}

static void client_handle_time_response(struct coap_client_request *req, struct coap_packet *response)
static int client_handle_time_response(struct coap_client_request *req,
struct coap_packet *response)
{
int64_t ts = 0;
const uint8_t *payload;
Expand All @@ -111,19 +114,20 @@ static void client_handle_time_response(struct coap_client_request *req, struct
payload = coap_packet_get_payload(response, &payload_len);
if (!payload_len) {
LOG_WRN("Received empty timestamp");
return;
return payload_len;
}

err = timestamp_from_buf(&ts, payload, payload_len);
if (err) {
LOG_ERR("Parsing of time response failed");
return;
return err;
}

tb_time.tb_time = ts;
tb_time.own_time = k_uptime_get();

k_sem_give(&time_sem);
return 0;
}

static int client_subscribe_to_attributes(void)
Expand Down
14 changes: 12 additions & 2 deletions tests/compile/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
common:
platform_allow:
- qemu_cortex_m3
- native_posix
tests:
thingsboard.compile:
platform_allow: qemu_cortex_m3
thingsboard.compile: {}
thingsboard.compile_provisioning:
extra_configs:
- CONFIG_THINGSBOARD_USE_PROVISIONING=y
- CONFIG_SETTINGS=y
thingsboard.compile_fota:
extra_configs:
- CONFIG_THINGSBOARD_FOTA=y

0 comments on commit 41387f9

Please sign in to comment.