Commit 5705573c authored by Jukka Rissanen's avatar Jukka Rissanen
Browse files

net: lwm2m: Convert to new logging system



Use new logging system instead of SYS_LOG.

Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
parent ac88baca
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -14,17 +14,14 @@ menuconfig LWM2M

if LWM2M

config SYS_LOG_LWM2M_LEVEL
	int "LWM2M log level"
	depends on SYS_LOG
	default 1
	range 0 4
	help
	  Set the log level for the LWM2M library.
module=LWM2M
module-dep=LOG
module-str=Log level for LWM2M library
source "subsys/net/Kconfig.template.log_config.net"

config LWM2M_ENGINE_STACK_SIZE
	int "LWM2M engine stack size"
	default 1536 if NET_LOG_GLOBAL
	default 1536 if NET_LOG
	default 1024
	help
	 Set the stack size for the LWM2M library engine (used for handling
+12 −9
Original line number Diff line number Diff line
@@ -10,9 +10,12 @@
 * Section: "16. IPSO Object: Light Control"
 */

#define SYS_LOG_DOMAIN "ipso_light_control"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_LWM2M_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME net_ipso_light_control
#define LOG_LEVEL CONFIG_LWM2M_LOG_LEVEL

#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#include <stdint.h>
#include <init.h>
#include <net/lwm2m.h>
@@ -87,7 +90,7 @@ static int on_time_post_write_cb(u16_t obj_inst_id,
	int i;

	if (data_len != 4) {
		SYS_LOG_ERR("unknown size %u", data_len);
		LOG_ERR("unknown size %u", data_len);
		return -EINVAL;
	}

@@ -116,7 +119,7 @@ static struct lwm2m_engine_obj_inst *light_control_create(u16_t obj_inst_id)
	/* Check that there is no other instance with this ID */
	for (index = 0; index < MAX_INSTANCE_COUNT; index++) {
		if (inst[index].obj && inst[index].obj_inst_id == obj_inst_id) {
			SYS_LOG_ERR("Can not create instance - "
			LOG_ERR("Can not create instance - "
				"already existing: %u", obj_inst_id);
			return NULL;
		}
@@ -128,8 +131,8 @@ static struct lwm2m_engine_obj_inst *light_control_create(u16_t obj_inst_id)
	}

	if (avail < 0) {
		SYS_LOG_ERR("Can not create instance - "
			    "no more room: %u", obj_inst_id);
		LOG_ERR("Can not create instance - no more room: %u",
			obj_inst_id);
		return NULL;
	}

@@ -166,7 +169,7 @@ static struct lwm2m_engine_obj_inst *light_control_create(u16_t obj_inst_id)
	inst[avail].resources = res[avail];
	inst[avail].resource_count = i;

	SYS_LOG_DBG("Create IPSO Light Control instance: %d", obj_inst_id);
	LOG_DBG("Create IPSO Light Control instance: %d", obj_inst_id);

	return &inst[avail];
}
+12 −10
Original line number Diff line number Diff line
@@ -10,9 +10,12 @@
 * Section: "10. IPSO Object: Temperature"
 */

#define SYS_LOG_DOMAIN "ipso_temp_sensor"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_LWM2M_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME net_ipso_temp_sensor
#define LOG_LEVEL CONFIG_LWM2M_LOG_LEVEL

#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#include <stdint.h>
#include <init.h>
#include <net/lwm2m.h>
@@ -77,7 +80,7 @@ static int reset_min_max_measured_values_cb(u16_t obj_inst_id)
{
	int i;

	SYS_LOG_DBG("RESET MIN/MAX %d", obj_inst_id);
	LOG_DBG("RESET MIN/MAX %d", obj_inst_id);
	for (i = 0; i < MAX_INSTANCE_COUNT; i++) {
		if (inst[i].obj && inst[i].obj_inst_id == obj_inst_id) {
			update_min_measured(obj_inst_id, i);
@@ -138,7 +141,7 @@ static struct lwm2m_engine_obj_inst *temp_sensor_create(u16_t obj_inst_id)
	/* Check that there is no other instance with this ID */
	for (index = 0; index < MAX_INSTANCE_COUNT; index++) {
		if (inst[index].obj && inst[index].obj_inst_id == obj_inst_id) {
			SYS_LOG_ERR("Can not create instance - "
			LOG_ERR("Can not create instance - "
				"already existing: %u", obj_inst_id);
			return NULL;
		}
@@ -151,8 +154,8 @@ static struct lwm2m_engine_obj_inst *temp_sensor_create(u16_t obj_inst_id)
	}

	if (index >= MAX_INSTANCE_COUNT) {
		SYS_LOG_ERR("Can not create instance - "
			    "no more room: %u", obj_inst_id);
		LOG_ERR("Can not create instance - no more room: %u",
			obj_inst_id);
		return NULL;
	}

@@ -193,8 +196,7 @@ static struct lwm2m_engine_obj_inst *temp_sensor_create(u16_t obj_inst_id)

	inst[index].resources = res[index];
	inst[index].resource_count = i;
	SYS_LOG_DBG("Create IPSO Temperature Sensor instance: %d",
		    obj_inst_id);
	LOG_DBG("Create IPSO Temperature Sensor instance: %d", obj_inst_id);
	return &inst[index];
}

+164 −167

File changed.

Preview size limit exceeded, changes collapsed.

+18 −16
Original line number Diff line number Diff line
@@ -10,9 +10,12 @@
 * - Configurable CURRENT_TIME notification delay
 */

#define SYS_LOG_DOMAIN "lwm2m_obj_device"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_LWM2M_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME net_lwm2m_obj_device
#define LOG_LEVEL CONFIG_LWM2M_LOG_LEVEL

#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#include <string.h>
#include <stdio.h>
#include <init.h>
@@ -117,13 +120,13 @@ static struct lwm2m_engine_res_inst res[DEVICE_MAX_ID];

static int reboot_cb(u16_t obj_inst_id)
{
	SYS_LOG_DBG("REBOOT");
	LOG_DBG("REBOOT");
	return -EPERM;
}

static int factory_default_cb(u16_t obj_inst_id)
{
	SYS_LOG_DBG("FACTORY_DEFAULT");
	LOG_DBG("FACTORY_DEFAULT");
	return -EPERM;
}

@@ -156,7 +159,7 @@ static int current_time_post_write_cb(u16_t obj_inst_id,
		return 0;
	}

	SYS_LOG_ERR("unknown size %u", data_len);
	LOG_ERR("unknown size %u", data_len);
	return -EINVAL;
}

@@ -167,8 +170,7 @@ int lwm2m_device_add_pwrsrc(u8_t pwrsrc_type)
	int index;

	if (pwrsrc_type < 0 || pwrsrc_type >= LWM2M_DEVICE_PWR_SRC_TYPE_MAX) {
		SYS_LOG_ERR("power source id %d is invalid",
			    pwrsrc_type);
		LOG_ERR("power source id %d is invalid", pwrsrc_type);
		return -EINVAL;
	}

@@ -198,12 +200,12 @@ int lwm2m_device_add_pwrsrc(u8_t pwrsrc_type)
int lwm2m_device_remove_pwrsrc(int index)
{
	if (index < 0 || index >= DEVICE_PWRSRC_MAX) {
		SYS_LOG_ERR("index is out of range: %d", index);
		LOG_ERR("index is out of range: %d", index);
		return -EINVAL;
	}

	if (pwrsrc_available[index] < 0) {
		SYS_LOG_ERR("Power source index %d isn't registered", index);
		LOG_ERR("Power source index %d isn't registered", index);
		return -EINVAL;
	}

@@ -219,12 +221,12 @@ int lwm2m_device_remove_pwrsrc(int index)
int lwm2m_device_set_pwrsrc_voltage_mv(int index, int voltage_mv)
{
	if (index < 0 || index >= DEVICE_PWRSRC_MAX) {
		SYS_LOG_ERR("index is out of range: %d", index);
		LOG_ERR("index is out of range: %d", index);
		return -EINVAL;
	}

	if (pwrsrc_available[index] < 0) {
		SYS_LOG_ERR("Power source index %d isn't registered.", index);
		LOG_ERR("Power source index %d isn't registered.", index);
		return -EINVAL;
	}

@@ -237,12 +239,12 @@ int lwm2m_device_set_pwrsrc_voltage_mv(int index, int voltage_mv)
int lwm2m_device_set_pwrsrc_current_ma(int index, int current_ma)
{
	if (index < 0 || index >= DEVICE_PWRSRC_MAX) {
		SYS_LOG_ERR("index is out of range: %d", index);
		LOG_ERR("index is out of range: %d", index);
		return -EINVAL;
	}

	if (pwrsrc_available[index] < 0) {
		SYS_LOG_ERR("Power source index %d isn't registered.", index);
		LOG_ERR("Power source index %d isn't registered.", index);
		return -EINVAL;
	}

@@ -315,7 +317,7 @@ static struct lwm2m_engine_obj_inst *device_create(u16_t obj_inst_id)

	inst.resources = res;
	inst.resource_count = i;
	SYS_LOG_DBG("Create LWM2M device instance: %d", obj_inst_id);
	LOG_DBG("Create LWM2M device instance: %d", obj_inst_id);
	return &inst;
}

@@ -348,7 +350,7 @@ static int lwm2m_device_init(struct device *dev)
	/* auto create the only instance */
	ret = lwm2m_create_obj_inst(LWM2M_OBJECT_DEVICE_ID, 0, &obj_inst);
	if (ret < 0) {
		SYS_LOG_DBG("Create LWM2M instance 0 error: %d", ret);
		LOG_DBG("Create LWM2M instance 0 error: %d", ret);
	}

	/* call device_periodic_service() every 10 seconds */
Loading