2019-11-29 17:54:08 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 HAW Hamburg
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @{
|
|
|
|
* @ingroup lwm2m_client
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Helper functions to interact with the basic objects provided by
|
|
|
|
* Wakaama from a LwM2M client.
|
|
|
|
*
|
|
|
|
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "kernel_defines.h"
|
|
|
|
|
|
|
|
#include "lwm2m_client.h"
|
|
|
|
#include "lwm2m_client_config.h"
|
|
|
|
#include "lwm2m_client_objects.h"
|
|
|
|
|
|
|
|
/* These functions are defined by the objects (object_security.c and
|
|
|
|
* object_server.c are implemented by the Wakaama package. device.c can be
|
|
|
|
* found in 'contrib/objects') */
|
|
|
|
lwm2m_object_t *get_security_object(int server_id, const char *server_uri,
|
|
|
|
char *bs_psk_id, char *psk,
|
|
|
|
uint16_t psk_len, bool is_bootstrap);
|
|
|
|
lwm2m_object_t *get_server_object(int server_id, const char *binding,
|
|
|
|
int lifetime, bool storing);
|
|
|
|
lwm2m_object_t *lwm2m_get_object_device(void);
|
|
|
|
|
|
|
|
lwm2m_object_t *lwm2m_client_get_security_object(
|
|
|
|
lwm2m_client_data_t *client_data)
|
|
|
|
{
|
2021-02-05 17:44:22 +01:00
|
|
|
(void)client_data;
|
2019-11-29 17:54:08 +01:00
|
|
|
lwm2m_object_t *ret;
|
2019-12-17 13:57:01 +01:00
|
|
|
char *server_uri = CONFIG_LWM2M_SERVER_URI;
|
|
|
|
int server_id = CONFIG_LWM2M_SERVER_ID;
|
2019-11-29 17:54:08 +01:00
|
|
|
uint16_t psk_len = -1;
|
|
|
|
char *psk_buffer = NULL;
|
|
|
|
char *psk_id = NULL;
|
|
|
|
|
|
|
|
ret = get_security_object(server_id, server_uri, psk_id, psk_buffer,
|
2019-12-17 13:57:01 +01:00
|
|
|
psk_len, IS_ACTIVE(CONFIG_LWM2M_BOOTSTRAP));
|
2019-11-29 17:54:08 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
lwm2m_object_t *lwm2m_client_get_server_object(
|
|
|
|
lwm2m_client_data_t *client_data)
|
|
|
|
{
|
|
|
|
(void)client_data;
|
|
|
|
lwm2m_object_t *ret;
|
2019-12-17 13:57:01 +01:00
|
|
|
int server_id = CONFIG_LWM2M_SERVER_ID;
|
|
|
|
int lifetime = CONFIG_LWM2M_DEVICE_TTL;
|
2019-11-29 17:54:08 +01:00
|
|
|
|
2019-12-17 13:57:01 +01:00
|
|
|
ret = get_server_object(server_id, CONFIG_LWM2M_DEVICE_BINDINGS, lifetime,
|
|
|
|
false);
|
2019-11-29 17:54:08 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
lwm2m_object_t *lwm2m_client_get_device_object(
|
|
|
|
lwm2m_client_data_t *client_data)
|
|
|
|
{
|
|
|
|
(void)client_data;
|
|
|
|
return lwm2m_get_object_device();
|
|
|
|
}
|