aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m')
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.c553
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.h628
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.c143
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.h94
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.c885
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.h109
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_api.h426
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.c203
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.h69
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_coap_util.c166
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.c347
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.h443
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.c498
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.h124
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.c542
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.h69
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.c399
-rw-r--r--thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.h207
18 files changed, 5905 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.c
new file mode 100644
index 0000000..638277a
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.c
@@ -0,0 +1,553 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include <stddef.h>
+
+#include "ipso_objects.h"
+#include "lwm2m.h"
+#include "lwm2m_tlv.h"
+
+//lint -e516 -save // Symbol '__INTADDR__()' has arg. type conflict
+#define LWM2M_INSTANCE_OFFSET_SET(instance, type) \
+ instance->proto.operations_offset = offsetof(type, operations); \
+ instance->proto.resource_ids_offset = offsetof(type, resource_ids);
+//lint -restore
+
+void ipso_instance_digital_input_init(ipso_digital_input_t * p_instance)
+{
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_digital_input_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_DIGITAL_INPUT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_digital_input_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[6] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_INPUT_STATE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_DIGITAL_INPUT_POLARITY;
+ p_instance->resource_ids[3] = IPSO_RR_ID_DIGITAL_INPUT_DEBOUNCE_PERIOD;
+ p_instance->resource_ids[4] = IPSO_RR_ID_DIGITAL_INPUT_EDGE_SELECTION;
+ p_instance->resource_ids[5] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER_RESET;
+ p_instance->resource_ids[6] = IPSO_RR_ID_APPLICATION_TYPE;
+ p_instance->resource_ids[7] = IPSO_RR_ID_SENSOR_TYPE;
+
+
+}
+
+void ipso_instance_digital_output_init(ipso_digital_output_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_digital_output_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_DIGITAL_OUTPUT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_digital_output_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_OUTPUT_STATE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY;
+ p_instance->resource_ids[2] = IPSO_RR_ID_APPLICATION_TYPE;
+}
+
+
+void ipso_instance_analog_input_init(ipso_analog_input_t * p_instance)
+{
+
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_analog_input_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_ANALOGUE_INPUT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_analog_input_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[6] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_ANALOG_INPUT_CURRENT_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+ p_instance->resource_ids[6] = IPSO_RR_ID_APPLICATION_TYPE;
+ p_instance->resource_ids[7] = IPSO_RR_ID_SENSOR_TYPE;
+}
+
+void ipso_instance_analog_output_init(ipso_analog_output_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_analog_output_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_ANALOGUE_OUTPUT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_analog_output_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_ANALOG_OUTPUT_CURRENT_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_APPLICATION_TYPE;
+}
+
+void ipso_instance_generic_sensor_init(ipso_generic_sensor_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_generic_sensor_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_GENERIC_SENSOR;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_generic_sensor_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[7] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+ p_instance->resource_ids[7] = IPSO_RR_ID_APPLICATION_TYPE;
+ p_instance->resource_ids[8] = IPSO_RR_ID_SENSOR_TYPE;
+}
+
+void ipso_instance_illuminance_init(ipso_illuminance_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_illuminance_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_ILLUMINANCE_SENSOR;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_illuminance_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+}
+
+void ipso_instance_presence_init(ipso_presence_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_presence_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_PRESENCE_SENSOR;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_presence_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[5] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_INPUT_STATE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER_RESET;
+ p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_TYPE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_BUSY_TO_CLEAR_DELAY;
+ p_instance->resource_ids[5] = IPSO_RR_ID_CLEAR_TO_BUSY_DELAY;
+}
+
+void ipso_instance_temperature_init(ipso_temperature_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_temperature_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_TEMPERATURE_SENSOR;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_temperature_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+}
+
+void ipso_instance_humidity_init(ipso_humidity_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_humidity_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_HUMIDITY_SENSOR;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_humidity_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+}
+
+void ipso_instance_power_measurement_init(ipso_power_measurement_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_power_measurement_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_POWER_MEASUREMENT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_power_measurement_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[9] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[10] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[11] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[12] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[13] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[14] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[15] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[16] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[17] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_INSTANTANEOUS_ACTIVE_POWER;
+ p_instance->resource_ids[1] = IPSO_RR_ID_MIN_MEASURED_ACTIVE_POWER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MAX_MEASURED_ACTIVE_POWER;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MIN_RANGE_ACTIVE_POWER;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MAX_RANGE_ACTIVE_POWER;
+ p_instance->resource_ids[5] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
+ p_instance->resource_ids[6] = IPSO_RR_ID_ACTIVE_POWER_CALIBRATION;
+ p_instance->resource_ids[7] = IPSO_RR_ID_INSTANTANEOUS_REACTIVE_POWER;
+ p_instance->resource_ids[8] = IPSO_RR_ID_MIN_MEASURED_REACTIVE_POWER;
+ p_instance->resource_ids[9] = IPSO_RR_ID_MAX_MEASURED_REACTIVE_POWER;
+ p_instance->resource_ids[10] = IPSO_RR_ID_MIN_RANGE_REACTIVE_POWER;
+ p_instance->resource_ids[11] = IPSO_RR_ID_MAX_RANGE_REACTIVE_POWER;
+ p_instance->resource_ids[12] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+ p_instance->resource_ids[13] = IPSO_RR_ID_CUMULATIVE_REACTIVE_POWER;
+ p_instance->resource_ids[14] = IPSO_RR_ID_REACTIVE_POWER_CALIBRATION;
+ p_instance->resource_ids[15] = IPSO_RR_ID_POWER_FACTOR;
+ p_instance->resource_ids[16] = IPSO_RR_ID_CURRENT_CALIBRATION;
+ p_instance->resource_ids[17] = IPSO_RR_ID_RESET_CUMULATIVE_ENERGY;
+}
+
+void ipso_instance_actuation_init(ipso_actuation_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_actuation_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_ACTUATION;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_actuation_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_ON_TIME;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MULTI_STATE_OUTPUT;
+ p_instance->resource_ids[4] = IPSO_RR_ID_APPLICATION_TYPE;
+}
+
+void ipso_instance_set_point_init(ipso_set_point_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_set_point_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_SET_POINT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_set_point_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_SETPOINT_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_COLOUR;
+ p_instance->resource_ids[2] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[3] = IPSO_RR_ID_APPLICATION_TYPE;
+}
+
+void ipso_instance_load_control_init(ipso_load_control_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_load_control_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_LOAD_CONTROL;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_load_control_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[5] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_EVENT_IDENTIFIER;
+ p_instance->resource_ids[1] = IPSO_RR_ID_START_TIME;
+ p_instance->resource_ids[2] = IPSO_RR_ID_DURATION_IN_MIN;
+ p_instance->resource_ids[3] = IPSO_RR_ID_CRITICALITY_LEVEL;
+ p_instance->resource_ids[4] = IPSO_RR_ID_AVG_LOAD_ADJPCT;
+ p_instance->resource_ids[5] = IPSO_RR_ID_DUTY_CYCLE;
+}
+
+void ipso_instance_light_control_init(ipso_light_control_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_light_control_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_LIGHT_CONTROL;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_light_control_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_COLOUR;
+ p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[4] = IPSO_RR_ID_ON_TIME;
+ p_instance->resource_ids[5] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
+ p_instance->resource_ids[6] = IPSO_RR_ID_POWER_FACTOR;
+}
+
+void ipso_instance_power_control_init(ipso_power_control_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_power_control_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_POWER_CONTROL;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_power_control_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
+ p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
+ p_instance->resource_ids[2] = IPSO_RR_ID_ON_TIME;
+ p_instance->resource_ids[3] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
+ p_instance->resource_ids[4] = IPSO_RR_ID_POWER_FACTOR;
+}
+
+void ipso_instance_accelerometer_init(ipso_accelerometer_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_accelerometer_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_ACCELEROMETER;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_accelerometer_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_X_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_Y_VALUE;
+ p_instance->resource_ids[2] = IPSO_RR_ID_Z_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+}
+
+void ipso_instance_magnetometer_init(ipso_magnetometer_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_magnetometer_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_MAGNETOMETER;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_magnetometer_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = IPSO_RR_ID_X_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_Y_VALUE;
+ p_instance->resource_ids[2] = IPSO_RR_ID_Z_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[4] = IPSO_RR_ID_COMPASS_DIRECTION;
+}
+
+void ipso_instance_barometer_init(ipso_barometer_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_barometer_t);
+
+ p_instance->proto.object_id = IPSO_SO_ID_BAROMETER;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((ipso_barometer_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+
+
+ p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
+ p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
+ p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
+ p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
+ p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
+ p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
+ p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.h
new file mode 100644
index 0000000..7a9ca8e
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects.h
@@ -0,0 +1,628 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**@file lwm2m_objects.h
+ *
+ * @defgroup iot_sdk_ipso_objects IPSO Smart Object definititions and types
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief IPSO objects definitions and types.
+ *
+ * @note The definitions used in this module are from the IPSO Alliance
+ * "IPSO SmartOject Guideline - Smart Objects Starter Pack1.0".
+ * The specification could be found at http://www.ipso-alliance.org/.
+ */
+
+#ifndef IPSO_OBJECTS_H__
+#define IPSO_OBJECTS_H__
+
+#include "lwm2m_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IPSO_SO_ID_DIGITAL_INPUT 3200
+#define IPSO_SO_ID_DIGITAL_OUTPUT 3201
+#define IPSO_SO_ID_ANALOGUE_INPUT 3202
+#define IPSO_SO_ID_ANALOGUE_OUTPUT 3203
+#define IPSO_SO_ID_GENERIC_SENSOR 3300
+#define IPSO_SO_ID_ILLUMINANCE_SENSOR 3301
+#define IPSO_SO_ID_PRESENCE_SENSOR 3302
+#define IPSO_SO_ID_TEMPERATURE_SENSOR 3303
+#define IPSO_SO_ID_HUMIDITY_SENSOR 3304
+#define IPSO_SO_ID_POWER_MEASUREMENT 3305
+#define IPSO_SO_ID_ACTUATION 3306
+#define IPSO_SO_ID_SET_POINT 3308
+#define IPSO_SO_ID_LOAD_CONTROL 3310
+#define IPSO_SO_ID_LIGHT_CONTROL 3311
+#define IPSO_SO_ID_POWER_CONTROL 3312
+#define IPSO_SO_ID_ACCELEROMETER 3313
+#define IPSO_SO_ID_MAGNETOMETER 3314
+#define IPSO_SO_ID_BAROMETER 3315
+
+/** @brief IPSO Reusable Resource IDs (Section 21). */
+#define IPSO_RR_ID_DIGITAL_INPUT_STATE 5500
+#define IPSO_RR_ID_DIGITAL_INPUT_COUNTER 5501
+#define IPSO_RR_ID_DIGITAL_INPUT_POLARITY 5502
+#define IPSO_RR_ID_DIGITAL_INPUT_DEBOUNCE_PERIOD 5503
+#define IPSO_RR_ID_DIGITAL_INPUT_EDGE_SELECTION 5504
+#define IPSO_RR_ID_DIGITAL_INPUT_COUNTER_RESET 5505
+
+#define IPSO_RR_ID_DIGITAL_OUTPUT_STATE 5550
+#define IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY 5551
+
+
+// Digital output polarity options.
+#define IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY_NORMAL 0
+#define IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY_REVERSED 1
+
+#define IPSO_RR_ID_ANALOG_INPUT_CURRENT_VALUE 5600
+#define IPSO_RR_ID_MIN_MEASURED_VALUE 5601
+#define IPSO_RR_ID_MAX_MEASURED_VALUE 5602
+#define IPSO_RR_ID_MIN_RANGE_VALUE 5603
+#define IPSO_RR_ID_MAX_RANGE_VALUE 5604
+#define IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES 5605
+
+#define IPSO_RR_ID_ANALOG_OUTPUT_CURRENT_VALUE 5650
+
+#define IPSO_RR_ID_SENSOR_VALUE 5700
+#define IPSO_RR_ID_SENSOR_UNITS 5701
+#define IPSO_RR_ID_X_VALUE 5702
+#define IPSO_RR_ID_Y_VALUE 5703
+#define IPSO_RR_ID_Z_VALUE 5704
+#define IPSO_RR_ID_COMPASS_DIRECTION 5705
+#define IPSO_RR_ID_COLOUR 5706
+
+#define IPSO_RR_ID_APPLICATION_TYPE 5750
+#define IPSO_RR_ID_SENSOR_TYPE 5751
+
+#define IPSO_RR_ID_INSTANTANEOUS_ACTIVE_POWER 5800
+#define IPSO_RR_ID_MIN_MEASURED_ACTIVE_POWER 5801
+#define IPSO_RR_ID_MAX_MEASURED_ACTIVE_POWER 5802
+#define IPSO_RR_ID_MIN_RANGE_ACTIVE_POWER 5803
+#define IPSO_RR_ID_MAX_RANGE_ACTIVE_POWER 5804
+#define IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER 5805
+#define IPSO_RR_ID_ACTIVE_POWER_CALIBRATION 5806
+
+#define IPSO_RR_ID_INSTANTANEOUS_REACTIVE_POWER 5810
+#define IPSO_RR_ID_MIN_MEASURED_REACTIVE_POWER 5811
+#define IPSO_RR_ID_MAX_MEASURED_REACTIVE_POWER 5812
+#define IPSO_RR_ID_MIN_RANGE_REACTIVE_POWER 5813
+#define IPSO_RR_ID_MAX_RANGE_REACTIVE_POWER 5814
+#define IPSO_RR_ID_CUMULATIVE_REACTIVE_POWER 5815
+#define IPSO_RR_ID_REACTIVE_POWER_CALIBRATION 5816
+
+#define IPSO_RR_ID_POWER_FACTOR 5820
+#define IPSO_RR_ID_CURRENT_CALIBRATION 5821
+#define IPSO_RR_ID_RESET_CUMULATIVE_ENERGY 5822
+#define IPSO_RR_ID_EVENT_IDENTIFIER 5823
+#define IPSO_RR_ID_START_TIME 5824
+#define IPSO_RR_ID_DURATION_IN_MIN 5825
+#define IPSO_RR_ID_CRITICALITY_LEVEL 5826
+#define IPSO_RR_ID_AVG_LOAD_ADJPCT 5827
+#define IPSO_RR_ID_DUTY_CYCLE 5828
+
+#define IPSO_RR_ID_ON_OFF 5850
+#define IPSO_RR_ID_DIMMER 5851
+#define IPSO_RR_ID_ON_TIME 5852
+#define IPSO_RR_ID_MULTI_STATE_OUTPUT 5853
+
+#define IPSO_RR_ID_SETPOINT_VALUE 5900
+
+#define IPSO_RR_ID_BUSY_TO_CLEAR_DELAY 5903
+#define IPSO_RR_ID_CLEAR_TO_BUSY_DELAY 5904
+
+
+
+/* Digital input ID: 3200 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[8]; /* Internal. */
+ uint16_t resource_ids[8]; /* Internal. */
+
+ /* Public members. */
+ bool state;
+ uint32_t counter;
+ bool polarity;
+ uint32_t debounce_period; /* Unit: milliseconds */
+ uint8_t edge_selection; /* Range: 1-3 */
+ /* Counter reset is execute only */
+ lwm2m_string_t application_type;
+ lwm2m_string_t sensor_type;
+
+} ipso_digital_input_t;
+
+
+/* Digital output ID: 3201 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
+ uint8_t operations[3]; /* Internal. MUST be second. */
+ uint16_t resource_ids[3]; /* Internal. MUST be third. */
+
+ /* Public members. */
+ bool digital_output_state;
+ bool digital_output_polarity;
+ lwm2m_string_t application_type;
+
+} ipso_digital_output_t;
+
+/* Analog input ID: 3202 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[8]; /* Internal. */
+ uint16_t resource_ids[8]; /* Internal. */
+
+ /* Public members. */
+ float current_value;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+ lwm2m_string_t application_type;
+ lwm2m_string_t sensor_type;
+} ipso_analog_input_t;
+
+/* Analog output ID: 3203 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[4]; /* Internal. */
+ uint16_t resource_ids[4]; /* Internal. */
+
+ /* Public members. */
+ float current_value;
+ float min_range_value;
+ float max_range_value;
+ lwm2m_string_t application_type;
+
+} ipso_analog_output_t;
+
+/* Generic sensor ID: 3300 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[9]; /* Internal. */
+ uint16_t resource_ids[9]; /* Internal. */
+
+ /* Public members. */
+ float sensor_value;
+ lwm2m_string_t units;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+ lwm2m_string_t application_type;
+ lwm2m_string_t sensor_type;
+
+} ipso_generic_sensor_t;
+
+/* Illuminance ID: 3301 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[7]; /* Internal. */
+ uint16_t resource_ids[7]; /* Internal. */
+
+ /* Public members. */
+ float sensor_value;
+ lwm2m_string_t units;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+
+} ipso_illuminance_t;
+
+/* Presence ID: 3302 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[8]; /* Internal. */
+ uint16_t resource_ids[8]; /* Internal. */
+
+ /* Public members. */
+ bool digital_input_state;
+ uint32_t digital_input_counter;
+ /* Digital input counter reset is execute only */
+ lwm2m_string_t sensor_type;
+ uint32_t busy_to_clear_delay; // Unit: ms
+ uint32_t clear_to_busy_delay; // Unit: ms
+
+
+} ipso_presence_t;
+
+/* Temperature ID: 3303 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[7]; /* Internal. */
+ uint16_t resource_ids[7]; /* Internal. */
+
+ /* Public members. */
+ float sensor_value;
+ lwm2m_string_t units;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+
+
+} ipso_temperature_t;
+
+/* Humidity ID: 3304 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[8]; /* Internal. */
+ uint16_t resource_ids[8]; /* Internal. */
+
+ /* Public members. */
+ float sensor_value;
+ lwm2m_string_t units;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+
+} ipso_humidity_t;
+
+/* Power measurement ID: 3305 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[18]; /* Internal. */
+ uint16_t resource_ids[18]; /* Internal. */
+
+ /* Public members. */
+ float instantaneous_active_power;
+ float min_measured_active_power;
+ float max_measured_active_power;
+ float min_range_active_power;
+ float max_range_active_power;
+ float cumulative_active_power;
+ float active_power_calibration;
+ float instantaneous_reactive_power;
+ float min_measured_reactive_power;
+ float max_measured_reactive_power;
+ float min_range_reactive_power;
+ float max_range_reactive_power;
+ /* Reset min and max measured values is execute only */
+ float cumulative_reactive_power;
+ float reactive_power_calibration;
+ float power_factor;
+ float current_calibration;
+ /* Reset cumulative is execute only */
+
+} ipso_power_measurement_t;
+
+/* Actuation ID: 3306 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[5]; /* Internal. */
+ uint16_t resource_ids[5]; /* Internal. */
+
+ /* Public members. */
+ bool on;
+ uint16_t dimmer; // Unit: % Range: 0 - 100
+ uint32_t on_time; // Unit: s
+ lwm2m_string_t multi_state_output;
+ lwm2m_string_t application_type;
+
+} ipso_actuation_t;
+
+/* Set point ID: 3308 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[4]; /* Internal. */
+ uint16_t resource_ids[4]; /* Internal. */
+
+ /* Public members. */
+ float set_point_value;
+ lwm2m_string_t colour;
+ lwm2m_string_t units;
+ lwm2m_string_t application_type;
+
+} ipso_set_point_t;
+
+/* Load control ID: 3310 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[6]; /* Internal. */
+ uint16_t resource_ids[6]; /* Internal. */
+
+ /* Public members. */
+ lwm2m_string_t event_identifier;
+ lwm2m_time_t start_time;
+ uint32_t duration_in_min;
+ uint8_t criticality_level; // Range: 0-3
+ uint16_t avg_load_adjpct; // Unit: % range: 0-100
+ uint16_t duty_cycle; // Unit: % range: 0-100
+
+
+} ipso_load_control_t;
+
+/* Light control ID: 3311 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[7]; /* Internal. */
+ uint16_t resource_ids[7]; /* Internal. */
+
+ /* Public members. */
+ bool on;
+ uint16_t dimmer; // Unit: % Range: 0 - 100
+ lwm2m_string_t colour;
+ lwm2m_string_t units;
+ uint32_t on_time; // Unit: s
+ float cumulative_active_power;
+ float power_factor;
+
+} ipso_light_control_t;
+
+/* Power control ID: 3312 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[5]; /* Internal. */
+ uint16_t resource_ids[5]; /* Internal. */
+
+ /* Public members. */
+ bool on;
+ uint16_t dimmer; // Unit: % Range: 0 - 100
+ uint32_t on_time; // Unit: s
+ float cumulative_active_power;
+ float power_factor;
+
+} ipso_power_control_t;
+
+/* Accelerometer ID: 3313 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[6]; /* Internal. */
+ uint16_t resource_ids[6]; /* Internal. */
+
+ /* Public members. */
+ float x_value;
+ float y_value;
+ float z_value;
+ lwm2m_string_t units;
+ float min_range_value;
+ float max_range_value;
+
+} ipso_accelerometer_t;
+
+/* Magnetometer ID: 3314 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[8]; /* Internal. */
+ uint16_t resource_ids[8]; /* Internal. */
+
+ /* Public members. */
+ float x_value;
+ float y_value;
+ float z_value;
+ lwm2m_string_t units;
+ float compass_direction; // Unit: deg Range: 0-360
+
+} ipso_magnetometer_t;
+
+/* Barometer ID: 3315 */
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. */
+ uint8_t operations[7]; /* Internal. */
+ uint16_t resource_ids[7]; /* Internal. */
+
+ /* Public members. */
+ float sensor_value;
+ lwm2m_string_t units;
+ float min_measured_value;
+ float max_measured_value;
+ float min_range_value;
+ float max_range_value;
+ /* Reset min and max measured values is execute only */
+
+} ipso_barometer_t;
+
+
+/**@brief Initialize an IPSO digital input object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_digital_input_init(ipso_digital_input_t * p_instance);
+
+/**@brief Initialize an IPSO digital output object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_digital_output_init(ipso_digital_output_t * p_instance);
+
+/**@brief Initialize an IPSO analog input object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_analog_input_init(ipso_analog_input_t * p_instance);
+
+/**@brief Initialize an IPSO analog output object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_analog_output_init(ipso_analog_output_t * p_instance);
+
+/**@brief Initialize an IPSO generic sensor object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_generic_sensor_init(ipso_generic_sensor_t * p_instance);
+
+/**@brief Initialize an IPSO illuminance object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_illuminance_init(ipso_illuminance_t * p_instance);
+
+/**@brief Initialize an IPSO presence object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_presence_init(ipso_presence_t * p_instance);
+
+/**@brief Initialize an IPSO temperature object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_temperature_init(ipso_temperature_t * p_instance);
+
+/**@brief Initialize an IPSO humidity object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_humidity_init(ipso_humidity_t * p_instance);
+
+/**@brief Initialize an IPSO power measurement object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_power_measurement_init(ipso_power_measurement_t * p_instance);
+
+/**@brief Initialize an IPSO actuation object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_actuation_init(ipso_actuation_t * p_instance);
+
+/**@brief Initialize an IPSO set point object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_set_point_init(ipso_set_point_t * p_instance);
+
+/**@brief Initialize an IPSO load control object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_load_control_init(ipso_load_control_t * p_instance);
+
+/**@brief Initialize an IPSO light control object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_light_control_init(ipso_light_control_t * p_instance);
+
+/**@brief Initialize an IPSO power control object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_power_control_init(ipso_power_control_t * p_instance);
+
+/**@brief Initialize an IPSO accelerometer object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_accelerometer_init(ipso_accelerometer_t * p_instance);
+
+/**@brief Initialize an IPSO magnetometer object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_magnetometer_init(ipso_magnetometer_t * p_instance);
+
+/**@brief Initialize an IPSO barometer object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void ipso_instance_barometer_init(ipso_barometer_t * p_instance);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_OBJECTS_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.c
new file mode 100644
index 0000000..5cb53ec
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.c
@@ -0,0 +1,143 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include "ipso_objects_tlv.h"
+#include "lwm2m_tlv.h"
+
+static void index_buffer_len_update(uint32_t * index, uint32_t * buffer_len, uint32_t max_buffer)
+{
+ *index += *buffer_len;
+ *buffer_len = max_buffer - *index;
+}
+
+uint32_t ipso_tlv_ipso_digital_output_decode(ipso_digital_output_t * p_digital_output,
+ uint8_t * p_buffer,
+ uint32_t buffer_len)
+{
+ uint32_t err_code;
+ lwm2m_tlv_t tlv;
+
+ uint32_t index = 0;
+
+ while (index < buffer_len)
+ {
+ err_code = lwm2m_tlv_decode(&tlv, &index, p_buffer, buffer_len);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ switch (tlv.id)
+ {
+ case IPSO_RR_ID_DIGITAL_OUTPUT_STATE:
+ {
+ p_digital_output->digital_output_state = tlv.value[0];
+ break;
+ }
+
+ case IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY:
+ {
+ p_digital_output->digital_output_polarity = tlv.value[0];
+ break;
+ }
+
+ case IPSO_RR_ID_APPLICATION_TYPE:
+ {
+ p_digital_output->application_type.p_val = (char *)tlv.value;
+ p_digital_output->application_type.len = tlv.length;
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ return NRF_SUCCESS;
+}
+
+uint32_t ipso_tlv_ipso_digital_output_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ ipso_digital_output_t * p_digital_output)
+{
+ uint32_t err_code;
+ uint32_t max_buffer = *p_buffer_len;
+ uint32_t index = 0;
+
+ lwm2m_tlv_t tlv;
+ tlv.id_type = TLV_TYPE_RESOURCE_VAL; // type is the same for all.
+
+ // Encode state.
+ lwm2m_tlv_bool_set(&tlv, p_digital_output->digital_output_state, IPSO_RR_ID_DIGITAL_OUTPUT_STATE);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode polarity.
+ lwm2m_tlv_bool_set(&tlv, p_digital_output->digital_output_polarity, IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode application type.
+ lwm2m_tlv_string_set(&tlv, p_digital_output->application_type, IPSO_RR_ID_APPLICATION_TYPE);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ *p_buffer_len = index;
+
+ return NRF_SUCCESS;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.h
new file mode 100644
index 0000000..e2c1228
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/ipso_objects_tlv.h
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**@file lwm2m_objects_tlv.h
+ *
+ * @defgroup iot_sdk_ipso_objects_tlv IPSO Smart Object TLV encoder and decoder API
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief IPSO Smart Object TLV encoder and decoder API.
+ */
+
+#ifndef IPSO_OBJECTS_TLV_H__
+#define IPSO_OBJECTS_TLV_H__
+
+#include <stdint.h>
+#include "ipso_objects.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Decode an IPSO digital output object from a TLV byte buffer.
+ *
+ * @note Resource values NOT found in the tlv will not be altered.
+ *
+ * @warning lwm2m_string_t and lwm2m_opaque_t values will point to the byte buffer and needs
+ * to be copied by the application before the byte buffer is freed.
+ *
+ * @param[out] p_digital_output Pointer to a LWM2M server object to be filled by the decoded TLVs.
+ * @param[in] p_buffer Pointer to the TLV byte buffer to be decoded.
+ * @param[in] buffer_len Size of the buffer to be decoded.
+ *
+ * @retval NRF_SUCCESS If decoding was successfull.
+ */
+uint32_t ipso_tlv_ipso_digital_output_decode(ipso_digital_output_t * p_digital_output,
+ uint8_t * p_buffer,
+ uint32_t buffer_len);
+
+/**@brief Encode an IPSO digital output object to a TLV byte buffer.
+ *
+ * @param[out] p_buffer Pointer to a byte buffer to be used to fill the encoded TLVs.
+ * @param[inout] p_buffer_len Value by reference inicating the size of the buffer provided.
+ * Will return the number of used bytes on return.
+ * @param[in] p_digital_output Pointer to the IPSO digital output object to be encoded into TLVs.
+ *
+ * @retval NRF_SUCCESS If the encoded was successfull.
+ */
+uint32_t ipso_tlv_ipso_digital_output_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ ipso_digital_output_t * p_digital_output);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // IPSO_OBJECTS_TLV_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.c
new file mode 100644
index 0000000..bc022f1
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.c
@@ -0,0 +1,885 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "lwm2m_api.h"
+#include "lwm2m_register.h"
+#include "lwm2m_bootstrap.h"
+#include "sdk_os.h"
+#include "lwm2m.h"
+#include "sdk_config.h"
+
+#if LWM2M_CONFIG_LOG_ENABLED
+
+#define NRF_LOG_MODULE_NAME lwm2m
+
+#define NRF_LOG_LEVEL LWM2M_CONFIG_LOG_LEVEL
+#define NRF_LOG_INFO_COLOR LWM2M_CONFIG_INFO_COLOR
+#define NRF_LOG_DEBUG_COLOR LWM2M_CONFIG_DEBUG_COLOR
+
+#include "nrf_log.h"
+NRF_LOG_MODULE_REGISTER();
+
+#define LWM2M_TRC NRF_LOG_DEBUG /**< Used for getting trace of execution in the module. */
+#define LWM2M_ERR NRF_LOG_ERROR /**< Used for logging errors in the module. */
+#define LWM2M_DUMP NRF_LOG_HEXDUMP_DEBUG /**< Used for dumping octet information to get details of bond information etc. */
+
+#define LWM2M_ENTRY() LWM2M_TRC(">> %s", __func__)
+#define LWM2M_EXIT() LWM2M_TRC("<< %s", __func__)
+
+#else // LWM2M_CONFIG_LOG_ENABLED
+
+#define LWM2M_TRC(...) /**< Disables traces. */
+#define LWM2M_DUMP(...) /**< Disables dumping of octet streams. */
+#define LWM2M_ERR(...) /**< Disables error logs. */
+
+#define LWM2M_ENTRY(...)
+#define LWM2M_EXIT(...)
+
+#endif // LWM2M_CONFIG_LOG_ENABLED
+
+#if (LWM2M_CONFIG_LOG_ENABLED != 0)
+
+static uint8_t op_desc_idx_lookup(uint8_t bitmask)
+{
+ for (uint8_t i = 0; i < 8; i++)
+ {
+ if ((bitmask > i) == 0x1)
+ {
+ return i;
+ }
+ }
+
+ // If no bits where set in the bitmask.
+ return 0;
+}
+
+static const char m_operation_desc[8][9] = {
+ "NONE",
+ "READ",
+ "WRITE",
+ "EXECUTE",
+ "DELETE",
+ "CREATE",
+ "DISCOVER",
+ "OBSERVE"
+};
+
+#endif
+
+SDK_MUTEX_DEFINE(m_lwm2m_mutex) /**< Mutex variable. Currently unused, this declaration does not occupy any space in RAM. */
+
+static lwm2m_object_prototype_t * m_objects[LWM2M_COAP_HANDLER_MAX_OBJECTS];
+static lwm2m_instance_prototype_t * m_instances[LWM2M_COAP_HANDLER_MAX_INSTANCES];
+static uint16_t m_num_objects;
+static uint16_t m_num_instances;
+
+static void coap_error_handler(uint32_t error_code, coap_message_t * p_message)
+{
+ LWM2M_ERR("[CoAP]: Unhandled coap message recieved. Error code: %lu", error_code);
+}
+
+static void internal_coap_handler_init(void)
+{
+ memset(m_objects, 0, sizeof(m_objects));
+ memset(m_instances, 0, sizeof(m_instances));
+
+ m_num_objects = 0;
+ m_num_instances = 0;
+}
+
+
+static bool numbers_only(const char * p_str, uint16_t str_len)
+{
+ for (uint16_t i = 0; i < str_len; i++)
+ {
+ if (isdigit(p_str[i]) == 0)
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+static uint32_t instance_resolve(lwm2m_instance_prototype_t ** p_instance,
+ uint16_t object_id,
+ uint16_t instance_id)
+{
+ for (int i = 0; i < m_num_instances; ++i)
+ {
+ if (m_instances[i]->object_id == object_id &&
+ m_instances[i]->instance_id == instance_id)
+ {
+ if (m_instances[i]->callback == NULL)
+ {
+ return NRF_ERROR_NULL;
+ }
+
+ *p_instance = m_instances[i];
+
+ return NRF_SUCCESS;
+ }
+ }
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+
+static uint32_t object_resolve(lwm2m_object_prototype_t ** p_instance,
+ uint16_t object_id)
+{
+ for (int i = 0; i < m_num_objects; ++i)
+ {
+ if (m_objects[i]->object_id == object_id)
+ {
+ if (m_objects[i]->callback == NULL)
+ {
+ return NRF_ERROR_NULL;
+ }
+
+ *p_instance = m_objects[i];
+
+ return NRF_SUCCESS;
+ }
+ }
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+static uint32_t op_code_resolve(lwm2m_instance_prototype_t * p_instance,
+ uint16_t resource_id,
+ uint8_t * operation)
+{
+ uint8_t * operations = (uint8_t *) p_instance + p_instance->operations_offset;
+ uint16_t * operations_ids = (uint16_t *)((uint8_t *) p_instance +
+ p_instance->resource_ids_offset);
+
+ for (int j = 0; j < p_instance->num_resources; ++j)
+ {
+ if (operations_ids[j] == resource_id)
+ {
+ *operation = operations[j];
+ return NRF_SUCCESS;
+ }
+ }
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+static uint32_t internal_request_handle(coap_message_t * p_request,
+ uint16_t * p_path,
+ uint8_t path_len)
+{
+ uint32_t err_code;
+ uint8_t operation = LWM2M_OPERATION_CODE_NONE;
+ uint32_t content_type = 0;
+
+ err_code = coap_message_ct_mask_get(p_request, &content_type);
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ /**
+ * TODO: the methods should check if we have read / write / execute rights
+ * through ACL and resource operations
+ */
+
+ switch (p_request->header.code)
+ {
+ case COAP_CODE_GET:
+ {
+ LWM2M_TRC("[CoAP]: CoAP GET request");
+ if (content_type == COAP_CT_APP_LINK_FORMAT) // Discover
+ {
+ operation = LWM2M_OPERATION_CODE_DISCOVER;
+ }
+ else // Read
+ {
+ operation = LWM2M_OPERATION_CODE_READ;
+ }
+ break;
+ }
+
+ case COAP_CODE_PUT:
+ {
+ operation = LWM2M_OPERATION_CODE_WRITE;
+ break;
+ }
+
+ case COAP_CODE_POST:
+ {
+ operation = LWM2M_OPERATION_CODE_WRITE;
+ break;
+ }
+
+ case COAP_CODE_DELETE:
+ {
+ operation = LWM2M_OPERATION_CODE_DELETE;
+ break;
+ }
+
+ default:
+ break; // Maybe send response with unsupported method not allowed?
+ }
+
+ err_code = NRF_ERROR_NOT_FOUND;
+
+ switch (path_len)
+ {
+ case 0:
+ {
+ if (operation == LWM2M_OPERATION_CODE_DELETE)
+ {
+ LWM2M_TRC("[CoAP]: >> %s root /",
+ m_operation_desc[op_desc_idx_lookup(operation)]);
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = lwm2m_coap_handler_root(LWM2M_OPERATION_CODE_DELETE, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << %s root /",
+ m_operation_desc[op_desc_idx_lookup(operation)]);
+ }
+ break;
+ }
+
+ case 1:
+ {
+ LWM2M_TRC("[CoAP]: >> %s object /%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0]);
+
+ lwm2m_object_prototype_t * p_object;
+
+ err_code = object_resolve(&p_object, p_path[0]);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ break;
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = p_object->callback(p_object, LWM2M_INVALID_INSTANCE, operation, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << %s object /%u/, result: %s",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ (err_code == NRF_SUCCESS) ? "SUCCESS" : "NOT_FOUND");
+
+ break;
+ }
+
+ case 2:
+ {
+ LWM2M_TRC("[CoAP]: >> %s instance /%u/%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1]);
+
+ lwm2m_instance_prototype_t * p_instance;
+
+ err_code = instance_resolve(&p_instance, p_path[0], p_path[1]);
+ if (err_code == NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = p_instance->callback(p_instance, LWM2M_INVALID_RESOURCE, operation, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << %s instance /%u/%u/, result: %s",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1],
+ (err_code == NRF_SUCCESS) ? "SUCCESS" : "NOT_FOUND");
+ break;
+ }
+
+ // Bootstrap can write to non-existing instances
+ if (err_code == NRF_ERROR_NOT_FOUND &&
+ operation == LWM2M_OPERATION_CODE_WRITE &&
+ p_request->header.code == COAP_CODE_PUT)
+ {
+ LWM2M_TRC("[CoAP]: >> %s object /%u/%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1]);
+
+ lwm2m_object_prototype_t * p_object;
+
+ err_code = object_resolve(&p_object, p_path[0]);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ break;
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = p_object->callback(p_object, p_path[1], operation, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << %s object /%u/%u/, result: %s",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1],
+ (err_code == NRF_SUCCESS) ? "SUCCESS" : "NOT_FOUND");
+ }
+
+ if (err_code == NRF_ERROR_NOT_FOUND &&
+ operation == LWM2M_OPERATION_CODE_WRITE &&
+ p_request->header.code == COAP_CODE_POST)
+ {
+ LWM2M_TRC("[CoAP]: >> CREATE object /%u/%u/",
+ p_path[0],
+ p_path[1]);
+
+ lwm2m_object_prototype_t * p_object;
+
+ err_code = object_resolve(&p_object, p_path[0]);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ break;
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = p_object->callback(p_object, p_path[1], LWM2M_OPERATION_CODE_CREATE, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << CREATE object /%u/%u/, result: %s",
+ p_path[0],
+ p_path[1],
+ (err_code == NRF_SUCCESS) ? "SUCCESS" : "NOT_FOUND");
+ break;
+ }
+
+ break;
+ }
+
+ case 3:
+ {
+ if (operation == LWM2M_OPERATION_CODE_DELETE)
+ {
+ // Deleting resources within an instance not allowed.
+ break;
+ }
+
+ if (p_request->header.code == COAP_CODE_POST)
+ {
+ for (int i = 0; i < m_num_instances; ++i)
+ {
+ if ((m_instances[i]->object_id == p_path[0]) &&
+ (m_instances[i]->instance_id == p_path[1]))
+ {
+ if (m_instances[i]->callback == NULL)
+ {
+ err_code = NRF_ERROR_NULL;
+ break;
+ }
+
+ uint8_t resource_operation = 0;
+ err_code = op_code_resolve(m_instances[i], p_path[2], &resource_operation);
+
+ if (err_code != NRF_SUCCESS)
+ break;
+
+ if ((resource_operation & LWM2M_OPERATION_CODE_EXECUTE) > 0)
+ {
+ operation = LWM2M_OPERATION_CODE_EXECUTE;
+ }
+
+ if ((resource_operation & LWM2M_OPERATION_CODE_WRITE) > 0)
+ {
+ operation = LWM2M_OPERATION_CODE_WRITE;
+ }
+
+ LWM2M_TRC("[CoAP]: >> %s instance /%u/%u/%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ m_instances[i]->object_id,
+ m_instances[i]->instance_id,
+ p_path[2]);
+
+ LWM2M_MUTEX_UNLOCK();
+
+ (void)m_instances[i]->callback(m_instances[i],
+ p_path[2],
+ operation,
+ p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ err_code = NRF_SUCCESS;
+
+ LWM2M_TRC("[CoAP]: << %s instance /%u/%u/%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ m_instances[i]->object_id,
+ m_instances[i]->instance_id,
+ p_path[2]);
+
+ break;
+ }
+ }
+ }
+ else
+ {
+ LWM2M_TRC("[CoAP]: >> %s instance /%u/%u/%u/",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1],
+ p_path[2]);
+
+ lwm2m_instance_prototype_t * p_instance;
+
+ err_code = instance_resolve(&p_instance, p_path[0], p_path[1]);
+ if (err_code != NRF_SUCCESS)
+ {
+ break;
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = p_instance->callback(p_instance, p_path[2], operation, p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ LWM2M_TRC("[CoAP]: << %s instance /%u/%u/%u/, result: %s",
+ m_operation_desc[op_desc_idx_lookup(operation)],
+ p_path[0],
+ p_path[1],
+ p_path[2],
+ (err_code == NRF_SUCCESS) ? "SUCCESS" : "NOT_FOUND");
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return err_code;
+}
+
+
+static uint32_t lwm2m_coap_handler_handle_request(coap_message_t * p_request)
+{
+ LWM2M_ENTRY();
+
+ uint16_t index;
+ uint16_t path[3];
+ char * endptr;
+
+ bool is_numbers_only = true;
+ uint16_t path_index = 0;
+ uint32_t err_code = NRF_SUCCESS;
+
+ LWM2M_MUTEX_LOCK();
+
+ for (index = 0; index < p_request->options_count; index++)
+ {
+ if (p_request->options[index].number == COAP_OPT_URI_PATH)
+ {
+ uint16_t option_len = p_request->options[index].length;
+ bool numbers = numbers_only((char *)p_request->options[index].p_data,
+ option_len);
+
+ if (numbers)
+ {
+ // Declare a temporary array that is 1 byte longer than the
+ // option data in order to leave space for a terminating character.
+ uint8_t option_data[option_len + 1];
+ // Set the temporary array to zero.
+ memset(option_data, 0, sizeof(option_data));
+ // Copy the option data string to the temporary array.
+ memcpy(option_data, p_request->options[index].p_data, option_len);
+
+ // Convert the zero-terminated string to a long int value.
+ path[path_index] = strtol((char *)option_data, &endptr, 10);
+
+ ++path_index;
+
+ if (endptr == ((char *)option_data))
+ {
+ err_code = NRF_ERROR_NOT_FOUND;
+ break;
+ }
+
+ if (endptr != ((char *)option_data + option_len))
+ {
+ err_code = NRF_ERROR_NOT_FOUND;
+ break;
+ }
+ }
+ else
+ {
+ is_numbers_only = false;
+ break;
+ }
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ if (is_numbers_only == true)
+ {
+ err_code = internal_request_handle(p_request, path, path_index);
+ }
+ else
+ {
+ // If uri path did not consist of numbers only.
+ char * requested_uri = NULL;
+ for (index = 0; index < p_request->options_count; index++)
+ {
+ if (p_request->options[index].number == COAP_OPT_URI_PATH)
+ {
+ requested_uri = (char *)p_request->options[index].p_data;
+
+ // Stop on first URI hit.
+ break;
+ }
+ }
+
+ if (requested_uri == NULL)
+ {
+ err_code = NRF_ERROR_NOT_FOUND;
+ }
+ else
+ {
+ // Try to look up if there is a match with object with an alias name.
+ for (int i = 0; i < m_num_objects; ++i)
+ {
+ if (m_objects[i]->object_id == LWM2M_NAMED_OBJECT)
+ {
+ size_t size = strlen(m_objects[i]->p_alias_name);
+ if ((strncmp(m_objects[i]->p_alias_name, requested_uri, size) == 0))
+ {
+ if (m_objects[i]->callback == NULL)
+ {
+ err_code = NRF_ERROR_NULL;
+ break;
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ err_code = m_objects[i]->callback(m_objects[i],
+ LWM2M_INVALID_INSTANCE,
+ LWM2M_OPERATION_CODE_NONE,
+ p_request);
+
+ LWM2M_MUTEX_LOCK();
+
+ break;
+ }
+ }
+ else
+ {
+ // This is not a name object, return error code.
+ err_code = NRF_ERROR_NOT_FOUND;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ LWM2M_EXIT();
+
+ return err_code;
+}
+
+
+uint32_t lwm2m_coap_handler_instance_add(lwm2m_instance_prototype_t * p_instance)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_instance);
+
+ LWM2M_MUTEX_LOCK();
+
+ if (m_num_instances == LWM2M_COAP_HANDLER_MAX_INSTANCES)
+ {
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_ERROR_NO_MEM;
+ }
+
+ m_instances[m_num_instances] = p_instance;
+ ++m_num_instances;
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_coap_handler_instance_delete(lwm2m_instance_prototype_t * p_instance)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_instance);
+
+ LWM2M_MUTEX_LOCK();
+
+ for (int i = 0; i < m_num_instances; ++i)
+ {
+ if ((m_instances[i]->object_id == p_instance->object_id) &&
+ (m_instances[i]->instance_id == p_instance->instance_id))
+ {
+ // Move current last entry into this index position, and trim down the length.
+ // If this is the last element, it cannot be accessed because the m_num_instances
+ // count is 0.
+ m_instances[i] = m_instances[m_num_instances - 1];
+ --m_num_instances;
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_SUCCESS;
+ }
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+
+uint32_t lwm2m_coap_handler_object_add(lwm2m_object_prototype_t * p_object)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_object);
+
+ LWM2M_MUTEX_LOCK();
+
+ if (m_num_objects == LWM2M_COAP_HANDLER_MAX_INSTANCES)
+ {
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_ERROR_NO_MEM;
+ }
+
+ m_objects[m_num_objects] = p_object;
+ ++m_num_objects;
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_coap_handler_object_delete(lwm2m_object_prototype_t * p_object)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_object);
+
+ LWM2M_MUTEX_LOCK();
+
+ for (int i = 0; i < m_num_objects; ++i)
+ {
+ if ( m_objects[i]->object_id == p_object->object_id)
+ {
+ // Move current last entry into this index position, and trim down the length.
+ // If this is the last element, it cannot be accessed because the m_num_objects
+ // count is 0.
+ m_objects[i] = m_objects[m_num_objects - 1];
+ --m_num_objects;
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_SUCCESS;
+ }
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+
+uint32_t lwm2m_coap_handler_gen_link_format(uint8_t * p_buffer, uint16_t * p_buffer_len)
+{
+
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_buffer_len);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint16_t buffer_index = 0;
+ uint8_t * p_string_buffer;
+ uint16_t buffer_max_size;
+
+ uint8_t dry_run_buffer[16];
+ bool dry_run = false;
+ uint16_t dry_run_size = 0;
+
+ if (p_buffer == NULL)
+ {
+ // Dry-run only, in order to calculate the size of the needed buffer.
+ dry_run = true;
+ p_string_buffer = dry_run_buffer;
+ buffer_max_size = sizeof(dry_run_buffer);
+ }
+ else
+ {
+ p_string_buffer = p_buffer;
+ buffer_max_size = *p_buffer_len;
+ }
+
+ for (int i = 0; i < m_num_objects; ++i)
+ {
+ // We need more than 3 chars to write a new link
+ if (buffer_max_size - buffer_index <= 3)
+ {
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_ERROR_NO_MEM;
+ }
+
+ uint16_t curr_object = m_objects[i]->object_id;
+
+ if (curr_object == LWM2M_NAMED_OBJECT)
+ {
+ // Skip this object as it is a named object.
+ continue;
+ }
+
+ bool instance_present = false;
+ for (int j = 0; j < m_num_instances; ++j)
+ {
+ if (m_instances[j]->object_id == curr_object)
+ {
+ instance_present = true;
+
+ buffer_index += snprintf((char *)&p_string_buffer[buffer_index],
+ buffer_max_size - buffer_index,
+ "</%u/%u>,",
+ m_instances[j]->object_id,
+ m_instances[j]->instance_id);
+ if (dry_run == true)
+ {
+ dry_run_size += buffer_index;
+ buffer_index = 0;
+ }
+ }
+ }
+
+ if (!instance_present)
+ {
+ buffer_index += snprintf((char *)&p_string_buffer[buffer_index],
+ buffer_max_size - buffer_index,
+ "</%u>,",
+ curr_object);
+ if (dry_run == true)
+ {
+ dry_run_size += buffer_index;
+ buffer_index = 0;
+ }
+ }
+ }
+
+ if (dry_run == true)
+ {
+ *p_buffer_len = dry_run_size - 1;
+ }
+ else
+ {
+ *p_buffer_len = buffer_index - 1; // Remove the last comma
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_init(void)
+{
+ SDK_MUTEX_INIT(m_lwm2m_mutex);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint32_t err_code;
+
+ err_code = internal_lwm2m_register_init();
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ err_code = internal_lwm2m_bootstrap_init();
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ err_code = coap_error_handler_register(coap_error_handler);
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ internal_coap_handler_init();
+
+ err_code = coap_request_handler_register(lwm2m_coap_handler_handle_request);
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return err_code;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.h
new file mode 100644
index 0000000..fe03b4d
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m.h
@@ -0,0 +1,109 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/** @file lwm2m.h
+ *
+ * @defgroup iot_sdk_lwm2m_api LWM2M library private definitions.
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief LWM2M library private definitions.
+ */
+
+#ifndef LWM2M_H__
+#define LWM2M_H__
+
+#include "stdint.h"
+#include "stdbool.h"
+#include "coap_message.h"
+#include "coap_codes.h"
+#include "sdk_config.h"
+#include "sdk_os.h"
+#include "iot_errors.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup iot_coap_mutex_lock_unlock Module's Mutex Lock/Unlock Macros.
+ *
+ * @details Macros used to lock and unlock modules. Currently, SDK does not use mutexes but
+ * framework is provided in case the need to use an alternative architecture arises.
+ * @{
+ */
+#define LWM2M_MUTEX_LOCK() SDK_MUTEX_LOCK(m_lwm2m_mutex) /**< Lock module using mutex */
+#define LWM2M_MUTEX_UNLOCK() SDK_MUTEX_UNLOCK(m_lwm2m_mutex) /**< Unlock module using mutex */
+
+/** @} */
+
+/**
+ * @defgroup api_param_check API Parameters check macros.
+ *
+ * @details Macros that verify parameters passed to the module in the APIs. These macros
+ * could be mapped to nothing in final versions of code to save execution and size.
+ * LWM2M_DISABLE_API_PARAM_CHECK should be set to 0 to enable these checks.
+ *
+ * @{
+ */
+#if (LWM2M_DISABLE_API_PARAM_CHECK == 0)
+
+/**@brief Verify NULL parameters are not passed to API by application. */
+#define NULL_PARAM_CHECK(PARAM) \
+ if ((PARAM) == NULL) \
+ { \
+ return (NRF_ERROR_NULL | IOT_LWM2M_ERR_BASE); \
+ }
+#else
+
+#define NULL_PARAM_CHECK(PARAM)
+
+#endif // LWM2M_DISABLE_API_PARAM_CHECK
+
+#define LWM2M_REQUEST_TYPE_BOOTSTRAP 1
+#define LWM2M_REQUEST_TYPE_REGISTER 2
+#define LWM2M_REQUEST_TYPE_UPDATE 3
+#define LWM2M_REQUEST_TYPE_DEREGISTER 4
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_api.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_api.h
new file mode 100644
index 0000000..444c3e5
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_api.h
@@ -0,0 +1,426 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/** @file lwm2m_api.h
+*
+* @defgroup iot_sdk_lwm2m_api LWM2M Application Programming Interface
+* @ingroup iot_sdk_lwm2m
+* @{
+* @brief Public API of Nordic's LWM2M implementation.
+*/
+#ifndef LWM2M_API_H__
+#define LWM2M_API_H__
+
+#include <stdint.h>
+
+#include "lwm2m.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@addtogroup LWM2M_opcodes Types
+ * @{
+ * @brief LWMW2M Bootstrap type definitions.
+ */
+
+/**@brief LWM2M remote structure type. */
+typedef coap_remote_t lwm2m_remote_t;
+
+/**@brief LWM2M time type. */
+typedef uint32_t lwm2m_time_t;
+
+/**@brief LWM2M string type. */
+typedef struct
+{
+ char * p_val; /**< Pointer to the value of the string data. */
+ uint32_t len; /**< Length of p_val. */
+} lwm2m_string_t;
+
+/**@brief LWM2M opaque type. */
+typedef struct
+{
+ uint8_t * p_val; /**< Pointer to the value of the opaque data. */
+ uint32_t len; /**< Length of p_val. */
+} lwm2m_opaque_t;
+
+/**@brief Application notification callback types. */
+typedef enum
+{
+ LWM2M_NOTIFCATION_TYPE_BOOTSTRAP, /**< Notification from a bootstrap request. */
+ LWM2M_NOTIFCATION_TYPE_REGISTER, /**< Notification from a register request. */
+ LWM2M_NOTIFCATION_TYPE_UPDATE, /**< Notification from a update request. */
+ LWM2M_NOTIFCATION_TYPE_DEREGISTER /**< Notification from a deregister request. */
+} lwm2m_notification_type_t;
+
+/**@brief LWM2M server configuration type. */
+typedef struct
+{
+ uint32_t lifetime; /** Lifetime parameter **/
+ uint64_t msisdn; /** SMS number MSISDN **/
+ uint8_t lwm2m_version_major; /** LWM2M major version number **/
+ uint8_t lwm2m_version_minor; /** LWM2M miner version number **/
+ lwm2m_string_t binding;
+} lwm2m_server_config_t;
+
+/**@brief LWM2M client identity types. */
+typedef enum
+{
+ LWM2M_CLIENT_ID_TYPE_UUID = 36,
+ LWM2M_CLIENT_ID_TYPE_IMEI = 15,
+ LWM2M_CLIENT_ID_TYPE_ESN = 8,
+ LWM2M_CLIENT_ID_TYPE_MEID = 14
+} lwm2m_client_identity_type_t;
+
+/**@brief LWM2M identity string.
+ *
+ * @details Using the string representation of UUID/OPS/OS/IMEI/ESN/MEID.
+ *
+ * @note: OPS- and OS URN are not currently supported.
+ */
+typedef union
+{
+ char uuid[36];
+ char imei[15];
+ char esn[8];
+ char meid[14];
+} lwm2m_identity_string_t;
+
+/**@brief LWM2M client identity structure type. */
+typedef struct
+{
+ lwm2m_identity_string_t value;
+ lwm2m_client_identity_type_t type;
+} lwm2m_client_identity_t;
+/**@} */
+
+/**@addtogroup LWM2M_defines Defines
+ * @{
+ * @brief LWMW2M operation code and invalid object/instance definitions.
+ */
+
+/**
+ * @warning The invalid resource and instance are not stated by the lwm2m spec as reserved and will
+ * cause issues if instances or resources with these IDs is added.
+ */
+#define LWM2M_NAMED_OBJECT 65535 /**< Flag to indicate that the object does not use Integer as object id. */
+#define LWM2M_INVALID_RESOURCE 65535 /**< Invalid Resource ID. */
+#define LWM2M_INVALID_INSTANCE 65535 /**< Invalid Instance ID. */
+
+#define LWM2M_OPERATION_CODE_NONE 0x00 /**< Bit mask for LWM2M no operation. */
+#define LWM2M_OPERATION_CODE_READ 0x01 /**< Bit mask for LWM2M read operation. */
+#define LWM2M_OPERATION_CODE_WRITE 0x02 /**< Bit mask for LWM2M write operation. */
+#define LWM2M_OPERATION_CODE_EXECUTE 0x04 /**< Bit mask for LWM2M execute operation. */
+#define LWM2M_OPERATION_CODE_DELETE 0x08 /**< Bit mask for LWM2M delete operation. */
+#define LWM2M_OPERATION_CODE_CREATE 0x10 /**< Bit mask for LWM2M create operation. */
+#define LWM2M_OPERATION_CODE_DISCOVER 0x20 /**< Bit mask for LWM2M discover operation. */
+#define LWM2M_OPERATION_CODE_OBSERVE 0x40 /**< Bit mask for LWM2M observe operation. */
+/**@} */
+
+/**@cond */
+// Forward declare structs.
+typedef struct lwm2m_object_prototype_t lwm2m_object_prototype_t;
+typedef struct lwm2m_instance_prototype_t lwm2m_instance_prototype_t;
+/**@endcond */
+
+/**@brief Callback function upon requests on a given LWM2M resource instance.
+ *
+ * @details Will be called when the request is for an instance Ex. /0/1.
+ *
+ * If no instance could be located the object callback will be called.
+ * The instance_id corresponds to the one in the URI-patch in the CoAP request and may be used to
+ * create a new instance. If the value of resource_id is set to LWM2M_INVALID_RESOURCE the callback
+ * should treated it as a call to the instance instead of a resource inside of the instance.
+ *
+ * If a resource has been found p_instance pointer will be set, else it will be NULL.
+ *
+ * @param[in] p_instance Pointer to the located resource if it already exists.
+ * @param[in] resource_id Id of the resource requested.
+ * @param[in] op_code Opcode of the request. Values of the opcodes are defined
+ * in \ref LWM2M_opcodes.
+ * @param[in] p_request Pointer to the CoAP request message.
+ *
+ * @retval NRF_SUCCESS Will always return success.
+ */
+typedef uint32_t (*lwm2m_instance_callback_t)(lwm2m_instance_prototype_t * p_instance,
+ uint16_t resource_id,
+ uint8_t op_code,
+ coap_message_t * p_request);
+
+/**@brief Callback function upon request on a given LWM2M object or instance create.
+ *
+ * @details Will be called when the request is for an object Ex: /0 or /0/1 an instance and the
+ * op_code is CREATE. Depending on the CoAP request code the user might create an instance
+ * or just return the tlv of current instances. If the value of instance_id is set to
+ * LWM2M_INVALID_INSTANCE the callback should treated it as a call to the instance instead
+ * of an instance of the object.
+ *
+ * @param[in] p_object Pointer to the located object.
+ * @param[in] instance_id Id of the instance requested.
+ * @param[in] op_code Opcode of the request. Values of the opcodes are defined
+ * in \ref LWM2M_opcodes.
+ * @param[in] p_request Pointer to the CoAP request message.
+ *
+ * @retval NRF_SUCCESS Will always return success.
+ */
+typedef uint32_t (*lwm2m_object_callback_t)(lwm2m_object_prototype_t * p_object,
+ uint16_t instance_id,
+ uint8_t op_code,
+ coap_message_t * p_request);
+
+/**@brief LWM2M object prototype structure.
+ *
+ * @details Each instance will have this structure in the front of its instance structure.
+ * The object is used to have a common way of looking up its object id and callback
+ * structure for each of the inherited. As there is no instance of the objects themselves,
+ * the prototype is used as a meta object in order to have a common set of functions
+ * for all instances of a object kind.
+ */
+struct lwm2m_object_prototype_t
+{
+ uint16_t object_id; /**< Identifies the object. */
+ lwm2m_object_callback_t callback; /**< Called when for request to /0 (object) and /0/1 if instance 1 is not found. */
+ char * p_alias_name; /**< Alternative name of the resource, used when LWM2M_NAMED_OBJECT is set. */
+};
+
+/**@brief LWM2M instance structure.
+ *
+ * @details Prototype for the instance object, this enables us to search through the instances
+ * without knowing the type.
+ */
+struct lwm2m_instance_prototype_t
+{
+ uint16_t object_id; /**< Identifies what object this instance belongs to. */
+ uint16_t instance_id; /**< Used to identify the instance. */
+ uint16_t num_resources; /**< Number of resources MUST equal number of members in the lwm2m instance, sizeof resource_access and sizeof resource_ids. */
+ uint8_t operations_offset; /**< Internal use. */
+ uint8_t resource_ids_offset; /**< Internal use. */
+ lwm2m_instance_callback_t callback; /**< Called when an operation is done on this instance. */
+};
+
+/**@brief Callback interface from the enabler interface (bootstrap/register) to the application.
+ *
+ * @warning This is an interface function. MUST BE IMPLEMENTED BY APPLICATION.
+ *
+ * @param[in] type Notification type. The types are defined in \ref lwm2m_notification_type_t.
+ * @param[in] p_remote remote that answered the request
+ * @param[in] coap_code coap op code from the response
+ *
+ * @retval NRF_SUCCESS If the client application handled the notification successfully.
+ */
+uint32_t lwm2m_notification(lwm2m_notification_type_t type,
+ lwm2m_remote_t * p_remote,
+ uint8_t coap_code);
+
+/**@brief CoAP Request handler for the root of the object/instance/resource hierarchy.
+ *
+ * @details The function is called when a request is for the lwm2m root (ie no object instance
+ * or resource).
+ *
+ * @warning This is an interface function. MUST BE IMPLEMENTED BY APPLICATION.
+ *
+ * @param[in] op_code LWM2M operation code.
+ * @param[in] p_request Pointer to CoAP request message.
+ *
+ * @retval NRF_SUCCESS If the handler processed the request successfully.
+ */
+uint32_t lwm2m_coap_handler_root(uint8_t op_code, coap_message_t * p_request);
+
+/**@brief Initialize LWM2M library.
+ *
+ * @retval NRF_SUCCESS If initialization was successful.
+ */
+uint32_t lwm2m_init(void);
+
+/**@brief Send bootstrap request to a remote bootstrap server.
+ *
+ * @details Sends a bootstrap request with specified ID to the specified remote, calls the
+ * lwm2m_notification with answer from the bootstrap server.
+ *
+ * @param[in] p_remote Pointer to the structure holding connection information of the remote
+ * LWM2M bootstrap server.
+ * @param[in] p_id Pointer to the structure holding the Id of the client.
+ * @param[in] local_port Port number of the local port to be used to send the bootstrap request.
+ *
+ * @retval NRF_SUCCESS If bootstrap request to the LWM2M bootstrap server was sent successfully.
+ * @retval NRF_ERROR_NULL If one of the parameters was a NULL pointer.
+ */
+uint32_t lwm2m_bootstrap(lwm2m_remote_t * p_remote,
+ lwm2m_client_identity_t * p_id,
+ uint16_t local_port);
+
+/**@brief Register with a remote LWM2M server.
+ *
+ * @param[in] p_remote Pointer to the structure holding connection information
+ * of the remote LWM2M server.
+ * @param[in] p_id Pointer to the structure holding the Id of the client.
+ * @param[in] p_config Registration parameters.
+ * @param[in] local_port Port number of the local port to be used to send the
+ * register request.
+ * @param[in] p_link_format_string Pointer to a link format encoded string to send in the
+ * register request.
+ * @param[in] link_format_len Length of the link format string provided.
+ *
+ * @retval NRF_SUCCESS If registration request to the LWM2M server was sent out successfully.
+ */
+uint32_t lwm2m_register(lwm2m_remote_t * p_remote,
+ lwm2m_client_identity_t * p_id ,
+ lwm2m_server_config_t * p_config,
+ uint16_t local_port,
+ uint8_t * p_link_format_string,
+ uint16_t link_format_len);
+
+/**@brief Update a registration with a remote server.
+ *
+ * @param[in] p_remote Pointer to the structure holding connection information of the remote
+ * LWM2M server.
+ * @param[in] p_config Registration parameters.
+ * @param[in] local_port Port number of the local port to be used to send the update request.
+ *
+ * @retval NRF_SUCCESS If update request to the LWM2M server was sent out successfully.
+ */
+uint32_t lwm2m_update(lwm2m_remote_t * p_remote,
+ lwm2m_server_config_t * p_config,
+ uint16_t local_port);
+
+/**@brief Deregister from a remote server.
+ *
+ * @param[in] p_remote Pointer to the structure holding connection information of the remote
+ * LWM2M server.
+ * @param[in] local_port Port number of the local port to be used to send the deregister request.
+ *
+ * @retval NRF_SUCCESS If deregister request to the LWM2M server was sent out successfully.
+ */
+uint32_t lwm2m_deregister(lwm2m_remote_t * p_remote, uint16_t local_port);
+
+/**@brief Add an instance to coap_handler in order to match requests to the given instance.
+ *
+ * @details Add a new LWM2M instance to the coap_handler. The application MUST initialize
+ * and allocate the additional data in the struct.
+ *
+ * @param[in] p_instance Pointer to the instance to add.
+ *
+ * @retval NRF_SUCCESS If registration was successful.
+ * @retval NRF_ERROR_NO_MEM If the module was not able to add the instance. Verify that
+ * the LWM2M_COAP_HANDLER_MAX_INSTANCES setting in sdk_config.h
+ * has a correct value.
+ */
+uint32_t lwm2m_coap_handler_instance_add(lwm2m_instance_prototype_t * p_instance);
+
+/**@brief Delete an instance from coap_handler in order to stop matching requests to the given
+ * instance.
+ *
+ * @param[in] p_instance Pointer to the instance to delete.
+ *
+ * @retval NRF_SUCCESS If unregistration was a success.
+ * @retval NRF_ERROR_NOT_FOUND If the given instance was not located.
+ */
+uint32_t lwm2m_coap_handler_instance_delete(lwm2m_instance_prototype_t * p_instance);
+
+/**@brief Add an object to coap_handler in order to match requests to the given object.
+ *
+ * @details Add a new LWM2M object to the coap_handler. The application MUST initialize
+ * and allocate the additional data in the struct.
+ *
+ * @param[in] p_object Pointer to the object to add.
+ *
+ * @retval NRF_SUCCESS If registration was successful.
+ * @retval NRF_ERROR_NO_MEM If the module was not able to add the object. Verify that
+ * the LWM2M_COAP_HANDLER_MAX_OBJECTS setting in sdk_config.h
+ * has a correct value.
+ */
+uint32_t lwm2m_coap_handler_object_add(lwm2m_object_prototype_t * p_object);
+
+/**@brief Delete an object from coap_handler in order to stop matching requests to the given
+ * object.
+ *
+ * @param[in] p_object Pointer to the object to delete.
+ *
+ * @retval NRF_SUCCESS If unregistration was a success.
+ * @retval NRF_ERROR_NOT_FOUND If the given object was not located.
+ */
+uint32_t lwm2m_coap_handler_object_delete(lwm2m_object_prototype_t * p_object);
+
+/**@brief Generate link format string based on registered objects and instances.
+ *
+ * @note For generation of links to work properly it is required that objects is added
+ * before instances.
+ *
+ * @param[inout] p_buffer Pointer to a buffer to fill with link format encoded string. If
+ * a NULL pointer is provided the function will dry-run the function
+ * in order to calculate how much memory that is needed for the link
+ * format string.
+ * @param[inout] p_buffer_len As input used to indicate the length of the buffer. It will return the
+ * used amount of buffer length by reference in response. If NULL pointer
+ * is provided for p_buffer, the value by reference output will be the number
+ * of bytes needed to generate the link format string.
+ *
+ * @retval NRF_SUCCESS If generation of link format string was successful.
+ * @retval NRF_ERROR_NO_MEM If the provided memory was not large enough.
+ */
+uint32_t lwm2m_coap_handler_gen_link_format(uint8_t * p_buffer, uint16_t * p_buffer_len);
+
+/**@brief Send CoAP 2.05 Content response with the payload provided.
+ *
+ * @param[in] p_payload Pointer to the payload to send. Must not be NULL.
+ * @param[in] payload_len Size of the payload.
+ * @param[in] p_request Original CoAP request. Must not be NULL.
+ *
+ * @retval NRF_SUCCESS If the response was sent out successfully.
+ */
+uint32_t lwm2m_respond_with_payload(uint8_t * p_payload,
+ uint16_t payload_len,
+ coap_message_t * p_request);
+
+/**@brief Send CoAP response with a given CoAP message code.
+ *
+ * @param [in] code CoAP response code to send.
+ * @param [in] p_request Original CoAP request. Must not be NULL.
+ *
+ * @retval NRF_SUCCESS If the response was sent out successfully.
+ */
+uint32_t lwm2m_respond_with_code(coap_msg_code_t code, coap_message_t * p_request);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_API_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.c
new file mode 100644
index 0000000..7724e10
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.c
@@ -0,0 +1,203 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+#include "lwm2m_api.h"
+#include "lwm2m_bootstrap.h"
+#include "lwm2m.h"
+#include "coap_api.h"
+#include "coap_message.h"
+#include "coap_codes.h"
+#include "sdk_config.h"
+#include "app_util.h"
+
+#if LWM2M_CONFIG_LOG_ENABLED
+
+#define NRF_LOG_MODULE_NAME lwm2m
+
+#define NRF_LOG_LEVEL LWM2M_CONFIG_LOG_LEVEL
+#define NRF_LOG_INFO_COLOR LWM2M_CONFIG_INFO_COLOR
+#define NRF_LOG_DEBUG_COLOR LWM2M_CONFIG_DEBUG_COLOR
+
+#include "nrf_log.h"
+
+#define LWM2M_TRC NRF_LOG_DEBUG /**< Used for getting trace of execution in the module. */
+#define LWM2M_ERR NRF_LOG_ERROR /**< Used for logging errors in the module. */
+#define LWM2M_DUMP NRF_LOG_HEXDUMP_DEBUG /**< Used for dumping octet information to get details of bond information etc. */
+
+#define LWM2M_ENTRY() LWM2M_TRC(">> %s", __func__)
+#define LWM2M_EXIT() LWM2M_TRC("<< %s", __func__)
+
+#else // LWM2M_CONFIG_LOG_ENABLED
+
+#define LWM2M_TRC(...) /**< Disables traces. */
+#define LWM2M_DUMP(...) /**< Disables dumping of octet streams. */
+#define LWM2M_ERR(...) /**< Disables error logs. */
+
+#define LWM2M_ENTRY(...)
+#define LWM2M_EXIT(...)
+
+#endif // LWM2M_CONFIG_LOG_ENABLED
+
+#define LWM2M_BOOTSTRAP_URI_PATH "bs"
+
+#define TOKEN_START 0x012A
+
+static uint16_t m_token = TOKEN_START;
+
+static uint32_t internal_message_new(coap_message_t ** pp_msg,
+ coap_msg_code_t code,
+ coap_response_callback_t callback,
+ uint16_t local_port)
+{
+ uint32_t err_code;
+ coap_message_conf_t conf;
+ memset (&conf, 0, sizeof(coap_message_conf_t));
+
+ conf.type = COAP_TYPE_CON;
+ conf.code = code;
+ conf.response_callback = callback;
+ conf.port.port_number = local_port;
+
+ conf.token_len = uint16_encode(m_token, conf.token);
+
+ m_token++;
+
+ err_code = coap_message_new(pp_msg, &conf);
+
+ return err_code;
+}
+
+
+/**@brief Function to be used as callback function upon a bootstrap request. */
+static void lwm2m_bootstrap_cb(uint32_t status, void * p_arg, coap_message_t * p_message)
+{
+ LWM2M_TRC("[Bootstrap]: lwm2m_bootstrap_cb, status: %ul, coap code: %u",
+ status,
+ p_message->header.code);
+
+ (void)lwm2m_notification(LWM2M_NOTIFCATION_TYPE_BOOTSTRAP,
+ &p_message->remote,
+ p_message->header.code);
+}
+
+
+uint32_t internal_lwm2m_bootstrap_init(void)
+{
+ m_token = TOKEN_START;
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_bootstrap(lwm2m_remote_t * p_remote, lwm2m_client_identity_t * p_id, uint16_t local_port)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_remote);
+ NULL_PARAM_CHECK(p_id);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint32_t err_code;
+ coap_message_t * p_msg;
+
+ lwm2m_string_t endpoint;
+
+ endpoint.p_val = LWM2M_BOOTSTRAP_URI_PATH;
+ endpoint.len = 2;
+
+ err_code = internal_message_new(&p_msg, COAP_CODE_POST, lwm2m_bootstrap_cb, local_port);
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_remote_addr_set(p_msg, p_remote);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_PATH,
+ (uint8_t *)endpoint.p_val,
+ endpoint.len); // end_point length is always 2
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ char buffer[40];
+ buffer[0] = 'e';
+ buffer[1] = 'p';
+ buffer[2] = '=';
+ memcpy(buffer + 3, &p_id->value, p_id->type);
+
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ p_id->type + 3);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_msg);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_delete(p_msg);
+ }
+ else
+ {
+ // If we have hit an error try to clean up.
+ // Return the original error code.
+ (void)coap_message_delete(p_msg);
+ }
+
+ LWM2M_EXIT();
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return err_code;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.h
new file mode 100644
index 0000000..68bdf6b
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_bootstrap.h
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/** @file lwm2m_bootstrap.h
+ *
+ * @defgroup iot_sdk_lwm2m_bootstrap_api LWM2M bootstrap API interface
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief Bootstrap API interface for the LWM2M protocol.
+ */
+
+#ifndef LWM2M_BOOTSTRAP_H__
+#define LWM2M_BOOTSTRAP_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Initialize the LWM2M register module.
+ *
+ * @details Calling this function will set the module in default state.
+ */
+uint32_t internal_lwm2m_bootstrap_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_BOOTSTRAP_H__
+
+/**@} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_coap_util.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_coap_util.c
new file mode 100644
index 0000000..bf7bece
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_coap_util.c
@@ -0,0 +1,166 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include "coap_api.h"
+#include "coap_message.h"
+#include "coap_codes.h"
+#include "lwm2m.h"
+
+
+uint32_t lwm2m_respond_with_code(coap_msg_code_t code, coap_message_t * p_request)
+{
+ NULL_PARAM_CHECK(p_request);
+
+ // Application helper function, no need for mutex.
+ coap_message_conf_t response_config;
+ memset (&response_config, 0, sizeof(coap_message_conf_t));
+
+ if (p_request->header.type == COAP_TYPE_NON)
+ {
+ response_config.type = COAP_TYPE_NON;
+ }
+ else if (p_request->header.type == COAP_TYPE_CON)
+ {
+ response_config.type = COAP_TYPE_ACK;
+ }
+
+ // PIGGY BACKED RESPONSE
+ response_config.code = code;
+ response_config.id = p_request->header.id;
+ response_config.port.port_number = p_request->port.port_number;
+
+ // Copy token.
+ memcpy(&response_config.token[0], &p_request->token[0], p_request->header.token_len);
+ // Copy token length.
+ response_config.token_len = p_request->header.token_len;
+
+ coap_message_t * p_response;
+ uint32_t err_code = coap_message_new(&p_response, &response_config);
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ err_code = coap_message_remote_addr_set(p_response, &p_request->remote);
+ if (err_code != NRF_SUCCESS)
+ {
+ (void)coap_message_delete(p_response);
+ return err_code;
+ }
+
+ memcpy(&p_response->remote, &p_request->remote, sizeof(coap_remote_t));
+
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_response);
+ if (err_code != NRF_SUCCESS)
+ {
+ (void)coap_message_delete(p_response);
+ return err_code;
+ }
+
+ err_code = coap_message_delete(p_response);
+
+ return err_code;
+}
+
+
+uint32_t lwm2m_respond_with_payload(uint8_t * p_payload, uint16_t payload_len, coap_message_t * p_request)
+{
+ NULL_PARAM_CHECK(p_request);
+ NULL_PARAM_CHECK(p_payload);
+
+ // Application helper function, no need for mutex.
+ coap_message_conf_t response_config;
+ memset (&response_config, 0, sizeof(coap_message_conf_t));
+
+ if (p_request->header.type == COAP_TYPE_NON)
+ {
+ response_config.type = COAP_TYPE_NON;
+ }
+ else if (p_request->header.type == COAP_TYPE_CON)
+ {
+ response_config.type = COAP_TYPE_ACK;
+ }
+
+ // PIGGY BACKED RESPONSE
+ response_config.code = COAP_CODE_205_CONTENT;
+ response_config.id = p_request->header.id;
+ response_config.port.port_number = p_request->port.port_number;
+
+ // Copy token.
+ memcpy(&response_config.token[0], &p_request->token[0], p_request->header.token_len);
+ // Copy token length.
+ response_config.token_len = p_request->header.token_len;
+
+ coap_message_t * p_response;
+ uint32_t err_code = coap_message_new(&p_response, &response_config);
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ err_code = coap_message_payload_set(p_response, p_payload, payload_len);
+ if (err_code != NRF_SUCCESS)
+ {
+ (void)coap_message_delete(p_response);
+ return err_code;
+ }
+
+ err_code = coap_message_remote_addr_set(p_response, &p_request->remote);
+ if (err_code != NRF_SUCCESS)
+ {
+ (void)coap_message_delete(p_response);
+ return err_code;
+ }
+
+ memcpy(&p_response->remote, &p_request->remote, sizeof(coap_remote_t));
+
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_response);
+ if (err_code != NRF_SUCCESS)
+ {
+ (void)coap_message_delete(p_response);
+ return err_code;
+ }
+
+ err_code = coap_message_delete(p_response);
+
+ return err_code;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.c
new file mode 100644
index 0000000..e61a40e
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.c
@@ -0,0 +1,347 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include <stddef.h>
+
+#include "lwm2m_objects.h"
+#include "lwm2m.h"
+
+//lint -e516 -save // Symbol '__INTADDR__()' has arg. type conflict
+#define LWM2M_INSTANCE_OFFSET_SET(instance, type) \
+ instance->proto.operations_offset = offsetof(type, operations); \
+ instance->proto.resource_ids_offset = offsetof(type, resource_ids);
+//lint -restore
+
+
+void lwm2m_instance_security_init(lwm2m_security_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_security_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_SECURITY;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_security_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[9] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[10] = LWM2M_OPERATION_CODE_NONE;
+ p_instance->operations[11] = LWM2M_OPERATION_CODE_NONE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_SECURITY_SERVER_URI;
+ p_instance->resource_ids[1] = LWM2M_SECURITY_BOOTSTRAP_SERVER;
+ p_instance->resource_ids[2] = LWM2M_SECURITY_SECURITY_MODE;
+ p_instance->resource_ids[3] = LWM2M_SECURITY_PUBLIC_KEY;
+ p_instance->resource_ids[4] = LWM2M_SECURITY_SERVER_PUBLIC_KEY;
+ p_instance->resource_ids[5] = LWM2M_SECURITY_SECRET_KEY;
+ p_instance->resource_ids[6] = LWM2M_SECURITY_SMS_SECURITY_MODE;
+ p_instance->resource_ids[7] = LWM2M_SECURITY_SMS_BINDING_KEY_PARAM;
+ p_instance->resource_ids[8] = LWM2M_SECURITY_SMS_BINDING_SECRET_KEY;
+ p_instance->resource_ids[9] = LWM2M_SECURITY_SERVER_SMS_NUMBER;
+ p_instance->resource_ids[10] = LWM2M_SECURITY_SHORT_SERVER_ID;
+ p_instance->resource_ids[11] = LWM2M_SECURITY_CLIENT_HOLD_OFF_TIME;
+}
+
+
+void lwm2m_instance_server_init(lwm2m_server_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_server_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_SERVER;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_server_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[5] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[6] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[7] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_SERVER_SHORT_SERVER_ID;
+ p_instance->resource_ids[1] = LWM2M_SERVER_LIFETIME;
+ p_instance->resource_ids[2] = LWM2M_SERVER_DEFAULT_MIN_PERIOD;
+ p_instance->resource_ids[3] = LWM2M_SERVER_DEFAULT_MAX_PERIOD;
+ p_instance->resource_ids[4] = LWM2M_SERVER_DISABLE;
+ p_instance->resource_ids[5] = LWM2M_SERVER_DISABLE_TIMEOUT;
+ p_instance->resource_ids[6] = LWM2M_SERVER_NOTIFY_WHEN_DISABLED;
+ p_instance->resource_ids[7] = LWM2M_SERVER_BINDING;
+ p_instance->resource_ids[8] = LWM2M_SERVER_REGISTRATION_UPDATE_TRIGGER;
+}
+
+
+void lwm2m_instance_firmware_init(lwm2m_firmware_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_firmware_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_FIRMWARE;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_firmware_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_FIRMWARE_PACKAGE;
+ p_instance->resource_ids[1] = LWM2M_FIRMWARE_PACKAGE_URI;
+ p_instance->resource_ids[2] = LWM2M_FIRMWARE_UPDATE;
+ p_instance->resource_ids[3] = LWM2M_FIRMWARE_STATE;
+ p_instance->resource_ids[4] = LWM2M_FIRMWARE_UPDATE_SUPPORTED_OBJECTS;
+ p_instance->resource_ids[5] = LWM2M_FIRMWARE_UPDATE_RESULT;
+}
+
+
+void lwm2m_instance_acl_init(lwm2m_acl_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_acl_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_ACL;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_acl_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_ACL_OBJECT_ID;
+ p_instance->resource_ids[1] = LWM2M_ACL_INSTANCE_ID;
+ p_instance->resource_ids[2] = LWM2M_ACL_ACL;
+ p_instance->resource_ids[3] = LWM2M_ACL_CONTROL_OWNER;
+}
+
+
+void lwm2m_instance_connectivity_monitoring_init(lwm2m_connectivity_monitoring_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_connectivity_monitoring_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_CONN_MON;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_connectivity_monitoring_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[9] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[10] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_CONN_MON_NETWORK_BEARER;
+ p_instance->resource_ids[1] = LWM2M_CONN_MON_AVAILABLE_NETWORK_BEARER;
+ p_instance->resource_ids[2] = LWM2M_CONN_MON_RADIO_SIGNAL_STRENGHT;
+ p_instance->resource_ids[3] = LWM2M_CONN_MON_LINK_QUALITY;
+ p_instance->resource_ids[4] = LWM2M_CONN_MON_IP_ADDRESSES;
+ p_instance->resource_ids[5] = LWM2M_CONN_MON_ROUTER_IP_ADRESSES;
+ p_instance->resource_ids[6] = LWM2M_CONN_MON_LINK_UTILIZATION;
+ p_instance->resource_ids[7] = LWM2M_CONN_MON_APN;
+ p_instance->resource_ids[8] = LWM2M_CONN_MON_CELL_ID;
+ p_instance->resource_ids[9] = LWM2M_CONN_MON_SMNC;
+ p_instance->resource_ids[10] = LWM2M_CONN_MON_SMCC;
+}
+
+
+void lwm2m_instance_connectivity_statistics_init(lwm2m_connectivity_statistics_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_connectivity_statistics_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_CONN_STAT;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_connectivity_statistics_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_CONN_STAT_SMS_TX_COUNTER;
+ p_instance->resource_ids[1] = LWM2M_CONN_STAT_SMS_RX_COUNTER;
+ p_instance->resource_ids[2] = LWM2M_CONN_STAT_TX_DATA;
+ p_instance->resource_ids[3] = LWM2M_CONN_STAT_RX_DATA;
+ p_instance->resource_ids[4] = LWM2M_CONN_STAT_MAX_MSG_SIZE;
+ p_instance->resource_ids[5] = LWM2M_CONN_STAT_AVG_MSG_SIZE;
+ p_instance->resource_ids[6] = LWM2M_CONN_STAT_START_RESET;
+}
+
+
+void lwm2m_instance_device_init(lwm2m_device_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_device_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_DEVICE;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_device_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[9] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[10] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[11] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[12] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[13] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[14] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[15] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+ p_instance->operations[16] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_DEVICE_MANUFACTURER;
+ p_instance->resource_ids[1] = LWM2M_DEVICE_MODEL_NUMBER;
+ p_instance->resource_ids[2] = LWM2M_DEVICE_SERIAL_NUMBER;
+ p_instance->resource_ids[3] = LWM2M_DEVICE_FIRMWARE_VERSION;
+ p_instance->resource_ids[4] = LWM2M_DEVICE_REBOOT;
+ p_instance->resource_ids[5] = LWM2M_DEVICE_FACTORY_RESET;
+ p_instance->resource_ids[6] = LWM2M_DEVICE_AVAILABLE_POWER_SOURCES;
+ p_instance->resource_ids[7] = LWM2M_DEVICE_POWER_SOURCE_VOLTAGE;
+ p_instance->resource_ids[8] = LWM2M_DEVICE_POWER_SOURCE_CURRENT;
+ p_instance->resource_ids[9] = LWM2M_DEVICE_BATTERY_LEVEL;
+ p_instance->resource_ids[10] = LWM2M_DEVICE_MEMORY_FREE;
+ p_instance->resource_ids[11] = LWM2M_DEVICE_ERROR_CODE;
+ p_instance->resource_ids[12] = LWM2M_DEVICE_RESET_ERROR_CODE;
+ p_instance->resource_ids[13] = LWM2M_DEVICE_CURRENT_TIME;
+ p_instance->resource_ids[14] = LWM2M_DEVICE_UTC_OFFSET;
+ p_instance->resource_ids[15] = LWM2M_DEVICE_TIMEZONE;
+ p_instance->resource_ids[16] = LWM2M_DEVICE_SUPPORTED_BINDINGS;
+}
+
+
+void lwm2m_instance_location_init(lwm2m_location_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_location_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_LOCATION;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_location_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_LOCATION_ALTITUDE;
+ p_instance->resource_ids[1] = LWM2M_LOCATION_LONGITUDE;
+ p_instance->resource_ids[2] = LWM2M_LOCATION_ALTITUDE;
+ p_instance->resource_ids[3] = LWM2M_LOCATION_UNCERTAINTY;
+ p_instance->resource_ids[4] = LWM2M_LOCATION_VELOCITY;
+ p_instance->resource_ids[5] = LWM2M_LOCATION_TIMESTAMP;
+}
+
+
+void lwm2m_instance_software_update_init(lwm2m_software_update_t * p_instance)
+{
+ // Set prototype variables.
+ LWM2M_INSTANCE_OFFSET_SET(p_instance, lwm2m_software_update_t);
+
+ p_instance->proto.object_id = LWM2M_OBJ_SOFTWARE_UPDATE;
+ p_instance->proto.instance_id = 0;
+ p_instance->proto.num_resources = sizeof(((lwm2m_software_update_t *)0)->operations);
+
+ // Set access types.
+ p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[2] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[3] = LWM2M_OPERATION_CODE_WRITE;
+ p_instance->operations[4] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
+ p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
+ p_instance->operations[8] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
+
+ // Set resource IDs.
+ p_instance->resource_ids[0] = LWM2M_SW_UPDATE_PKG_NAME;
+ p_instance->resource_ids[1] = LWM2M_SW_UPDATE_PKG_VERSION;
+ p_instance->resource_ids[2] = LWM2M_SW_UPDATE_PACKAGE;
+ p_instance->resource_ids[3] = LWM2M_SW_UPDATE_PACKAGE_URI;
+ p_instance->resource_ids[4] = LWM2M_SW_UPDATE_INSTALL;
+ p_instance->resource_ids[5] = LWM2M_SW_UPDATE_CHECKPOINT;
+ p_instance->resource_ids[6] = LWM2M_SW_UPDATE_UNINSTALL;
+ p_instance->resource_ids[7] = LWM2M_SW_UPDATE_UPDATE_STATE;
+ p_instance->resource_ids[8] = LWM2M_SW_UPDATE_SUPPORTED_OBJECTS;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.h
new file mode 100644
index 0000000..c18917e
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects.h
@@ -0,0 +1,443 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**@file lwm2m_objects.h
+ *
+ * @defgroup iot_sdk_lwm2m_objects OMA LWM2M objects definitions and types
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief OMA LWM2M objects definitions and types.
+ *
+ * @note The definitions used in this module are from the OMA LWM2M
+ * "Lightweight Machine to Machine Technical Specification - OMA_TS-LightweightM2M-V1_0-20131210-C".
+ * The specification could be found at http://openmobilealliance.org/.
+ */
+
+#ifndef LWM2M_OBJECTS_H__
+#define LWM2M_OBJECTS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "lwm2m_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* @brief LWM2M Enabler Object IDs Appendix E */
+#define LWM2M_OBJ_SECURITY 0
+#define LWM2M_OBJ_SERVER 1
+#define LWM2M_OBJ_ACL 2
+#define LWM2M_OBJ_DEVICE 3
+#define LWM2M_OBJ_CONN_MON 4
+#define LWM2M_OBJ_FIRMWARE 5
+#define LWM2M_OBJ_LOCATION 6
+#define LWM2M_OBJ_CONN_STAT 7
+
+/* @brief LWM2M Registry Objects */
+#define LWM2M_OBJ_SOFTWARE_UPDATE 9
+
+/* LWM2M Security Resource IDs Appendix E.1 */
+#define LWM2M_SECURITY_SERVER_URI 0
+#define LWM2M_SECURITY_BOOTSTRAP_SERVER 1
+#define LWM2M_SECURITY_SECURITY_MODE 2
+#define LWM2M_SECURITY_PUBLIC_KEY 3
+#define LWM2M_SECURITY_SERVER_PUBLIC_KEY 4
+#define LWM2M_SECURITY_SECRET_KEY 5
+#define LWM2M_SECURITY_SMS_SECURITY_MODE 6
+#define LWM2M_SECURITY_SMS_BINDING_KEY_PARAM 7
+#define LWM2M_SECURITY_SMS_BINDING_SECRET_KEY 8
+#define LWM2M_SECURITY_SERVER_SMS_NUMBER 9
+#define LWM2M_SECURITY_SHORT_SERVER_ID 10
+#define LWM2M_SECURITY_CLIENT_HOLD_OFF_TIME 11
+
+
+/* LWM2M Server Resources Appendix E.2 */
+#define LWM2M_SERVER_SHORT_SERVER_ID 0
+#define LWM2M_SERVER_LIFETIME 1
+#define LWM2M_SERVER_DEFAULT_MIN_PERIOD 2
+#define LWM2M_SERVER_DEFAULT_MAX_PERIOD 3
+#define LWM2M_SERVER_DISABLE 4
+#define LWM2M_SERVER_DISABLE_TIMEOUT 5
+#define LWM2M_SERVER_NOTIFY_WHEN_DISABLED 6
+#define LWM2M_SERVER_BINDING 7
+#define LWM2M_SERVER_REGISTRATION_UPDATE_TRIGGER 8
+
+
+/* LWM2M Firmware update Resources Appendix E.6 */
+#define LWM2M_FIRMWARE_PACKAGE 0
+#define LWM2M_FIRMWARE_PACKAGE_URI 1
+#define LWM2M_FIRMWARE_UPDATE 2
+#define LWM2M_FIRMWARE_STATE 3
+#define LWM2M_FIRMWARE_UPDATE_SUPPORTED_OBJECTS 4
+#define LWM2M_FIRMWARE_UPDATE_RESULT 5
+
+#define LWM2M_FIRMWARE_STATE_IDLE 1
+#define LWM2M_FIRMWARE_STATE_DOWNLOADING 2
+#define LWM2M_FIRMWARE_STATE_DOWNLOADED 3
+
+#define LWM2M_FIRMWARE_UPDATE_RESULT_DEFAULT 0
+#define LWM2M_FIRMWARE_UPDATE_RESULT_SUCCESS 1
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_STORAGE 2
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_MEMORY 3
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_CONN_LOST 4
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_CRC 5
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_UNSUPPORTED 6
+#define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_INVALID_URI 7
+
+
+/* LWM2M ACL Resources */
+#define LWM2M_ACL_OBJECT_ID 0
+#define LWM2M_ACL_INSTANCE_ID 1
+#define LWM2M_ACL_ACL 2
+#define LWM2M_ACL_CONTROL_OWNER 3
+
+/* LWM2M Connectivity Monitoring Resources */
+#define LWM2M_CONN_MON_NETWORK_BEARER 0
+#define LWM2M_CONN_MON_AVAILABLE_NETWORK_BEARER 1
+#define LWM2M_CONN_MON_RADIO_SIGNAL_STRENGHT 2
+#define LWM2M_CONN_MON_LINK_QUALITY 3
+#define LWM2M_CONN_MON_IP_ADDRESSES 4
+#define LWM2M_CONN_MON_ROUTER_IP_ADRESSES 5
+#define LWM2M_CONN_MON_LINK_UTILIZATION 6
+#define LWM2M_CONN_MON_APN 7
+#define LWM2M_CONN_MON_CELL_ID 8
+#define LWM2M_CONN_MON_SMNC 9
+#define LWM2M_CONN_MON_SMCC 10
+
+/* LWM2M Connectivity Statistics */
+#define LWM2M_CONN_STAT_SMS_TX_COUNTER 0
+#define LWM2M_CONN_STAT_SMS_RX_COUNTER 1
+#define LWM2M_CONN_STAT_TX_DATA 2
+#define LWM2M_CONN_STAT_RX_DATA 3
+#define LWM2M_CONN_STAT_MAX_MSG_SIZE 4
+#define LWM2M_CONN_STAT_AVG_MSG_SIZE 5
+#define LWM2M_CONN_STAT_START_RESET 6
+
+/* LWM2M Device */
+#define LWM2M_DEVICE_MANUFACTURER 0
+#define LWM2M_DEVICE_MODEL_NUMBER 1
+#define LWM2M_DEVICE_SERIAL_NUMBER 2
+#define LWM2M_DEVICE_FIRMWARE_VERSION 3
+#define LWM2M_DEVICE_REBOOT 4
+#define LWM2M_DEVICE_FACTORY_RESET 5
+#define LWM2M_DEVICE_AVAILABLE_POWER_SOURCES 6
+#define LWM2M_DEVICE_POWER_SOURCE_VOLTAGE 7
+#define LWM2M_DEVICE_POWER_SOURCE_CURRENT 8
+#define LWM2M_DEVICE_BATTERY_LEVEL 9
+#define LWM2M_DEVICE_MEMORY_FREE 10
+#define LWM2M_DEVICE_ERROR_CODE 11
+#define LWM2M_DEVICE_RESET_ERROR_CODE 12
+#define LWM2M_DEVICE_CURRENT_TIME 13
+#define LWM2M_DEVICE_UTC_OFFSET 14
+#define LWM2M_DEVICE_TIMEZONE 15
+#define LWM2M_DEVICE_SUPPORTED_BINDINGS 16
+
+/* LWM2M Location */
+#define LWM2M_LOCATION_LATITUDE 0
+#define LWM2M_LOCATION_LONGITUDE 1
+#define LWM2M_LOCATION_ALTITUDE 2
+#define LWM2M_LOCATION_UNCERTAINTY 3
+#define LWM2M_LOCATION_VELOCITY 4
+#define LWM2M_LOCATION_TIMESTAMP 5
+
+/* LWM2M Software update */
+#define LWM2M_SW_UPDATE_PKG_NAME 0
+#define LWM2M_SW_UPDATE_PKG_VERSION 1
+#define LWM2M_SW_UPDATE_PACKAGE 2
+#define LWM2M_SW_UPDATE_PACKAGE_URI 3
+#define LWM2M_SW_UPDATE_INSTALL 4
+#define LWM2M_SW_UPDATE_CHECKPOINT 5
+#define LWM2M_SW_UPDATE_UNINSTALL 6
+#define LWM2M_SW_UPDATE_UPDATE_STATE 7
+#define LWM2M_SW_UPDATE_SUPPORTED_OBJECTS 8
+
+/**
+ * LWM2M Enabler
+ */
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
+ uint8_t operations[12]; /* Internal. MUST be second. */
+ uint16_t resource_ids[12]; /* Internal. MUST be third. */
+
+ /* Public members. */
+ lwm2m_string_t server_uri;
+ bool bootstrap_server;
+ uint8_t security_mode;
+ lwm2m_opaque_t public_key;
+ lwm2m_opaque_t server_public_key;
+ lwm2m_opaque_t secret_key;
+ uint8_t sms_security_mode;
+ lwm2m_opaque_t sms_binding_key_param;
+ lwm2m_opaque_t sms_binding_secret_keys;
+ uint32_t sms_number;
+ uint16_t short_server_id;
+ lwm2m_time_t client_hold_off_time;
+
+} lwm2m_security_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
+ uint8_t operations[9]; /* Internal. MUST be second. */
+ uint16_t resource_ids[9]; /* Internal. MUST be third. */
+
+ /* Public members. */
+ uint16_t short_server_id;
+ lwm2m_time_t lifetime;
+ lwm2m_time_t default_minimum_period;
+ lwm2m_time_t default_maximum_period;
+ void * disable; // Function pointer.
+ lwm2m_time_t disable_timeout;
+ bool notification_storing_on_disabled;
+ lwm2m_string_t binding;
+ void * registration_update_trigger; // Function pointer.
+
+} lwm2m_server_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
+ uint8_t operations[6]; /* Internal. MUST be second. */
+ uint16_t resource_ids[6]; /* Internal. MUST be third. */
+
+ /* Public members. */
+ lwm2m_opaque_t package;
+ lwm2m_string_t package_uri;
+ uint8_t state;
+ bool update_supported_objects;
+ uint8_t update_result;
+
+} lwm2m_firmware_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[4];
+ uint16_t resource_ids[4];
+
+ /* Public members. */
+ uint16_t acl_object_id;
+ uint16_t acl_instance_id;
+ uint16_t acl;
+ uint16_t control_owner;
+
+} lwm2m_acl_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[11];
+ uint16_t resource_ids[11];
+
+ /* Public members. */
+ uint32_t network_bearer;
+ uint32_t available_network_bearer;// TODO this is a list!
+ uint32_t radio_signal_strength; // Unit: dBm
+ uint32_t link_quality;
+ lwm2m_string_t ip_addresses; // TODO: this is a list!
+ lwm2m_string_t router_ip_addresses; // TODO: this is a list!
+ uint8_t link_utilization; // Unit: percent
+ lwm2m_string_t apn; // TODO: this is a list!
+ uint32_t cell_id;
+ uint8_t smnc; // Unit: percent
+ uint32_t smcc;
+
+} lwm2m_connectivity_monitoring_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[7];
+ uint16_t resource_ids[7];
+
+ /* Public members. */
+ uint32_t sms_tx_counter;
+ uint32_t sms_rx_counter;
+ uint32_t tx_data; // Unit: kilo-bytes
+ uint32_t rx_data; // Unit: kilo-bytes
+ uint32_t max_message_size; // Unit: byte
+ uint32_t average_message_size; // Unit: byte
+ /* StartOrReset is Execute only */
+
+} lwm2m_connectivity_statistics_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[17];
+ uint16_t resource_ids[17];
+
+ /* Public members. */
+ lwm2m_string_t manufacturer;
+ lwm2m_string_t model_number;
+ lwm2m_string_t serial_number;
+ lwm2m_string_t firmware_version;
+ /* Reboot is execute only */
+ /* Factory reset is execute only */
+ uint8_t avail_power_sources; // TODO: this is a list, Range: 0-7
+ uint32_t power_source_voltage; // TODO: this is a list, Unit: mV
+ uint32_t power_source_current; // TODO: this is a list, Unit: mA
+ uint8_t battery_level; // Unit: percent
+ uint32_t memory_free; // Unit: KB
+ uint32_t error_code; // TODO: this is a list
+ /* Reset Error code is execute only */
+ lwm2m_time_t current_time;
+ lwm2m_string_t utc_offset;
+ lwm2m_string_t timezone;
+ lwm2m_string_t supported_bindings; // TODO this is a list
+
+} lwm2m_device_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[6];
+ uint16_t resource_ids[6];
+
+ /* Public members. */
+ lwm2m_string_t latitude; // Unit: Deg
+ lwm2m_string_t longitude; // Unit: Deg
+ lwm2m_string_t altitude; // Unit: m
+ lwm2m_string_t uncertainty; // Unit: m
+ lwm2m_opaque_t velocity; // Unit: Refers to 3GPP GAD specs
+ lwm2m_time_t timestamp; // Range: 0-6
+
+} lwm2m_location_t;
+
+typedef struct
+{
+ lwm2m_instance_prototype_t proto;
+ uint8_t operations[9];
+ uint16_t resource_ids[9];
+
+ /* Public members. */
+ lwm2m_string_t pkg_name;
+ lwm2m_string_t pkg_version;
+ lwm2m_opaque_t package;
+ lwm2m_string_t package_uri;
+ /* Install is execute only */
+ uint16_t checkpoint; // TODO: this is of type Objlnk
+ /* Uninstall is execute only */
+ uint8_t update_state; // Range: 1-5
+ bool update_supported_objects;
+
+} lwm2m_software_update_t;
+
+/**@brief Initialize a LWM2M security object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_security_init(lwm2m_security_t * p_instance);
+
+/**@brief Initialize a LWM2M server object instance.
+ *
+ * @details Must be called before any use of the instance.
+
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_server_init(lwm2m_server_t * p_instance);
+
+/**@brief Initialize a LWM2M firmware object instance.
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_firmware_init(lwm2m_firmware_t * p_instance);
+
+/**@brief Initialize a LWM2M ACL object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_acl_init(lwm2m_acl_t * p_instance);
+
+/**@brief Initialize a LWM2M connectivity monitoring object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_connectivity_monitoring_init(lwm2m_connectivity_monitoring_t * p_instance);
+
+/**@brief Initialize a LWM2M connectivity statistics object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_connectivity_statistics_init(lwm2m_connectivity_statistics_t * p_instance);
+
+/**@brief Initialize a LWM2M device object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_device_init(lwm2m_device_t * p_instance);
+
+/**@brief Initialize a LWM2M location object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_location_init(lwm2m_location_t * p_instance);
+
+/**@brief Initialize a LWM2M software update object instance
+ *
+ * @details Must be called before any use of the instance.
+ *
+ * @param[in] p_instance Pointer to instance structure to initialize.
+ */
+void lwm2m_instance_software_update_init(lwm2m_software_update_t * p_instance);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_OBJECTS_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.c
new file mode 100644
index 0000000..93cb6c1
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.c
@@ -0,0 +1,498 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include "lwm2m_objects_tlv.h"
+#include "lwm2m_tlv.h"
+
+static void index_buffer_len_update(uint32_t * index, uint32_t * buffer_len, uint32_t max_buffer)
+{
+ *index += *buffer_len;
+ *buffer_len = max_buffer - *index;
+}
+
+uint32_t lwm2m_tlv_server_decode(lwm2m_server_t * server, uint8_t * buffer, uint32_t buffer_len)
+{
+ uint32_t err_code;
+ lwm2m_tlv_t tlv;
+
+ uint32_t index = 0;
+
+ while (index < buffer_len)
+ {
+ err_code = lwm2m_tlv_decode(&tlv, &index, buffer, buffer_len);
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ switch (tlv.id)
+ {
+ case LWM2M_SERVER_SHORT_SERVER_ID:
+ {
+ if (lwm2m_tlv_bytebuffer_to_uint16(tlv.value, tlv.length, &server->short_server_id) != NRF_SUCCESS)
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+
+ break;
+ }
+
+ case LWM2M_SERVER_LIFETIME:
+ {
+ if (lwm2m_tlv_bytebuffer_to_uint32(tlv.value, tlv.length, &server->lifetime))
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SERVER_DEFAULT_MIN_PERIOD:
+ {
+ if (lwm2m_tlv_bytebuffer_to_uint32(tlv.value, tlv.length, &server->default_minimum_period))
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SERVER_DEFAULT_MAX_PERIOD:
+ {
+ if (lwm2m_tlv_bytebuffer_to_uint32(tlv.value, tlv.length, &server->default_maximum_period))
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SERVER_DISABLE:
+ {
+ // Execute do nothing
+ break;
+ }
+
+ case LWM2M_SERVER_DISABLE_TIMEOUT:
+ {
+ if (lwm2m_tlv_bytebuffer_to_uint32(tlv.value, tlv.length, &server->disable_timeout))
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SERVER_NOTIFY_WHEN_DISABLED:
+ {
+ server->notification_storing_on_disabled = tlv.value[0];
+ break;
+ }
+ case LWM2M_SERVER_BINDING:
+ {
+ // If original buffer is gone this will also be gone
+ server->binding.len = tlv.length;
+ server->binding.p_val = (char *) tlv.value;
+ break;
+ }
+
+ case LWM2M_SERVER_REGISTRATION_UPDATE_TRIGGER:
+ {
+ // Execute do nothing
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_tlv_security_decode(lwm2m_security_t * p_security,
+ uint8_t * p_buffer,
+ uint32_t buffer_len)
+{
+ uint32_t err_code;
+ lwm2m_tlv_t tlv;
+
+ uint32_t index = 0;
+
+ while (index < buffer_len)
+ {
+ err_code = lwm2m_tlv_decode(&tlv, &index, p_buffer, buffer_len);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ switch (tlv.id)
+ {
+ case LWM2M_SECURITY_SERVER_URI:
+ {
+ p_security->server_uri.p_val = (char *)tlv.value;
+ p_security->server_uri.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_BOOTSTRAP_SERVER:
+ {
+ p_security->bootstrap_server = tlv.value[0];
+ break;
+ }
+
+ case LWM2M_SECURITY_SECURITY_MODE:
+ {
+ p_security->security_mode = tlv.value[0];
+ break;
+ }
+
+ case LWM2M_SECURITY_PUBLIC_KEY:
+ {
+ p_security->public_key.p_val = tlv.value;
+ p_security->public_key.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_SERVER_PUBLIC_KEY:
+ {
+ p_security->server_public_key.p_val = tlv.value;
+ p_security->server_public_key.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_SECRET_KEY:
+ {
+ p_security->secret_key.p_val = tlv.value;
+ p_security->secret_key.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_SMS_SECURITY_MODE:
+ {
+ p_security->sms_security_mode = tlv.value[0];
+ break;
+ }
+
+ case LWM2M_SECURITY_SMS_BINDING_KEY_PARAM:
+ {
+ p_security->sms_binding_key_param.p_val = tlv.value;
+ p_security->sms_binding_key_param.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_SMS_BINDING_SECRET_KEY:
+ {
+ p_security->sms_binding_secret_keys.p_val = tlv.value;
+ p_security->sms_binding_secret_keys.len = tlv.length;
+ break;
+ }
+
+ case LWM2M_SECURITY_SERVER_SMS_NUMBER:
+ {
+ uint32_t result = lwm2m_tlv_bytebuffer_to_uint32(tlv.value,
+ tlv.length,
+ &p_security->sms_number);
+ if (result != NRF_SUCCESS)
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SECURITY_SHORT_SERVER_ID:
+ {
+ uint32_t result = lwm2m_tlv_bytebuffer_to_uint16(tlv.value,
+ tlv.length,
+ &p_security->short_server_id);
+ if (result != NRF_SUCCESS)
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ case LWM2M_SECURITY_CLIENT_HOLD_OFF_TIME:
+ {
+ uint32_t result = lwm2m_tlv_bytebuffer_to_uint32(tlv.value,
+ tlv.length,
+ &p_security->client_hold_off_time);
+ if (result != NRF_SUCCESS)
+ {
+ return NRF_ERROR_INVALID_DATA;
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_tlv_server_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ lwm2m_server_t * p_server)
+{
+ uint32_t err_code;
+ uint32_t max_buffer = *p_buffer_len;
+ uint32_t index = 0;
+
+ lwm2m_tlv_t tlv;
+ tlv.id_type = TLV_TYPE_RESOURCE_VAL; // Type is the same for all.
+
+ // Encode short server id.
+ lwm2m_tlv_uint16_set(&tlv, p_server->short_server_id, LWM2M_SERVER_SHORT_SERVER_ID);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode lifetime.
+ lwm2m_tlv_uint32_set(&tlv, p_server->lifetime, LWM2M_SERVER_LIFETIME);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode default minimum period.
+ lwm2m_tlv_uint32_set(&tlv, p_server->default_minimum_period, LWM2M_SERVER_DEFAULT_MIN_PERIOD);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode default maximum period.
+ lwm2m_tlv_uint32_set(&tlv, p_server->default_maximum_period, LWM2M_SERVER_DEFAULT_MAX_PERIOD);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode disable timeout.
+ lwm2m_tlv_uint32_set(&tlv, p_server->disable_timeout, LWM2M_SERVER_DISABLE_TIMEOUT);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode Notify when disabled.
+ lwm2m_tlv_bool_set(&tlv, p_server->notification_storing_on_disabled, LWM2M_SERVER_NOTIFY_WHEN_DISABLED);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ // Encode binding.
+ lwm2m_tlv_string_set(&tlv, p_server->binding, LWM2M_SERVER_BINDING);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ *p_buffer_len = index;
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_tlv_security_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ lwm2m_security_t * p_security)
+{
+ uint32_t err_code;
+ uint32_t max_buffer = *p_buffer_len;
+ uint32_t index = 0;
+
+ lwm2m_tlv_t tlv;
+ tlv.id_type = TLV_TYPE_RESOURCE_VAL; // type is the same for all.
+
+
+ lwm2m_tlv_string_set(&tlv, p_security->server_uri, LWM2M_SECURITY_SERVER_URI);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_bool_set(&tlv, p_security->bootstrap_server, LWM2M_SECURITY_BOOTSTRAP_SERVER);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_uint16_set(&tlv, p_security->security_mode, LWM2M_SECURITY_SECURITY_MODE);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_opaque_set(&tlv, p_security->public_key, LWM2M_SECURITY_PUBLIC_KEY);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_opaque_set(&tlv, p_security->server_public_key, LWM2M_SECURITY_SERVER_PUBLIC_KEY);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_opaque_set(&tlv, p_security->secret_key, LWM2M_SECURITY_SECRET_KEY);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_uint16_set(&tlv, p_security->sms_security_mode, LWM2M_SECURITY_SMS_SECURITY_MODE);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_opaque_set(&tlv, p_security->sms_binding_key_param, LWM2M_SECURITY_SMS_BINDING_KEY_PARAM);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_opaque_set(&tlv, p_security->sms_binding_secret_keys, LWM2M_SECURITY_SMS_BINDING_SECRET_KEY);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_uint32_set(&tlv, p_security->sms_number, LWM2M_SECURITY_SERVER_SMS_NUMBER);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_uint16_set(&tlv, p_security->short_server_id, LWM2M_SECURITY_SHORT_SERVER_ID);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ lwm2m_tlv_uint32_set(&tlv, p_security->client_hold_off_time, LWM2M_SECURITY_CLIENT_HOLD_OFF_TIME);
+ err_code = lwm2m_tlv_encode(p_buffer + index, p_buffer_len, &tlv);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ index_buffer_len_update(&index, p_buffer_len, max_buffer);
+
+ return NRF_SUCCESS;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.h
new file mode 100644
index 0000000..608ecef
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_objects_tlv.h
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**@file lwm2m_objects_tlv.h
+ *
+ * @defgroup iot_sdk_lwm2m_objects_tlv OMA LWM2M object TLV encoder and decoder API
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief OMA LWM2M object TLV encoder and decoder API.
+ */
+
+#ifndef LWM2M_OBJECTS_TLV_H__
+#define LWM2M_OBJECTS_TLV_H__
+
+#include <stdint.h>
+#include "lwm2m_objects.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Decode a LWM2M server object from a TLV byte buffer.
+ *
+ * @note Resource values NOT found in the tlv will not be altered.
+ *
+ * @warning lwm2m_string_t and lwm2m_opaque_t values will point to the byte buffer and needs
+ * to be copied by the application before the byte buffer is freed.
+ *
+ * @param[out] p_server Pointer to a LWM2M server object to be filled by the decoded TLVs.
+ * @param[in] p_buffer Pointer to the TLV byte buffer to be decoded.
+ * @param[in] buffer_len Size of the buffer to be decoded.
+ *
+ * @retval NRF_SUCCESS If decoding was successful.
+ */
+uint32_t lwm2m_tlv_server_decode(lwm2m_server_t * p_server,
+ uint8_t * p_buffer,
+ uint32_t buffer_len);
+
+/**@brief Encode a LWM2M server object to a TLV byte buffer.
+ *
+ * @param[out] p_buffer Pointer to a byte buffer to be used to fill the encoded TLVs.
+ * @param[inout] p_buffer_len Value by reference indicating the size of the buffer provided.
+ * Will return the number of used bytes on return.
+ * @param[in] p_server Pointer to the LWM2M server object to be encoded into TLVs.
+ *
+ * @retval NRF_SUCCESS If the encoded was successful.
+ */
+uint32_t lwm2m_tlv_server_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ lwm2m_server_t * p_server);
+
+/**@brief Decode a LWM2M security object from a TLV byte buffer.
+ *
+ * @note Resource values NOT found in the tlv will not be altered.
+ *
+ * @warning lwm2m_string_t and lwm2m_opaque_t values will point to the byte buffer and needs
+ * to be copied by the application before the byte buffer is freed.
+ *
+ * @param[out] p_security Pointer to a LWM2M server object to be filled by the decoded TLVs.
+ * @param[in] p_buffer Pointer to the TLV byte buffer to be decoded.
+ * @param[in] buffer_len Size of the buffer to be decoded.
+ *
+ * @retval NRF_SUCCESS If decoding was successful.
+ */
+uint32_t lwm2m_tlv_security_decode(lwm2m_security_t * p_security,
+ uint8_t * p_buffer,
+ uint32_t buffer_len);
+
+/**@brief Encode a LWM2M security object to a TLV byte buffer.
+ *
+ * @param[out] p_buffer Pointer to a byte buffer to be used to fill the encoded TLVs.
+ * @param[inout] p_buffer_len Value by reference indicating the size of the buffer provided.
+ * Will return the number of used bytes on return.
+ * @param[in] p_security Pointer to the LWM2M security object to be encoded into TLVs.
+ *
+ * @retval NRF_SUCCESS If the encoded was successful.
+ */
+uint32_t lwm2m_tlv_security_encode(uint8_t * p_buffer,
+ uint32_t * p_buffer_len,
+ lwm2m_security_t * p_security);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_OBJECTS_TLV_H__
+
+/** @} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.c
new file mode 100644
index 0000000..3c273ee
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.c
@@ -0,0 +1,542 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+#include "lwm2m_api.h"
+#include "lwm2m_register.h"
+#include "lwm2m.h"
+#include "coap_api.h"
+#include "coap_message.h"
+#include "coap_codes.h"
+#include "sdk_config.h"
+#include "app_util.h"
+
+#if LWM2M_CONFIG_LOG_ENABLED
+
+#define NRF_LOG_MODULE_NAME lwm2m
+
+#define NRF_LOG_LEVEL LWM2M_CONFIG_LOG_LEVEL
+#define NRF_LOG_INFO_COLOR LWM2M_CONFIG_INFO_COLOR
+#define NRF_LOG_DEBUG_COLOR LWM2M_CONFIG_DEBUG_COLOR
+
+#include "nrf_log.h"
+
+#define LWM2M_TRC NRF_LOG_DEBUG /**< Used for getting trace of execution in the module. */
+#define LWM2M_ERR NRF_LOG_ERROR /**< Used for logging errors in the module. */
+#define LWM2M_DUMP NRF_LOG_HEXDUMP_DEBUG /**< Used for dumping octet information to get details of bond information etc. */
+
+#define LWM2M_ENTRY() LWM2M_TRC(">> %s", __func__)
+#define LWM2M_EXIT() LWM2M_TRC("<< %s", __func__)
+
+#else // LWM2M_CONFIG_LOG_ENABLED
+
+#define LWM2M_TRC(...) /**< Disables traces. */
+#define LWM2M_DUMP(...) /**< Disables dumping of octet streams. */
+#define LWM2M_ERR(...) /**< Disables error logs. */
+
+#define LWM2M_ENTRY(...)
+#define LWM2M_EXIT(...)
+
+#endif // LWM2M_CONFIG_LOG_ENABLED
+
+#define LWM2M_REGISTER_URI_PATH "rd"
+
+#define TOKEN_START 0xAE1C
+
+typedef struct
+{
+ lwm2m_remote_t remote;
+ char location[LWM2M_REGISTER_MAX_LOCATION_LEN];
+ uint16_t location_len;
+} internal_lwm2m_remote_location_t;
+
+
+static internal_lwm2m_remote_location_t m_remote_to_location[LWM2M_MAX_SERVERS];
+
+static uint16_t num_servers = 0;
+static uint16_t m_token = TOKEN_START;
+
+static uint32_t internal_message_new(coap_message_t ** pp_msg,
+ coap_msg_code_t code,
+ coap_response_callback_t callback,
+ uint16_t local_port)
+{
+ uint32_t err_code;
+ coap_message_conf_t conf;
+ memset (&conf, 0, sizeof(coap_message_conf_t));
+
+ conf.type = COAP_TYPE_CON;
+ conf.code = code;
+ conf.response_callback = callback;
+ conf.port.port_number = local_port;
+
+ conf.token_len = uint16_encode(m_token, conf.token);
+
+ m_token++;
+
+ err_code = coap_message_new(pp_msg, &conf);
+
+ return err_code;
+}
+
+
+static uint32_t internal_location_find(lwm2m_string_t * p_location, lwm2m_remote_t * p_remote)
+{
+ for (uint16_t i = 0; i < num_servers; ++i)
+ {
+ if (memcmp(&m_remote_to_location[i].remote, p_remote, sizeof(lwm2m_remote_t)) == 0)
+ {
+ p_location->p_val = m_remote_to_location[i].location;
+ p_location->len = m_remote_to_location[i].location_len;
+ return NRF_SUCCESS;
+ }
+ }
+
+ return NRF_ERROR_NOT_FOUND;
+}
+
+
+static uint32_t internal_remote_location_save(lwm2m_string_t * location, lwm2m_remote_t * remote)
+{
+ for (uint16_t i = 0; i < num_servers; ++i)
+ {
+ if (memcmp(&m_remote_to_location[i].remote, remote, sizeof(lwm2m_remote_t)) == 0)
+ {
+ memcpy(m_remote_to_location[i].location, location->p_val, location->len);
+ m_remote_to_location[i].location_len = location->len;
+ return NRF_SUCCESS;
+ }
+ }
+
+ if (num_servers == LWM2M_MAX_SERVERS)
+ return NRF_ERROR_NO_MEM;
+
+ memcpy(&m_remote_to_location[num_servers].remote, remote, sizeof(lwm2m_remote_t));
+
+ memcpy(m_remote_to_location[num_servers].location, location->p_val, location->len);
+
+ m_remote_to_location[num_servers].location_len = location->len;
+
+ ++num_servers;
+
+ return NRF_SUCCESS;
+}
+
+
+static uint32_t internal_server_config_set(coap_message_t * msg, lwm2m_server_config_t * p_config)
+{
+ char buffer[32];
+ uint32_t err_code = NRF_SUCCESS;
+
+ if (p_config->lifetime > 0)
+ {
+ int retval = snprintf(buffer, sizeof(buffer), "lt=%lu", p_config->lifetime);
+ if (retval < 0)
+ {
+ err_code = NRF_ERROR_INVALID_PARAM;
+ }
+ else
+ {
+ err_code = coap_message_opt_str_add(msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ strlen(buffer));
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ if ((p_config->lwm2m_version_major > 0) || (p_config->lwm2m_version_minor > 0))
+ {
+ int retval = snprintf(buffer,
+ sizeof(buffer),
+ "lwm2m=%d.%d",
+ p_config->lwm2m_version_major,
+ p_config->lwm2m_version_minor);
+ if (retval < 0)
+ {
+ err_code = NRF_ERROR_INVALID_PARAM;
+ }
+ else
+ {
+ err_code = coap_message_opt_str_add(msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ strlen(buffer));
+ }
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ if (p_config->msisdn > 0)
+ {
+ int retval = snprintf(buffer, sizeof(buffer), "sms=%llu" , p_config->msisdn);
+ if (retval < 0)
+ {
+ err_code = NRF_ERROR_INVALID_PARAM;
+ }
+ else
+ {
+ err_code = coap_message_opt_str_add(msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ strlen(buffer));
+ }
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ if (p_config->binding.len > 0)
+ {
+ if (p_config->binding.len < sizeof(buffer) - 2)
+ {
+ buffer[0] = 'b';
+ buffer[1] = '=';
+ memcpy(buffer + 2, p_config->binding.p_val, p_config->binding.len);
+
+ err_code = coap_message_opt_str_add(msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ p_config->binding.len + 2);
+ }
+ else
+ {
+ err_code = NRF_ERROR_NO_MEM;
+ }
+ }
+ }
+
+ return err_code;
+}
+
+
+uint32_t internal_lwm2m_register_init(void)
+{
+ m_token = TOKEN_START;
+ num_servers = 0;
+ return NRF_SUCCESS;
+}
+
+
+static void lwm2m_register_cb(uint32_t status, void * p_arg, coap_message_t * p_message)
+{
+ LWM2M_TRC("[Register]: lwm2m_register_cb, status: %ul, coap code: %u",
+ status,
+ p_message->header.code);
+
+ LWM2M_MUTEX_LOCK();
+
+ for (uint16_t i = 0; i < p_message->options_count; ++i)
+ {
+ coap_option_t option = p_message->options[i];
+
+ if (option.number == COAP_OPT_LOCATION_PATH)
+ {
+ lwm2m_string_t location;
+ location.p_val = (char *) option.p_data;
+ location.len = option.length;
+ (void)internal_remote_location_save(&location, &p_message->remote);
+ }
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ (void)lwm2m_notification(LWM2M_NOTIFCATION_TYPE_REGISTER,
+ &p_message->remote,
+ p_message->header.code);
+}
+
+
+uint32_t lwm2m_register(lwm2m_remote_t * p_remote,
+ lwm2m_client_identity_t * p_id,
+ lwm2m_server_config_t * p_config,
+ uint16_t local_port,
+ uint8_t * p_link_format_string,
+ uint16_t link_format_len)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_remote);
+ NULL_PARAM_CHECK(p_id);
+ NULL_PARAM_CHECK(p_config);
+ NULL_PARAM_CHECK(p_link_format_string);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint32_t err_code;
+ char buffer[40];
+
+ lwm2m_string_t endpoint;
+
+ endpoint.p_val = LWM2M_REGISTER_URI_PATH;
+ endpoint.len = 2;
+
+ coap_message_t * p_msg;
+
+ err_code = internal_message_new(&p_msg, COAP_CODE_POST, lwm2m_register_cb, local_port);
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_remote_addr_set(p_msg, p_remote);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ // Set uri-path option
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_PATH,
+ (uint8_t *)endpoint.p_val,
+ endpoint.len); // end_point length is always 2
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ // Set content format.
+ err_code = coap_message_opt_uint_add(p_msg, COAP_OPT_CONTENT_FORMAT, COAP_CT_APP_LINK_FORMAT);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ // Set queries.
+ buffer[0] = 'e';
+ buffer[1] = 'p';
+ buffer[2] = '=';
+ memcpy(buffer + 3, &p_id->value, p_id->type);
+
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_QUERY,
+ (uint8_t *)buffer,
+ p_id->type + 3);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = internal_server_config_set(p_msg, p_config);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_payload_set(p_msg, p_link_format_string, link_format_len);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_msg);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_delete(p_msg);
+ }
+ else
+ {
+ // If we have hit an error try to clean up.
+ // Return the original error code.
+ (void)coap_message_delete(p_msg);
+ }
+
+ LWM2M_MUTEX_UNLOCK();
+
+ LWM2M_EXIT();
+
+ return err_code;
+}
+
+void lwm2m_update_cb(uint32_t status, void * p_arg, coap_message_t * p_message)
+{
+ LWM2M_TRC("[Update]: lwm2m_update_cb, status: %ul, coap code: %u",
+ status,
+ p_message->header.code);
+
+ (void)lwm2m_notification(LWM2M_NOTIFCATION_TYPE_UPDATE,
+ &p_message->remote,
+ p_message->header.code);
+}
+
+
+uint32_t lwm2m_update(lwm2m_remote_t * p_remote, lwm2m_server_config_t * p_config, uint16_t local_port)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_remote);
+ NULL_PARAM_CHECK(p_config);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint32_t err_code;
+ coap_message_t * p_msg;
+
+ err_code = internal_message_new(&p_msg, COAP_CODE_POST, lwm2m_update_cb, local_port);
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_remote_addr_set(p_msg, p_remote);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ lwm2m_string_t location;
+ err_code = internal_location_find(&location, p_remote);
+
+ if (err_code == NRF_SUCCESS)
+ {
+ // Sets URI PATH
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_PATH,
+ (uint8_t *)location.p_val,
+ location.len);
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ // Sets CoAP queries
+ err_code = internal_server_config_set(p_msg, p_config);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_msg);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_delete(p_msg);
+ }
+ else
+ {
+ // If we have hit an error try to clean up.
+ // Return the original error code.
+ (void)coap_message_delete(p_msg);
+ }
+
+ LWM2M_EXIT();
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return err_code;
+}
+
+void lwm2m_deregister_cb(uint32_t status, void * p_arg, coap_message_t * p_message)
+{
+ LWM2M_TRC("[DeRegister]: lwm2m_deregister_cb, status: %ul, coap code: %u",
+ status,
+ p_message->header.code);
+
+ (void)lwm2m_notification(LWM2M_NOTIFCATION_TYPE_DEREGISTER,
+ &p_message->remote,
+ p_message->header.code);
+}
+
+uint32_t lwm2m_deregister(lwm2m_remote_t * p_remote, uint16_t local_port)
+{
+ LWM2M_ENTRY();
+
+ NULL_PARAM_CHECK(p_remote);
+
+ LWM2M_MUTEX_LOCK();
+
+ uint32_t err_code;
+ coap_message_t * p_msg;
+
+ err_code = internal_message_new(&p_msg, COAP_CODE_DELETE, lwm2m_deregister_cb, local_port);
+ if (err_code != NRF_SUCCESS)
+ {
+ LWM2M_MUTEX_UNLOCK();
+ return err_code;
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_remote_addr_set(p_msg, p_remote);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ lwm2m_string_t location;
+ err_code = internal_location_find(&location, p_remote);
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_opt_str_add(p_msg,
+ COAP_OPT_URI_PATH,
+ (uint8_t *)location.p_val,
+ location.len);
+ }
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ uint32_t msg_handle;
+ err_code = coap_message_send(&msg_handle, p_msg);
+ }
+
+ if (err_code == NRF_SUCCESS)
+ {
+ err_code = coap_message_delete(p_msg);
+ }
+ else
+ {
+ // If we have hit an error try to clean up.
+ // Return the original error code.
+ (void)coap_message_delete(p_msg);
+ }
+
+ LWM2M_EXIT();
+
+ LWM2M_MUTEX_UNLOCK();
+
+ return err_code;
+}
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.h
new file mode 100644
index 0000000..5daa950
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_register.h
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/** @file lwm2m_register.h
+ *
+ * @defgroup iot_sdk_lwm2m_register_api LWM2M register API interface
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief Register API interface for the LWM2M protocol.
+ */
+
+#ifndef LWM2M_REGISTER_H__
+#define LWM2M_REGISTER_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**@brief Initialize the LWM2M register module.
+ *
+ * @details Calling this function will set the module in default state.
+ */
+uint32_t internal_lwm2m_register_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_REGISTER_H__
+
+/**@} */
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.c
new file mode 100644
index 0000000..047cdb7
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.c
@@ -0,0 +1,399 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <stdint.h>
+#include <string.h>
+#include "lwm2m_tlv.h"
+#include "lwm2m_objects.h"
+#include "iot_errors.h"
+#include "iot_defines.h"
+
+// Used for encoding
+// TODO: Remove this temp_buffer in order to allow to users to use the API at the same time.
+// Current implementation might fail if two different interrupt levels are executing
+// encode at the same time. The temp_buffer will be overwritten by the last user.
+static uint8_t temp_buffer[4];
+
+
+uint32_t lwm2m_tlv_bytebuffer_to_uint32(uint8_t * p_buffer, uint8_t val_len, uint32_t * p_result)
+{
+ uint32_t res;
+ switch (val_len)
+ {
+ case 0:
+ {
+ res = 0;
+ break;
+ }
+
+ case 1:
+ {
+ res = p_buffer[0];
+ break;
+ }
+
+ case 2:
+ {
+ res = ((uint32_t)p_buffer[0] << 8) |
+ p_buffer[1];
+ break;
+ }
+
+ case 3:
+ {
+ res = ((uint32_t)p_buffer[0] << 16) |
+ ((uint32_t)p_buffer[1] << 8) |
+ p_buffer[2];
+ break;
+ }
+
+ case 4:
+ {
+ res = ((uint32_t)p_buffer[0] << 24) |
+ ((uint32_t)p_buffer[1] << 16) |
+ ((uint32_t)p_buffer[2] << 8) |
+ p_buffer[3];
+ break;
+ }
+
+ default:
+ return NRF_ERROR_DATA_SIZE;
+ }
+
+ *p_result = res;
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_tlv_bytebuffer_to_uint16(uint8_t * p_buffer, uint8_t val_len, uint16_t * p_result)
+{
+ uint16_t res;
+ switch (val_len)
+ {
+ case 0:
+ {
+ res = 0;
+ break;
+ }
+
+ case 1:
+ {
+ res = p_buffer[0];
+ break;
+ }
+
+ case 2:
+ {
+ res = ((uint16_t)p_buffer[0] << 8) | p_buffer[1];
+ break;
+ }
+
+ default:
+ return NRF_ERROR_DATA_SIZE;
+ }
+
+ *p_result = res;
+ return NRF_SUCCESS;
+}
+
+
+void lwm2m_tlv_uint16_to_bytebuffer(uint8_t * p_buffer, uint8_t * p_len, uint16_t value)
+{
+ if (value == 0)
+ {
+ *p_len = 0;
+ }
+ else if (value <= UINT8_MAX)
+ {
+ p_buffer[0] = value;
+ *p_len = 1;
+ }
+ else
+ {
+
+ p_buffer[1] = value;
+ p_buffer[0] = value >> 8;
+ *p_len = 2;
+ }
+}
+
+
+void lwm2m_tlv_uint32_to_bytebuffer(uint8_t * p_buffer, uint8_t * p_len, uint32_t value)
+{
+ if (value == 0)
+ {
+ *p_len = 0;
+ }
+ else if (value <= UINT8_MAX)
+ {
+ p_buffer[0] = value;
+ *p_len = 1;
+ }
+ else if (value <= UINT16_MAX)
+ {
+
+ p_buffer[1] = value;
+ p_buffer[0] = value >> 8;
+ *p_len = 2;
+ }
+ else if (value <= 0xFFFFFF) // 24 bit
+ {
+ p_buffer[2] = value;
+ p_buffer[1] = value >> 8;
+ p_buffer[0] = value >> 16;
+ *p_len = 3;
+ }
+ else
+ {
+ p_buffer[3] = value;
+ p_buffer[2] = value >> 8;
+ p_buffer[1] = value >> 16;
+ p_buffer[0] = value >> 24;
+ *p_len = 4;
+ }
+}
+
+
+void lwm2m_tlv_uint16_set(lwm2m_tlv_t * p_tlv, uint16_t value, uint16_t id)
+{
+ uint8_t val_len;
+ lwm2m_tlv_uint16_to_bytebuffer(temp_buffer, &val_len, value);
+
+ p_tlv->length = val_len;
+ p_tlv->value = temp_buffer;
+ p_tlv->id = id;
+}
+
+
+void lwm2m_tlv_uint32_set(lwm2m_tlv_t * p_tlv, uint32_t value, uint16_t id)
+{
+ uint8_t val_len;
+ lwm2m_tlv_uint32_to_bytebuffer(temp_buffer, &val_len, value);
+
+ p_tlv->length = val_len;
+ p_tlv->value = temp_buffer;
+ p_tlv->id = id;
+}
+
+
+void lwm2m_tlv_bool_set(lwm2m_tlv_t * p_tlv, bool value, uint16_t id)
+{
+
+ if (value == true)
+ {
+ temp_buffer[0] = 1;
+ }
+ else
+ {
+ temp_buffer[0] = 0;
+ }
+
+ p_tlv->length = 1;
+ p_tlv->value = temp_buffer;
+ p_tlv->id = id;
+}
+
+
+void lwm2m_tlv_string_set(lwm2m_tlv_t * p_tlv, lwm2m_string_t string, uint16_t id)
+{
+ p_tlv->length = string.len;
+ p_tlv->value = (uint8_t *)string.p_val;
+ p_tlv->id = id;
+}
+
+
+void lwm2m_tlv_opaque_set(lwm2m_tlv_t * p_tlv, lwm2m_opaque_t opaque, uint16_t id)
+{
+ p_tlv->length = opaque.len;
+ p_tlv->value = opaque.p_val;
+ p_tlv->id = id;
+}
+
+
+uint32_t lwm2m_tlv_decode(lwm2m_tlv_t * p_tlv,
+ uint32_t * p_index,
+ uint8_t * p_buffer,
+ uint16_t buffer_len)
+{
+ uint32_t err_code;
+ uint16_t index = *p_index;
+
+ uint8_t type = (p_buffer[index] & TLV_TYPE_MASK) >> TLV_TYPE_BIT_POS;
+ uint8_t id_len = (p_buffer[index] & TLV_ID_LEN_MASK) >> TLV_ID_LEN_BIT_POS;
+ uint8_t length_len = (p_buffer[index] & TLV_LEN_TYPE_MASK) >> TLV_LEN_TYPE_BIT_POS;
+ uint32_t length = (p_buffer[index] & TLV_LEN_VAL_MASK) >> TLV_VAL_LEN_BIT_POS;
+
+ p_tlv->id_type = type;
+ p_tlv->length = 0;
+
+ // Jump to the byte following the "Type" at index 0.
+ ++index;
+
+ // Extract the Identifier based on the number of bytes indicated in id_len (bit 5).
+ // Adding one to the id_len will give the number of bytes used.
+ uint8_t id_len_size = id_len + 1;
+
+ err_code = lwm2m_tlv_bytebuffer_to_uint16(&p_buffer[index], id_len_size, &p_tlv->id);
+
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+ index += id_len_size;
+
+
+ // Extract the value length.
+ // The length_len tells how many bytes are being used.
+ if (length_len == TLV_LEN_TYPE_3BIT)
+ {
+ p_tlv->length = length;
+ }
+ else
+ {
+ err_code = lwm2m_tlv_bytebuffer_to_uint32(&p_buffer[index], length_len, &length);
+ if (err_code != NRF_SUCCESS)
+ {
+ return err_code;
+ }
+
+ p_tlv->length = length;
+ index += length_len;
+ }
+
+ if (p_tlv->length > buffer_len)
+ {
+ return (IOT_LWM2M_ERR_BASE | NRF_ERROR_INVALID_DATA);
+ }
+
+ p_tlv->value = &p_buffer[index];
+
+ *p_index = index + p_tlv->length;
+
+ return NRF_SUCCESS;
+}
+
+
+uint32_t lwm2m_tlv_encode(uint8_t * p_buffer, uint32_t * buffer_len, lwm2m_tlv_t * p_tlv)
+{
+ uint8_t length_len;
+ uint8_t id_len;
+
+ uint8_t id[2] = {0,};
+ uint8_t len[3] = {0,};
+ uint16_t index = 0;
+ uint8_t type = 0;
+
+ // Set Identifier type by copying the lwm2m_tlv_t->id_type into bit 7-6.
+ type = (p_tlv->id_type << TLV_TYPE_BIT_POS);
+
+ // Set length of Identifier in bit 5 in the TLV type byte.
+ if (p_tlv->id > UINT8_MAX)
+ {
+ type |= (TLV_ID_LEN_16BIT << TLV_ID_LEN_BIT_POS);
+ id[0] = p_tlv->id >> 8;
+ id[1] = p_tlv->id;
+ id_len = 2;
+ }
+ else
+ {
+ type |= (TLV_ID_LEN_8BIT << TLV_ID_LEN_BIT_POS);
+ id[0] = p_tlv->id;
+ id_len = 1;
+ }
+
+ // Set type of Length bit 4-3 in the TLV type byte.
+
+ // If the Length can fit into 3 bits.
+ if ((p_tlv->length & TLV_LEN_VAL_MASK) == p_tlv->length)
+ {
+ type |= (TLV_LEN_TYPE_3BIT << TLV_LEN_TYPE_BIT_POS);
+ length_len = 0;
+
+ // As Length type field is set to "No Length", set bit 2-0.
+ type |= (p_tlv->length & TLV_LEN_VAL_MASK);
+ }
+ else
+ {
+ lwm2m_tlv_uint32_to_bytebuffer(&len[0], &length_len, p_tlv->length);
+
+ // Length can not be larger than 24-bit.
+ if (length_len > TLV_LEN_TYPE_24BIT)
+ {
+ return (IOT_LWM2M_ERR_BASE | NRF_ERROR_INVALID_PARAM);
+ }
+
+ type |= (length_len << TLV_LEN_TYPE_BIT_POS);
+ }
+
+ // Check if the buffer is large enough.
+ if (*buffer_len < (p_tlv->length + id_len + length_len + 1)) // + 1 for the type byte
+ {
+ return (IOT_LWM2M_ERR_BASE | NRF_ERROR_DATA_SIZE);
+ }
+
+ // Copy the type to the buffer.
+ memcpy(p_buffer + index, &type, 1);
+ ++index;
+
+ // Copy the Identifier to the buffer.
+ memcpy(p_buffer + index, id, id_len);
+ index += id_len;
+
+ // Copy length to the buffer.
+ if (length_len != 0)
+ {
+ memcpy(p_buffer + index, len, length_len);
+ index += length_len;
+ }
+
+ // Copy the value to buffer, memcpy of 0 length is undefined behavior so lets avoid it.
+ if (p_tlv->length > 0)
+ {
+ memcpy(p_buffer + index, p_tlv->value, p_tlv->length);
+ }
+
+ // Set length of the output buffer.
+ *buffer_len = p_tlv->length + index;
+
+ return NRF_SUCCESS;
+}
+
+
+
+
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.h
new file mode 100644
index 0000000..8ac5784
--- /dev/null
+++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/iot/lwm2m/lwm2m_tlv.h
@@ -0,0 +1,207 @@
+/**
+ * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form, except as embedded into a Nordic
+ * Semiconductor ASA integrated circuit in a product or a software update for
+ * such product, must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 4. This software, with or without modification, must only be used with a
+ * Nordic Semiconductor ASA integrated circuit.
+ *
+ * 5. Any software provided in binary form under this license must not be reverse
+ * engineered, decompiled, modified and/or disassembled.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/** @file lwm2m_tlv.h
+ *
+ * @defgroup iot_sdk_lwm2m_tlv_api LWM2M TLV interface
+ * @ingroup iot_sdk_lwm2m
+ * @{
+ * @brief TLV encoding and decoding interface for the LWM2M protocol.
+ */
+
+#ifndef LWM2M_TLV_H__
+#define LWM2M_TLV_H__
+
+#include <stdint.h>
+#include "lwm2m_objects.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* TLV type masks
+*/
+#define TLV_TYPE_BIT_POS 6
+#define TLV_ID_LEN_BIT_POS 5
+#define TLV_LEN_TYPE_BIT_POS 3
+#define TLV_VAL_LEN_BIT_POS 0
+
+#define TLV_TYPE_MASK (0x3 << TLV_TYPE_BIT_POS) /**< Type bitmask, bit 7-6 (0b11000000). */
+#define TLV_ID_LEN_MASK (0x1 << TLV_ID_LEN_BIT_POS) /**< Length bitmask, bit 5 (0b00100000). */
+#define TLV_LEN_TYPE_MASK (0x3 << TLV_LEN_TYPE_BIT_POS) /**< Length type bitmask, bit 4-3 (0b00011000). */
+#define TLV_LEN_VAL_MASK (0x7 << TLV_VAL_LEN_BIT_POS) /**< Length of the value bitmask, bit 2-0 (0b00000111). */
+
+#define TLV_TYPE_OBJECT 0x00
+#define TLV_TYPE_RESOURCE_INSTANCE 0x01
+#define TLV_TYPE_MULTI_RESOURCE 0x02
+#define TLV_TYPE_RESOURCE_VAL 0x03
+
+#define TLV_ID_LEN_8BIT 0x00
+#define TLV_ID_LEN_16BIT 0x01
+
+#define TLV_LEN_TYPE_3BIT 0x00
+#define TLV_LEN_TYPE_8BIT 0x01
+#define TLV_LEN_TYPE_16BIT 0x02
+#define TLV_LEN_TYPE_24BIT 0x03
+
+typedef struct
+{
+ uint16_t id_type; /**< Identifier type. */
+ uint16_t id; /**< Identifier ID. */
+ uint32_t length; /**< Length of the value in the TLV. */
+ uint8_t * value; /**< Value of the TLV. */
+} lwm2m_tlv_t;
+
+/**@brief Decode a LWM2M TLV byte buffer into a TLV structure.
+ *
+ * @param[out] p_tlv This struct will be filled with id, length, type and pointer to value.
+ * @param[inout] p_index Index to start decoding from.
+ * @param[in] p_buffer The buffer to decode from.
+ * @param[in] buffer_len The length of the buffer.
+ *
+ * @retval NRF_SUCCESS If decoding was successful.
+ * @retval IOT_LWM2M_ERR_BASE | NRF_INVALID_DATA
+ */
+uint32_t lwm2m_tlv_decode(lwm2m_tlv_t * p_tlv, uint32_t * p_index, uint8_t * p_buffer, uint16_t buffer_len);
+
+/**@brief Encode a TLV structure into a LWM2M TLV byte buffer.
+ *
+ * @details Encode using the provided tlv, if the buffer provided is to small an NRF_ERROR_DATA_SIZE will be returned.
+ *
+ * Maximum buffer size requirement: value_length + 6 (1 for type byte, 2 for id bytes, 3 for length bytes).
+ *
+ * @param[out] p_buffer Buffer to put the encoded tlv into.
+ * @param[inout] buffer_len Length of input buffer out: length of the encoded buffer.
+ * @param[in] p_tlv The tlv to use.
+ *
+ * @retval NRF_SUCCESS If decoding was successful.
+ * @retval IOT_LWM2M_ERR_BASE | NRF_ERROR_DATA_SIZE
+ */
+uint32_t lwm2m_tlv_encode(uint8_t * p_buffer, uint32_t * p_buffer_len, lwm2m_tlv_t * p_tlv);
+
+/**@brief Encode a byte buffer into a uint32_t.
+ *
+ * @param[in] p_buffer Buffer which holds a serialized version of the uint32_t.
+ * @param[in] val_len Length of the value in the buffer.
+ * @param[out] p_result By reference pointer to the result uint32_t.
+ *
+ * @retval NRF_SUCCESS If the conversion from byte buffer to uint32_t value was successful.
+ */
+uint32_t lwm2m_tlv_bytebuffer_to_uint32(uint8_t * p_buffer, uint8_t val_len, uint32_t * p_result);
+
+/**@brief Encode a byte buffer into a uint16_t.
+ *
+ * @param[in] p_buffer Buffer which holds a serialized version of the uint16_t.
+ * @param[in] val_len Length of the value in the buffer.
+ * @param[out] p_result By reference pointer to the result uint16_t.
+ *
+ * @retval NRF_SUCCESS If the conversion from byte buffer to uint32_t value was successful.
+ */
+uint32_t lwm2m_tlv_bytebuffer_to_uint16(uint8_t * p_buffer, uint8_t val_len, uint16_t * p_result);
+
+/**@brief Decode a uint32_t into a byte buffer.
+ *
+ * @param[out] p_buffer Buffer which holds a serialized version of the uint32_t.
+ * @param[out] p_len By reference pointer to hold the length of the serialized value in the buffer.
+ * @param[in] value Value to convert serialize into a byte buffer.
+ *
+ * @retval NRF_SUCCESS If the conversion from uint32_t value to byte buffer was successful.
+ */
+void lwm2m_tlv_uint32_to_bytebuffer(uint8_t * p_buffer, uint8_t * p_len, uint32_t value);
+
+/**@brief Decode a uint16_t into a byte buffer.
+ *
+ * @param[out] p_buffer Buffer which holds a serialized version of the uint16_t.
+ * @param[out] p_len By reference pointer to hold the length of the serialized value in the buffer.
+ * @param[in] value Value to convert serialize into a byte buffer.
+ *
+ * @retval NRF_SUCCESS If the conversion from uint16_t value to byte buffer was successful.
+ */
+void lwm2m_tlv_uint16_to_bytebuffer(uint8_t * p_buffer, uint8_t * p_len, uint16_t value);
+
+/**@brief Set a uint32_t value to a lwm2m_tlv_t structure.
+ *
+ * @param[out] p_tlv TLV containing the uint32_t tlv.
+ * @param[in] value Value to set.
+ * @param[in] id Resource Id associated with the value.
+ */
+void lwm2m_tlv_uint32_set(lwm2m_tlv_t * p_tlv, uint32_t value, uint16_t id);
+
+
+/**@brief Set a uint16_t value to a lwm2m_tlv_t structure.
+ *
+ * @param[out] p_tlv TLV containing the uint16_t tlv.
+ * @param[in] value Value to set.
+ * @param[in] id Resource Id associated with the value.
+ */
+void lwm2m_tlv_uint16_set(lwm2m_tlv_t * p_tlv, uint16_t value, uint16_t id);
+
+
+/**@brief Set a boolean value to a lwm2m_tlv_t structure.
+ *
+ * @param[out] p_tlv TLV containing the boolean tlv.
+ * @param[in] value Value to set.
+ * @param[in] id Resource Id associated with the value.
+ */
+void lwm2m_tlv_bool_set(lwm2m_tlv_t * p_tlv, bool value, uint16_t id);
+
+/**@brief Set a string value to a lwm2m_tlv_t structure.
+ *
+ * @param[out] p_tlv TLV containing the string tlv.
+ * @param[in] value Value to set.
+ * @param[in] id Resource Id associated with the value.
+ */
+void lwm2m_tlv_string_set(lwm2m_tlv_t * p_tlv, lwm2m_string_t string, uint16_t id);
+
+/**@brief Set a opaque value to a lwm2m_tlv_t structure.
+ *
+ * @param[out] p_tlv TLV containing the opaque tlv.
+ * @param[in] value Value to set.
+ * @param[in] id Resource Id associated with the value.
+ */
+void lwm2m_tlv_opaque_set(lwm2m_tlv_t * p_tlv, lwm2m_opaque_t opaque, uint16_t id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LWM2M_TLV_H__
+
+/** @} */