-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Introduce LWM2M subsystem for Zephyr #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
10d897a
misc/byteorder: add support for __bswap_64
de8fbcc
net: zoap: use message id for reply matching
4e06a92
net: lwm2m: initial library support for LWM2M
408f43e
samples: lwm2m: initial sample for LWM2M client
4d28996
net: lwm2m: add IPSO support w/ temperature sensor object
65035d1
samples: lwm2m: add IPSO temperature object to LWM2M client
7970296
net: lwm2m: add SPX Apache-2.0 license tag w/ Linaro copyright
e7ed1a0
MAINTAINERS: add maintainer for LwM2M library / samples
4f27e89
CODEOWNERS: add entries for LwM2M library / samples
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,6 +280,11 @@ M: Anas Nashif <[email protected]> | |
| M: Inaky Perez-Gonzalez <[email protected]> | ||
| F: .known-issues/ | ||
|
|
||
| LWM2M | ||
| M: Michael Scott <[email protected]> | ||
| S: Supported | ||
| F: subsys/net/lib/lwm2m/ | ||
| F: samples/net/lwm2m_client/ | ||
|
|
||
| MAINTAINERS | ||
| M: Anas Nashif <[email protected]> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| /* | ||
| * Copyright (c) 2017 Linaro Limited | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #ifndef __LWM2M_H__ | ||
| #define __LWM2M_H__ | ||
|
|
||
| #include <net/net_context.h> | ||
|
|
||
| /* LWM2M Objects defined by OMA */ | ||
|
|
||
| #define LWM2M_OBJECT_SECURITY_ID 0 | ||
| #define LWM2M_OBJECT_SERVER_ID 1 | ||
| #define LWM2M_OBJECT_ACCESS_CONTROL_ID 2 | ||
| #define LWM2M_OBJECT_DEVICE_ID 3 | ||
| #define LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID 4 | ||
| #define LWM2M_OBJECT_FIRMWARE_ID 5 | ||
| #define LWM2M_OBJECT_LOCATION_ID 6 | ||
| #define LWM2M_OBJECT_CONNECTIVITY_STATISTICS_ID 7 | ||
|
|
||
| /* IPSO Alliance Objects */ | ||
|
|
||
| #define IPSO_OBJECT_TEMP_SENSOR_ID 3303 | ||
|
|
||
| /* callback can return 1 if handled (don't update value) */ | ||
| typedef void *(*lwm2m_engine_get_data_cb_t)(u16_t obj_inst_id, | ||
| size_t *data_len); | ||
| typedef int (*lwm2m_engine_set_data_cb_t)(u16_t obj_inst_id, | ||
| u8_t *data, u16_t data_len, | ||
| bool last_block, size_t total_size); | ||
| typedef int (*lwm2m_engine_exec_cb_t)(u16_t obj_inst_id); | ||
|
|
||
|
|
||
| /* LWM2M Device Object */ | ||
|
|
||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_DC_POWER 0 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT 1 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_EXT 2 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_UNUSED 3 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_PWR_OVER_ETH 4 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_USB 5 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_AC_POWER 6 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_SOLAR 7 | ||
| #define LWM2M_DEVICE_PWR_SRC_TYPE_MAX 8 | ||
|
|
||
| #define LWM2M_DEVICE_ERROR_NONE 0 | ||
| #define LWM2M_DEVICE_ERROR_LOW_POWER 1 | ||
| #define LWM2M_DEVICE_ERROR_EXT_POWER_SUPPLY_OFF 2 | ||
| #define LWM2M_DEVICE_ERROR_GPS_FAILURE 3 | ||
| #define LWM2M_DEVICE_ERROR_LOW_SIGNAL_STRENGTH 4 | ||
| #define LWM2M_DEVICE_ERROR_OUT_OF_MEMORY 5 | ||
| #define LWM2M_DEVICE_ERROR_SMS_FAILURE 6 | ||
| #define LWM2M_DEVICE_ERROR_NETWORK_FAILURE 7 | ||
| #define LWM2M_DEVICE_ERROR_PERIPHERAL_FAILURE 8 | ||
|
|
||
| #define LWM2M_DEVICE_BATTERY_STATUS_NORMAL 0 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_CHARGING 1 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_CHARGE_COMP 2 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_DAMAGED 3 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_LOW 4 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_NOT_INST 5 | ||
| #define LWM2M_DEVICE_BATTERY_STATUS_UNKNOWN 6 | ||
|
|
||
| int lwm2m_device_add_pwrsrc(u8_t pwr_src_type); /* returns index */ | ||
| int lwm2m_device_remove_pwrsrc(int index); | ||
| int lwm2m_device_set_pwrsrc_voltage_mv(int index, int voltage_mv); | ||
| int lwm2m_device_set_pwrsrc_current_ma(int index, int current_ma); | ||
| int lwm2m_device_add_err(u8_t error_code); | ||
|
|
||
|
|
||
| /* LWM2M Firemware Update Object */ | ||
|
|
||
| #define STATE_IDLE 0 | ||
| #define STATE_DOWNLOADING 1 | ||
| #define STATE_DOWNLOADED 2 | ||
| #define STATE_UPDATING 3 | ||
|
|
||
| #define RESULT_DEFAULT 0 | ||
| #define RESULT_SUCCESS 1 | ||
| #define RESULT_NO_STORAGE 2 | ||
| #define RESULT_OUT_OF_MEM 3 | ||
| #define RESULT_CONNECTION_LOST 4 | ||
| #define RESULT_INTEGRITY_FAILED 5 | ||
| #define RESULT_UNSUP_FW 6 | ||
| #define RESULT_INVALID_URI 7 | ||
| #define RESULT_UPDATE_FAILED 8 | ||
| #define RESULT_UNSUP_PROTO 9 | ||
|
|
||
| void lwm2m_firmware_set_write_cb(lwm2m_engine_set_data_cb_t cb); | ||
| lwm2m_engine_set_data_cb_t lwm2m_firmware_get_write_cb(void); | ||
|
|
||
|
|
||
| /* LWM2M Engine */ | ||
|
|
||
| /* | ||
| * float type below use the following logic: | ||
| * val1 is the whole number portion of decimal | ||
| * val2 is the decimal portion *1000000 for 32bit, *1000000000 for 64bit | ||
| * Example: 123.456 == val1: 123, val2:456000 | ||
| * Example: 123.000456 = val1: 123, val2:456 | ||
| */ | ||
| typedef struct float32_value { | ||
| s32_t val1; | ||
| s32_t val2; | ||
| } float32_value_t; | ||
|
|
||
| typedef struct float64_value { | ||
| s64_t val1; | ||
| s64_t val2; | ||
| } float64_value_t; | ||
|
|
||
| int lwm2m_engine_create_obj_inst(char *pathstr); | ||
|
|
||
| int lwm2m_engine_set_string(char *path, char *data_ptr); | ||
| int lwm2m_engine_set_u8(char *path, u8_t value); | ||
| int lwm2m_engine_set_u16(char *path, u16_t value); | ||
| int lwm2m_engine_set_u32(char *path, u32_t value); | ||
| int lwm2m_engine_set_u64(char *path, u64_t value); | ||
| int lwm2m_engine_set_s8(char *path, s8_t value); | ||
| int lwm2m_engine_set_s16(char *path, s16_t value); | ||
| int lwm2m_engine_set_s32(char *path, s32_t value); | ||
| int lwm2m_engine_set_s64(char *path, s64_t value); | ||
| int lwm2m_engine_set_bool(char *path, bool value); | ||
| int lwm2m_engine_set_float32(char *pathstr, float32_value_t *value); | ||
| int lwm2m_engine_set_float64(char *pathstr, float64_value_t *value); | ||
|
|
||
| int lwm2m_engine_get_string(char *path, void *str, u16_t strlen); | ||
| u8_t lwm2m_engine_get_u8(char *path); | ||
| u16_t lwm2m_engine_get_u16(char *path); | ||
| u32_t lwm2m_engine_get_u32(char *path); | ||
| u64_t lwm2m_engine_get_u64(char *path); | ||
| s8_t lwm2m_engine_get_s8(char *path); | ||
| s16_t lwm2m_engine_get_s16(char *path); | ||
| s32_t lwm2m_engine_get_s32(char *path); | ||
| s64_t lwm2m_engine_get_s64(char *path); | ||
| bool lwm2m_engine_get_bool(char *path); | ||
| int lwm2m_engine_get_float32(char *pathstr, float32_value_t *buf); | ||
| int lwm2m_engine_get_float64(char *pathstr, float64_value_t *buf); | ||
|
|
||
| int lwm2m_engine_register_read_callback(char *path, | ||
| lwm2m_engine_get_data_cb_t cb); | ||
| int lwm2m_engine_register_pre_write_callback(char *path, | ||
| lwm2m_engine_get_data_cb_t cb); | ||
| int lwm2m_engine_register_post_write_callback(char *path, | ||
| lwm2m_engine_set_data_cb_t cb); | ||
| int lwm2m_engine_register_exec_callback(char *path, | ||
| lwm2m_engine_exec_cb_t cb); | ||
|
|
||
| int lwm2m_engine_start(struct net_context *net_ctx); | ||
|
|
||
| /* LWM2M RD Client */ | ||
|
|
||
| int lwm2m_rd_client_start(struct net_context *net_ctx, | ||
| struct sockaddr *peer_addr, | ||
| const char *ep_name); | ||
|
|
||
| #endif /* __LWM2M_H__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,6 +231,7 @@ struct zoap_reply { | |
| void *user_data; | ||
| int age; | ||
| u8_t token[8]; | ||
| u16_t id; | ||
| u8_t tkl; | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Makefile - LWM2M client test application | ||
|
|
||
| # | ||
| # Copyright (c) 2017 Linaro | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
|
|
||
| BOARD ?= qemu_x86 | ||
| CONF_FILE ?= prj_$(BOARD).conf | ||
|
|
||
| include $(ZEPHYR_BASE)/Makefile.inc | ||
| include $(ZEPHYR_BASE)/samples/net/common/Makefile.ipstack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| .. _lwm2m-client-sample: | ||
|
|
||
| LWM2M client | ||
| ############ | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| TODO | ||
|
|
||
| Building and Running | ||
| ******************** | ||
|
|
||
| TODO | ||
|
|
||
| Sample output | ||
| ============= | ||
|
|
||
| TODO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| CONFIG_NETWORKING=y | ||
| CONFIG_NET_LOG=y | ||
| CONFIG_NET_BUF_LOG=y | ||
| CONFIG_SYS_LOG_NET_LEVEL=4 | ||
| CONFIG_SYS_LOG_NET_BUF_LEVEL=2 | ||
| CONFIG_SYS_LOG_LWM2M_LEVEL=4 | ||
| CONFIG_TEST_RANDOM_GENERATOR=y | ||
| CONFIG_NET_IPV6=y | ||
| CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 | ||
| CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2 | ||
| CONFIG_NET_IPV4=y | ||
| CONFIG_NET_DHCPV4=n | ||
| CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3 | ||
| CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2 | ||
| CONFIG_SYS_LOG_SHOW_COLOR=y | ||
| CONFIG_INIT_STACKS=y | ||
| CONFIG_PRINTK=y | ||
| CONFIG_NET_STATISTICS=y | ||
| CONFIG_NET_BUF_DATA_SIZE=384 | ||
| CONFIG_NET_PKT_RX_COUNT=50 | ||
| CONFIG_NET_PKT_TX_COUNT=50 | ||
| CONFIG_NET_BUF_RX_COUNT=50 | ||
| CONFIG_NET_BUF_TX_COUNT=50 | ||
| CONFIG_NET_MAX_CONTEXTS=10 | ||
| CONFIG_NET_CONTEXT_NET_PKT_POOL=y | ||
|
|
||
| CONFIG_NET_SHELL=y | ||
|
|
||
| CONFIG_NET_APP=y | ||
| CONFIG_NET_APP_NEED_IPV6=y | ||
| CONFIG_NET_APP_NEED_IPV4=y | ||
| CONFIG_NET_APP_CLIENT=y | ||
| CONFIG_NET_APP_SETTINGS=y | ||
|
|
||
| CONFIG_LWM2M=y | ||
| CONFIG_LWM2M_RD_CLIENT_INSTANCE_COUNT=2 | ||
| CONFIG_LWM2M_IPSO_SUPPORT=y | ||
| CONFIG_LWM2M_IPSO_TEMP_SENSOR=y | ||
|
|
||
| CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::1" | ||
| CONFIG_NET_APP_PEER_IPV6_ADDR="2001:db8::2" | ||
| CONFIG_NET_APP_MY_IPV4_ADDR="192.0.2.1" | ||
| CONFIG_NET_APP_PEER_IPV4_ADDR="192.0.2.2" | ||
|
|
||
| CONFIG_NET_L2_ETHERNET=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| CONFIG_NETWORKING=y | ||
| CONFIG_NET_LOG=y | ||
| CONFIG_NET_BUF_LOG=y | ||
| CONFIG_SYS_LOG_NET_LEVEL=4 | ||
| CONFIG_SYS_LOG_NET_BUF_LEVEL=2 | ||
| CONFIG_SYS_LOG_LWM2M_LEVEL=4 | ||
| CONFIG_TEST_RANDOM_GENERATOR=y | ||
| CONFIG_NET_IPV6=y | ||
| CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 | ||
| CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2 | ||
| CONFIG_NET_IPV4=y | ||
| CONFIG_NET_DHCPV4=n | ||
| CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3 | ||
| CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2 | ||
| CONFIG_SYS_LOG_SHOW_COLOR=y | ||
| CONFIG_INIT_STACKS=y | ||
| CONFIG_PRINTK=y | ||
| CONFIG_NET_STATISTICS=y | ||
| CONFIG_NET_BUF_DATA_SIZE=384 | ||
| CONFIG_NET_PKT_RX_COUNT=50 | ||
| CONFIG_NET_PKT_TX_COUNT=50 | ||
| CONFIG_NET_BUF_RX_COUNT=50 | ||
| CONFIG_NET_BUF_TX_COUNT=50 | ||
| CONFIG_NET_MAX_CONTEXTS=10 | ||
| CONFIG_NET_CONTEXT_NET_PKT_POOL=y | ||
|
|
||
| CONFIG_NET_SHELL=y | ||
|
|
||
| CONFIG_NET_APP=y | ||
| CONFIG_NET_APP_NEED_IPV6=y | ||
| CONFIG_NET_APP_NEED_IPV4=y | ||
| CONFIG_NET_APP_CLIENT=y | ||
| CONFIG_NET_APP_SETTINGS=y | ||
|
|
||
| CONFIG_LWM2M=y | ||
| CONFIG_LWM2M_RD_CLIENT_INSTANCE_COUNT=2 | ||
| CONFIG_LWM2M_IPSO_SUPPORT=y | ||
| CONFIG_LWM2M_IPSO_TEMP_SENSOR=y | ||
|
|
||
| CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::1" | ||
| CONFIG_NET_APP_PEER_IPV6_ADDR="2001:db8::2" | ||
| CONFIG_NET_APP_MY_IPV4_ADDR="192.0.2.1" | ||
| CONFIG_NET_APP_PEER_IPV4_ADDR="192.0.2.2" | ||
|
|
||
| CONFIG_NET_SLIP_TAP=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| sample: | ||
| description: TBD | ||
| name: TBD | ||
| tests: | ||
| - test: | ||
| build_only: true | ||
| platform_whitelist: qemu_x86 | ||
| tags: net lwm2m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # | ||
| # Copyright (c) 2017 Linaro | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
|
|
||
| include $(ZEPHYR_BASE)/samples/net/common/Makefile.common | ||
|
|
||
| obj-y = lwm2m-client.o |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok but why is this patch part of lwm2m patchset? You probably want to send this patch in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it here so testers could pull this as a part of the PR to test LWM2M. I will definitely submit this separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as it is in its commit, I do not think it make sense to create another PR, the commit is needed here, so it should be part of this PR, lets not go into this please, it is enough to have commits separated and have PRs be more inclusive and allow coverage of major features that touch different parts of the system.