Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/wakaama: Fix usages of lwm2m_uri_t and ISPO sensor #21034

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/wakaama/contrib/lwm2m_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ static credman_tag_t _get_credential(const sock_udp_ep_t *ep, uint8_t security_m
}

/* prepare query */
lwm2m_uri_t query_uri = {
.objectId = LWM2M_SECURITY_OBJECT_ID,
};
lwm2m_uri_t query_uri;
LWM2M_URI_RESET(&query_uri);
query_uri.objectId = LWM2M_SECURITY_OBJECT_ID;

lwm2m_list_t *instance = sec->instanceList;

Expand Down Expand Up @@ -409,9 +409,9 @@ void lwm2m_client_refresh_dtls_credentials(void)
}

/* prepare query */
lwm2m_uri_t query_uri = {
.objectId = LWM2M_SECURITY_OBJECT_ID,
};
lwm2m_uri_t query_uri;
LWM2M_URI_RESET(&query_uri);
query_uri.objectId = LWM2M_SECURITY_OBJECT_ID;

lwm2m_list_t *instance = sec->instanceList;
int64_t val;
Expand Down
10 changes: 5 additions & 5 deletions pkg/wakaama/contrib/lwm2m_client_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
lwm2m_client_data_t *client_data = (lwm2m_client_data_t *)user_data;
lwm2m_client_connection_t *new_conn;

DEBUG("[lwm2m_connect_server] Connecting to server in security instance %" PRIu16 "\n", sec_obj_inst_id);

Check warning on line 107 in pkg/wakaama/contrib/lwm2m_client_connection.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

new_conn = _connection_create(sec_obj_inst_id, client_data);
if (new_conn) {
Expand Down Expand Up @@ -280,11 +280,11 @@
DEBUG("Creating connection\n");

/* prepare Server URI query */
lwm2m_uri_t resource_uri = {
.objectId = LWM2M_SECURITY_URI_ID,
.instanceId = sec_obj_inst_id,
.resourceId = LWM2M_SECURITY_URI_ID,
};
lwm2m_uri_t resource_uri;
LWM2M_URI_RESET(&resource_uri);
resource_uri.objectId = LWM2M_SECURITY_URI_ID;
resource_uri.instanceId = sec_obj_inst_id;
resource_uri.resourceId = LWM2M_SECURITY_URI_ID;

int res = lwm2m_get_string(client_data, &resource_uri, uri, &uri_len);
if (res < 0) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/wakaama/contrib/objects/ipso_sensor_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static uint8_t _read_cb(lwm2m_context_t * context, uint16_t instance_id, int * n
}

static uint8_t _exec_cb(lwm2m_context_t * context, uint16_t instance_id, uint16_t resource_id,
uint8_t * buffer, int length, lwm2m_object_t * object);
uint8_t * buffer, int length, lwm2m_object_t * object)
{
(void)context;
(void)buffer;
Expand Down Expand Up @@ -380,13 +380,12 @@ static void _mark_resource_as_changed(const lwm2m_object_t *object, uint16_t ins
uint16_t resource_id)
{
lwm2m_uri_t uri;
LWM2M_URI_RESET(&uri);

uri.objectId = object->objID;
uri.instanceId = instance_id;
uri.resourceId = resource_id;

uri.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | LWM2M_URI_FLAG_RESOURCE_ID;

lwm2m_resource_value_changed(lwm2m_client_get_ctx(object->userData), &uri);
}

Expand Down
1 change: 1 addition & 0 deletions pkg/wakaama/contrib/objects/light_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
* @return COAP_500_INTERNAL_SERVER_ERROR otherwise
*/
static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_data_t * data_array, lwm2m_object_t * object, lwm2m_write_type_t write_type);

Check warning on line 78 in pkg/wakaama/contrib/objects/light_control.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

/**
* @brief Gets the current value of a given @p instance.
Expand Down Expand Up @@ -219,7 +219,7 @@
}

static uint8_t _write_cb(lwm2m_context_t * context, uint16_t instance_id, int num_data,
lwm2m_data_t * data_array, lwm2m_object_t * object, lwm2m_write_type_t write_type)

Check warning on line 222 in pkg/wakaama/contrib/objects/light_control.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
{
(void)context;
(void)write_type;
Expand Down Expand Up @@ -285,7 +285,7 @@
}

case LWM2M_LIGHT_CONTROL_COLOUR_ID:
if (data_array[i].type != LWM2M_TYPE_STRING && data_array[i].type != LWM2M_TYPE_OPAQUE) {

Check warning on line 288 in pkg/wakaama/contrib/objects/light_control.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
DEBUG("[lwm2m:light_control:write]: invalid type for color"
"(%" PRId8 ")\n", (uint8_t)(data_array[i].type));
result = COAP_400_BAD_REQUEST;
Expand All @@ -307,7 +307,7 @@
break;

case LWM2M_LIGHT_CONTROL_APP_TYPE_ID:
if (data_array[i].type != LWM2M_TYPE_STRING && data_array[i].type != LWM2M_TYPE_OPAQUE) {

Check warning on line 310 in pkg/wakaama/contrib/objects/light_control.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
DEBUG("[lwm2m:light_control:write]: invalid type for app_type"
"(%" PRId8 ")\n", (uint8_t)(data_array[i].type));
result = COAP_400_BAD_REQUEST;
Expand Down Expand Up @@ -343,6 +343,7 @@
static void _mark_resource_changed(uint16_t instance_id, uint16_t resource_id)
{
lwm2m_uri_t uri;
LWM2M_URI_RESET(&uri);
uri.objectId = LWM2M_LIGHT_CONTROL_OBJECT_ID;
uri.instanceId = instance_id;
uri.resourceId = resource_id;
Expand All @@ -352,7 +353,7 @@
lwm2m_resource_value_changed(client_data->lwm2m_ctx, &uri);
}


Check warning on line 356 in pkg/wakaama/contrib/objects/light_control.c

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
lwm2m_object_t *lwm2m_object_light_control_init(lwm2m_client_data_t *client_data)
{
/* initialize the instances */
Expand Down
35 changes: 0 additions & 35 deletions pkg/wakaama/include/objects/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,41 +507,6 @@ int lwm2m_set_objlink(lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri,
int lwm2m_set_objlink_by_path(lwm2m_client_data_t *client_data, const char *path, size_t path_len,
uint16_t object_id_in, uint16_t instance_id_in);

#ifdef DOXYGEN
/**
* @name URI representation
* @brief Note that these are defined in `liblwm2m.h`.
* @{
*/

/**
* @brief Flag to indicate in @ref lwm2m_uri_t::flag that the object ID is present.
*/
#define LWM2M_URI_FLAG_OBJECT_ID (uint8_t)0x04

/**
* @brief Flag to indicate in @ref lwm2m_uri_t::flag that the instance ID is present.
*/
#define LWM2M_URI_FLAG_INSTANCE_ID (uint8_t)0x02

/**
* @brief Flag to indicate in @ref lwm2m_uri_t::flag that the resource ID is present.
*/
#define LWM2M_URI_FLAG_RESOURCE_ID (uint8_t)0x01

/**
* @brief Representation of an URI in a LwM2M client (defined in `liblwm2m.h`).
*/
typedef struct {
uint8_t flag; /**< indicates which segments are present */
uint16_t objectId; /**< object ID */
uint16_t instanceId; /**< instance ID */
uint16_t resourceId; /**< resource ID */
} lwm2m_uri_t;

/** @} */
#endif /* DOXYGEN */

#ifdef __cplusplus
}
#endif
Expand Down
Loading