From cc7185dafa8f76fa2885f411b98c95eb98fe0fea Mon Sep 17 00:00:00 2001 From: "burols.wang" Date: Wed, 27 Nov 2024 09:45:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=20(lwm2m>):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=B5=8B=E8=AF=95=E9=AA=8C=E8=AF=81=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E6=8C=81=E5=B9=B3=E5=8F=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 固件版本: N 是否需要文案翻译: 否 Signed-off-by: burols.wang --- docs/API_reference/en/networklib/Lwm2m.md | 5 ++--- docs/API_reference/zh/networklib/Lwm2m.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/API_reference/en/networklib/Lwm2m.md b/docs/API_reference/en/networklib/Lwm2m.md index 64c1750e..6a282f5e 100644 --- a/docs/API_reference/en/networklib/Lwm2m.md +++ b/docs/API_reference/en/networklib/Lwm2m.md @@ -192,9 +192,8 @@ Returns 0 for success, -1 for failure. To remove an already registered callback | Supported Platform | Remarks | | ------------------ | ------------------------------------------------------------- | -| EC600UEU_AC | Standard version not supported, customized versions supported | -| BG95M8 | | -| BG95M3 | | +| EC200UEU_AB | Standard version not supported, customized versions supported | +| BG95M8 | Standard version not supported, customized versions supported | | EC200AAU_HA | | | EG915NEA_AC | Standard version not supported, customized versions supported | | EG912NEN_AA | | diff --git a/docs/API_reference/zh/networklib/Lwm2m.md b/docs/API_reference/zh/networklib/Lwm2m.md index 6cf503d8..a6afac13 100644 --- a/docs/API_reference/zh/networklib/Lwm2m.md +++ b/docs/API_reference/zh/networklib/Lwm2m.md @@ -192,9 +192,8 @@ lwm2m.register_call(usrfun) | 支持平台 | 备注 | | ----------- | ------------ | -| EC600UEU_AC | 公版不支持,定制型号支持 | -| BG95M8 | | -| BG95M3 | | +| EC200UEU_AB | 公版不支持,定制型号支持 | +| BG95M8 | 公版不支持,定制型号支持 | | EC200AAU_HA | | | EG915NEA_AC | 公版不支持,定制型号支持 | | EG912NEN_AA | | -- Gitee From 6d067c41489ccc5135dab2b6a6951e29f61c0124 Mon Sep 17 00:00:00 2001 From: "burols.wang" Date: Wed, 27 Nov 2024 09:45:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=20(lwm2m>):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=B5=8B=E8=AF=95=E9=AA=8C=E8=AF=81=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E6=8C=81=E5=B9=B3=E5=8F=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 固件版本: N 是否需要文案翻译: 否 Signed-off-by: burols.wang --- docs/API_reference/en/networklib/Lwm2m.md | 5 ++--- docs/API_reference/zh/networklib/Lwm2m.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/API_reference/en/networklib/Lwm2m.md b/docs/API_reference/en/networklib/Lwm2m.md index 64c1750e..6a282f5e 100644 --- a/docs/API_reference/en/networklib/Lwm2m.md +++ b/docs/API_reference/en/networklib/Lwm2m.md @@ -192,9 +192,8 @@ Returns 0 for success, -1 for failure. To remove an already registered callback | Supported Platform | Remarks | | ------------------ | ------------------------------------------------------------- | -| EC600UEU_AC | Standard version not supported, customized versions supported | -| BG95M8 | | -| BG95M3 | | +| EC200UEU_AB | Standard version not supported, customized versions supported | +| BG95M8 | Standard version not supported, customized versions supported | | EC200AAU_HA | | | EG915NEA_AC | Standard version not supported, customized versions supported | | EG912NEN_AA | | diff --git a/docs/API_reference/zh/networklib/Lwm2m.md b/docs/API_reference/zh/networklib/Lwm2m.md index 6cf503d8..a6afac13 100644 --- a/docs/API_reference/zh/networklib/Lwm2m.md +++ b/docs/API_reference/zh/networklib/Lwm2m.md @@ -192,9 +192,8 @@ lwm2m.register_call(usrfun) | 支持平台 | 备注 | | ----------- | ------------ | -| EC600UEU_AC | 公版不支持,定制型号支持 | -| BG95M8 | | -| BG95M3 | | +| EC200UEU_AB | 公版不支持,定制型号支持 | +| BG95M8 | 公版不支持,定制型号支持 | | EC200AAU_HA | | | EG915NEA_AC | 公版不支持,定制型号支持 | | EG912NEN_AA | | -- Gitee From 16a4b53f4cec6b9f1797e76bdc80ab6f0d5f6f0c Mon Sep 17 00:00:00 2001 From: "burols.wang" Date: Fri, 29 Nov 2024 13:57:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=20(lwm2m):=20=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E7=A4=BA=E4=B8=8D=E6=98=8E=E6=98=BE?= =?UTF-8?q?=EF=BC=8C=E5=8D=95=E7=8B=AC=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=8F=90=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 固件版本: N 是否需要文案翻译: 否 Signed-off-by: burols.wang --- docs/API_reference/en/networklib/Lwm2m.md | 1 + docs/API_reference/zh/networklib/Lwm2m.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/API_reference/en/networklib/Lwm2m.md b/docs/API_reference/en/networklib/Lwm2m.md index 6a282f5e..5ca68b09 100644 --- a/docs/API_reference/en/networklib/Lwm2m.md +++ b/docs/API_reference/en/networklib/Lwm2m.md @@ -221,4 +221,5 @@ The event types may vary slightly across platforms, for example, some platforms | +QLWURC: "lifetime_changed",lifetime | Lifetime issued by LWM2M. | | | +QLWURC: "current_time_changed",data_time | Data time issued by LWM2M with UTC_OFFSET. | | --- +## Get example *[Click to view example code.](https://github.com/QuecPython/examples/tree/main/network-comm/net-protocols/lwm2m/example_lwm2m.py)* diff --git a/docs/API_reference/zh/networklib/Lwm2m.md b/docs/API_reference/zh/networklib/Lwm2m.md index a6afac13..7f4edb6c 100644 --- a/docs/API_reference/zh/networklib/Lwm2m.md +++ b/docs/API_reference/zh/networklib/Lwm2m.md @@ -221,4 +221,5 @@ lwm2m.register_call(usrfun) | +QLWURC: "lifetime_changed",lifetime | LWM2M下发的lifetime。 | | | +QLWURC: "current_time_changed",data_time | LWM2M下发的data_time加UTC_OFFSET。 | | --- +## 获取示例代码 *[点击下载示例代码](https://github.com/QuecPython/examples/tree/main/network-comm/net-protocols/lwm2m/example_lwm2m.py)* -- Gitee From e6f969682c5508262bf3a9cd438bfe83e5c120f5 Mon Sep 17 00:00:00 2001 From: "burols.wang" Date: Sat, 7 Dec 2024 17:20:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=20(lwm2m):=20=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E5=87=BA=E7=9A=84=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 固件版本: N 是否需要文案翻译: 否 Signed-off-by: burols.wang --- docs/API_reference/en/networklib/Lwm2m.md | 137 +++++++++--------- docs/API_reference/zh/networklib/Lwm2m.md | 160 +++++++++++----------- 2 files changed, 143 insertions(+), 154 deletions(-) diff --git a/docs/API_reference/en/networklib/Lwm2m.md b/docs/API_reference/en/networklib/Lwm2m.md index 5ca68b09..80c10258 100644 --- a/docs/API_reference/en/networklib/Lwm2m.md +++ b/docs/API_reference/en/networklib/Lwm2m.md @@ -1,6 +1,10 @@ # LWM2M - Lightweight M2M (Machine to Machine) - ## Create Object +The lightweight IoT protocol provides functionality for managing devices on a cloud platform, such as checking device online status, monitoring current signal conditions, restarting devices, and more. + +>The following models support this module function. For customized functions,please refer to the actual features: +> +>EC200UEU_AB_SANX/BG95M8_SANX/EC200AAU_HA_SANX/EG912NEN_AA. ### `lwm2m` @@ -8,153 +12,149 @@ lw=lwm2m() ``` +Create LwM2M object. + **Parameter Description:** No parameters. - - **Return Value Description:** Returns the lwm2m object. ## Initialize Object -### `init` +### `lwm2m.init` ```python lwm2m.init() ``` +Initialize the object. + **Parameter Description:** No parameters. - - **Return Value Description:** Returns an integer value of 0 for success, and an integer value of -1 for failure. ## Configure Object -### `config` +### `lwm2m.config` ```python lwm2m.config(config_type,config_list) ``` -**Parameter Description:** - -* `config_type` - Configuration type, an enumerated value under the lwm2m object, see Table 1 below. -* `config_list` - List of configuration parameters, list data type, list element values are explained in Table 2 below. - - - -**Return Value Description:** +Configure functional module parameters. -Returns an integer value of 0 for success, an integer value of -1 for failure, and an integer value of -2 for unsupported operations. +**Parameter Description:** -
Table 1
+* `config_type` - Configuration type, an enumerated value under the lwm2m object, see below. | Configuration Type | Corresponding config_list Parameter | Remarks | | ------------------ | ------------------------------------------------------------------- | ------------------------------ | -| Epnamemode | [mode] | | -| Reset | [] | Empty list | -| Security | [serverID,SSID,server_addr,bootstrap,security_mode,psk_id,psk_key] | | -| Server | [serverID,life_time,pmin,pmax,disable_timeout,storing,binding_mode] | | -| Urc | [URC_onoff] | Must be enabled to capture URC | -| Fota | [download,update] | Capture URC in manual mode. | +| lwm2m.Epnamemode | [mode] | | +| lwm2m.Reset | [] | Empty list | +| lwm2m.Security | [serverID,SSID,server_addr,bootstrap,security_mode,psk_id,psk_key] | | +| lwm2m.Server | [serverID,life_time,pmin,pmax,disable_timeout,storing,binding_mode] | | +| lwm2m.Urc | [URC_onoff] | Must be enabled to capture URC | +| lwm2m.Fota | [download,update] | Capture URC in manual mode. | -
Table 2
+* `config_list` - List of configuration parameters, list data type, list element values are explained in below. | Field Name | Data Type | Field Description | | --------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| serverID | Integer | 0 Bootstrap server
1 DM server
| -| SSID | Integer | 100 Bootstrap server
1000 Diagnostics server
| +| serverID | Integer | 0 - Bootstrap server
1 - DM server
| +| SSID | Integer | 100 - Bootstrap server
1000 - Diagnostics server
| | server_addr | String | Server address in the format "address", maximum length 256. | -| bootstrap | Integer | 0 Do not use bootstrap (only when serverID is not 0)
1 Use bootstrap (only when serverID is 0) | -| security_mode | Integer | Encryption method:
0 Pre-shared key mode
3 No security mode | +| bootstrap | Integer | 0 - Do not use bootstrap (only when serverID is not 0)
1 - Use bootstrap (only when serverID is 0) | +| security_mode | Integer | Encryption method:
0 - Pre-shared key mode
3 - No security mode | | psk_id | String | Used when security_mode is 0 | | psk_key | String | Used when security_mode is 0 | | life_time | Integer | Lifetime, range 1-86400, default is 86400, in seconds. | | pmin | Integer | Default pmin period, range 1-86400, default is 86400, in seconds. | | pmax | Integer | Default pmax period, range 1-86400, default is 86400, in seconds. | -| disable_timeout | Integer | Time interval before the next connection after disconnection from LwM2M server. Range 1-86400, default is 86400, in seconds. | +| disable_timeout | Integer | Time interval before the next connection after disconnection from lwm2m server. Range 1-86400, default is 86400, in seconds. | | storing | Integer | Whether to save server information:
0 Do not save
1 Save | -| binding_mode | String | Binding mode with the server:
"U" - UDP mode
"UQ" - UDP with queue mode
"S" - SMS mode
"SQ" - SMS with queue mode
"US" - UDP and SMS mode
"UQS" - UDP and SMS with queue mode | -| mode | Integer | Terminal device name format:
3 Format: urn:imei
lwm2mserver configured epname format | -| download | Integer | Download mode:
0 Manual download
1 Automatic download | -| update | Integer | Update mode:
0 Manual update
1 Automatic update | -| URC_onoff | Integer | Enable/Disable URC reporting for LwM2M:
0 Disable URC reporting
1 Enable URC reporting | +| binding_mode | String | Connection method to the server, currently only supporting UDP-based connection
"U" - UDP mode
"UQ" - UDP with queue mode
"S" - SMS mode
"SQ" - SMS with queue mode
"US" - UDP and SMS mode
"UQS" - UDP and SMS with queue mode | +| mode | Integer | Terminal device name format:
3 - Format: urn:imeixxxxx,lconfigured epname format | +| download | Integer | Download mode:
0 - Manual download
1 - Automatic download | +| update | Integer | Update mode:
0 - Manual update
1 - Automatic update | +| URC_onoff | Integer | Enable/Disable URC reporting for lwm2m:
0 - Disable URC reporting
1 - Enable URC reporting | + +**Return Value Description:** +Returns an integer value of 0 for success, an integer value of -1 for failure, and an integer value of -2 for unsupported operatio ## Register -### `register` +### `lwm2m.register` ```python lwm2m.register() ``` +Send a login request to the LwM2M server. The result of the login, whether successful or failed, will be sent through a callback function with the login success message. + **Parameter Description:** No parameters. - - **Return Value Description:** Returns 0 for success, -1 for failure. The registration result requires calling the query interface to check. ## Unregister -### `unregister` +### `lwm2m.unregister` ```python lwm2m.unregister() ``` +Send a logout request to the LwM2M server. The result, whether successful or failed, will be notified through a callback function. + **Parameter Description:** No parameters. - - **Return Value Description:** Returns 0 for success, -1 for failure. The unregister result requires calling the query interface to check. ## Query Registration Status -### `stat` +### `lwm2m.stat` ```python lwm2m.stat() ``` +Query the current login status. + **Parameter Description:** No parameters. - - **Return Value Description:** Returns an integer value of 0 for 'Not Registered' status, 1 for 'Registering' status, 2 for 'Registered' status, 3 for 'Deregistering' status, and 4 for 'Login Failed' status. ## Send Heartbeat -### `update` +### `lwm2m.update` ```python -lwm2m.update(SSID) +lwm2m.update(ssid) ``` +Send a heartbeat packet to the LwM2M server. There is an automatic heartbeat process internally, and it is not recommended to call this interface manually. + **Parameter Description:** -* `SSID` - Configured SSID or the SSID issued during BS login in the bootstrap stage, integer value. - - +* `ssid` - Configured ssid or the ssid issued during BS login in the bootstrap stage, integer value. **Return Value Description:** @@ -162,12 +162,14 @@ Returns 0 for success, -1 for failure. The result of the update is notified thro ## Register Callback Function -### `register_call` +### `lwm2m.register_call` ```python lwm2m.register_call(usrfun) ``` +Register a callback function. This callback function will notify the upper-layer application of the login result and messages sent by the server. + **Parameter Description:** * `usrfun` - The callback function to be set, which is called when the server responds. @@ -182,21 +184,10 @@ lwm2m.register_call(usrfun) | list[1] | Integer | Event code (can be ignored) | | list[2] | Integer | Captured URC string data (specific event description can be found in [Event-Description](#Event-Description), used to determine the connection event of Lwm2m. | - - **Return Value Description:** Returns 0 for success, -1 for failure. To remove an already registered callback function, pass in None. -## Supported Platforms - -| Supported Platform | Remarks | -| ------------------ | ------------------------------------------------------------- | -| EC200UEU_AB | Standard version not supported, customized versions supported | -| BG95M8 | Standard version not supported, customized versions supported | -| EC200AAU_HA | | -| EG915NEA_AC | Standard version not supported, customized versions supported | -| EG912NEN_AA | | ## Event-Description @@ -205,21 +196,23 @@ The event types may vary slightly across platforms, for example, some platforms | Event Type | Description | Remarks | | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | +QLWURC: "pdp active",result,APN | Result of PDP activation. Before sending the registration request to LwM2M, the PDP server should be activated. | result: string type
"successfully"
"failed"
APN: string type
APN value | -| +QLWURC: "initial",result,SSID | Initialization result when the client connects to the LwM2M server. | result: string type
"successfully"
"failed"
SSID: integer type
0 - All servers
Other values - Specific servers | +| +QLWURC: "initial",result,SSID | Initialization result when the client connects to the lwm2m server. | result: string type
"successfully"
"failed"
SSID: integer type
0 - All servers
Other values - Specific servers | | +QLWURC: "dtls",result,SSID | DTLS handshake result when using encryption. | Same as above | | +QLWURC: "bootstraping" | Reports this URC when the bootstrap process is active. | | | +QLWURC: "bootstrap",result,SSID | Result of the Bootstrap process. | Same as above | -| +QLWURC: "registering" | Reports this URC when the client is registering with the LwM2M server. | Same as above | -| +QLWURC: "ready",result,SSID | Result of registration request sent to the LwM2M server. | Same as above | -| +QLWURC: "update",result,SSID | Result of update request sent to the LwM2M server. | Same as above | -| +QLWURC: "deregister",SSID,code
+QLWURC: "deregister",code | Result of the deregistration request sent to the LwM2M server. | SSID: integer type
0 - All servers
Other values - Specific servers
Code: integer
0 - Success
1 - Failure
3 - Unknown Error | -| +QLWURC: "fota/pkgurl",url | URL address issued by LWM2M. | | -| +QLWURC: "apn_changed",APN | APN value issued by LWM2M. | | -| +QLWURC: "user_name_changed",user | User name issued by LWM2M. | | -| +QLWURC: "secret_changed",password | Password issued by LWM2M. | | -| +QLWURC: "authentication_type_changed", | Authentication type issued by LWM2M. | | -| +QLWURC: "lifetime_changed",lifetime | Lifetime issued by LWM2M. | | -| +QLWURC: "current_time_changed",data_time | Data time issued by LWM2M with UTC_OFFSET. | | +| +QLWURC: "registering" | Reports this URC when the client is registering with the lwm2m server. | Same as above | +| +QLWURC: "ready",result,SSID | Result of registration request sent to the lwm2m server. | Same as above | +| +QLWURC: "update",result,SSID | Result of update request sent to the lwm2m server. | Same as above | +| +QLWURC: "deregister",SSID,code
+QLWURC: "deregister",code | Result of the deregistration request sent to the lwm2m server. | SSID: integer type
0 - All servers
Other values - Specific servers
Code: integer
0 - Success
1 - Failure
3 - Unknown Error | +| +QLWURC: "fota/pkgurl",url | The URL address sent by the lwm2m server. | | +| +QLWURC: "apn_changed",APN | The APN sent by the lwm2m server. | | +| +QLWURC: "user_name_changed",user | The user name sent by the lwm2m server. | | +| +QLWURC: "secret_changed",password | The password sent by the lwm2m server. | | +| +QLWURC: "authentication_type_changed", | The authentication type sent by the lwm2m server. | | +| +QLWURC: "lifetime_changed",lifetime | The lifetime (heartbeat period) sent by the lwm2m server. | | +| +QLWURC: "current_time_changed",data_time | The timestamp sent by the lwm2m server. | | + --- + ## Get example *[Click to view example code.](https://github.com/QuecPython/examples/tree/main/network-comm/net-protocols/lwm2m/example_lwm2m.py)* diff --git a/docs/API_reference/zh/networklib/Lwm2m.md b/docs/API_reference/zh/networklib/Lwm2m.md index 7f4edb6c..b5c8b15c 100644 --- a/docs/API_reference/zh/networklib/Lwm2m.md +++ b/docs/API_reference/zh/networklib/Lwm2m.md @@ -1,6 +1,10 @@ # lwm2m-轻型物联网 - ## 创建对象 +轻型物联网协议,提供在云平台管理设备的功能,例如检查设备在线状态,观测当前信号情况,重启设备等。 + +>以下型号支持此模块功能,对于定制的功能,根据实际功能为准: +> +>EC200UEU_AB_SANX/BG95M8_SANX/EC200AAU_HA_SANX/EG912NEN_AA。 ### `lwm2m` @@ -8,153 +12,152 @@ lw=lwm2m() ``` +创建lwm2m对象。 + **参数描述:** 无参数。 - - **返回值描述:** 返回lwm2m对象。 + ## 初始化对象 -### `init` +### `lwm2m.init` ```python lwm2m.init() ``` +初始化对象。 + **参数描述:** 无参数。 - - **返回值描述:** 成功返回整型数值0,失败返回整型数值-1。 ## 配置对象 -### `config` +### `lwm2m.config` ```python lwm2m.config(config_type,config_list) ``` -**参数描述:** +配置功能模块参数。 -* `config_type` - 配置类型 ,枚举型,lwm2m对象下的枚举数值,详见表1。 -* `config_list` - 配置参数列表 ,列表数据类型,列表元素值详见表2。 - - - -**返回值描述:** - -成功返回整型数值0,失败返回整型数值-1,不支持返回整型数值-2。 +**参数描述:** -
表1
+* `config_type` - 配置类型 ,枚举型,lwm2m对象下的枚举数值,详见下表。 -| 配置类型名 | 对应的config_list参数 | 备注 | +| 配置类型 | 对应的config_list参数 | 备注 | | ---------- | ------------------------------------------------------------------- | ----------------- | -| Epnamemode | [mode] | | -| Reset | [] | 空list | -| Security | [serverID,SSID,server_addr,bootstrap,security_mode,psk_id,psk_key] | | -| Server | [serverID,life_time,pmin,pmax,disable_timeout,storing,binding_mode] | | -| Urc | [URC_onoff] | 如果要抓取URC,必须配置开启 | -| Fota | [download,update] | 如果要抓取URC,配置成均不自动。 | +| lwm2m.Epnamemode | [mode] | | +| lwm2m.Reset | [] | 空list | +| lwm2m.Security | [serverID,SSID,server_addr,bootstrap,security_mode,psk_id,psk_key] | | +| lwm2m.Server | [serverID,life_time,pmin,pmax,disable_timeout,storing,binding_mode] | | +| lwm2m.Urc | [URC_onoff] | 如果要抓取URC,必须配置开启 | +| lwm2m.Fota | [download,update] | 如果要抓取URC,配置成均不自动 | -
表2
+* `config_list` - 配置参数列表 ,列表数据类型,列表元素值详见下表。 | 字段名 | 字段类型 | 字段说明 | | --------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -| serverID | 整型 | 0 Bootstrap server
1 DM server
| -| SSID | 整型 | 100 Bootstrap server
1000 Diagnostics server
| -| server_addr | 字符串 | 服务器地址,格式为:"address:port",最长支持256。 | -| bootstrap | 整型 | 0 不用bootstrap(仅当serverID不为0)
1 使用bootstrap (仅当serverID为0) | -| security_mode | 整型 | 加密方法:
0 Pre-share key mode
3 No security mode | +| serverID | 整型 | 0 - Bootstrap server
1 - DM server
| +| SSID | 整型 | 100 - Bootstrap server
1000 - Diagnostics server
| +| server_addr | 字符串 | 服务器地址,格式为:"address:port",最长支持256 | +| bootstrap | 整型 | 0 - 不用bootstrap(仅当serverID不为0)
1 - 使用bootstrap (仅当serverID为0) | +| security_mode | 整型 | 加密方法:
0 - Pre-share key mode
3 - No security mode | | psk_id | 字符串 | security_mode为0时有用 | | psk_key | 字符串 | security_mode为0时有用 | | life_time | 整型 | 生存时间,取值范围1~86400,默认值86400,单位秒 | | pmin | 整型 | pmin默认周期,取值范围1~86400,默认值86400,单位秒 | | pmax | 整型 | pmax默认周期,取值范围1~86400,默认值86400,单位秒 | -| disable_timeout | 整型 | 与 LwM2M 服务器断开连接后到下一个连接的时间间隔。范围为 1-86400,默认值为 86400,单位为秒
实测端口后可以立马连接。无效(上送给服务端的,服务端未限制)。 | -| storing | 整型 | 是否保存服务器信息
0.不保存
1.保存 | -| binding_mode | 字符串 | 和服务器连接方式
"U" - UDP方式
"UQ" - UDP有队列模式方式
"S" - SMS方式
"SQ" - SMS有队列模式方式
“US” - UDP和SMS方式
"UQS" - UDP和SMS有队列模式方式 | -| mode | 整型 | 终端设备名字格式
3 格式为: urn:imei:xxxxx
lwm2mserver配置epname格式 | -| download | 整型 | 下载模式
0 手动下载
1 自动下载 | -| update | 整型 | 更新模式
0 手动更新
1 自动更新 | -| URC_onoff | 整型 | 是否开启LWm2m的urc上报
0 禁用URC上报
1 启用URC上报 | +| disable_timeout | 整型 | 与 LwM2M 服务器断开连接后到下一个连接的时间间隔。范围为 1-86400,默认值为 86400,单位为秒
实测断开后可以立刻启动连接,功能无效(上送给服务端的,服务端未限制) | +| storing | 整型 | 是否保存服务器信息
0 - 不保存
1 - 保存 | +| binding_mode | 字符串 | 和服务器连接方式,目前仅支持基于UDP的连接方式
"U" - UDP方式
"UQ" - UDP有队列模式方式
"S" - SMS方式
"SQ" - SMS有队列模式方式
"US" - UDP和SMS方式
"UQS" - UDP和SMS有队列模式方式 | +| mode | 整型 | 终端设备名字格式
3 - 格式为: urn:imei:xxxxx,配置epname格式 | +| download | 整型 | 下载模式
0 - 手动下载
1 - 自动下载 | +| update | 整型 | 更新模式
0 - 手动更新
1 - 自动更新 | +| URC_onoff | 整型 | 是否开启lwm2m的urc上报
0 - 禁用URC上报
1 - 启用URC上报 | + + +**返回值描述:** + +成功返回整型数值0,失败返回整型数值-1,不支持返回整型数值-2。 ## 注册 -### `register` +### `lwm2m.register` ```python lwm2m.register() ``` +向lwm2m服务器发送登录请求,登录成功或失败结果会通过回调函数上送登录成功消息。 + **参数描述:** 无参数 - - **返回值描述:** 执行成功返回0,执行失败返回-1。注册结果需要调用查询接口进行查询。 ## 注销 -### `unregister` +### `lwm2m.unregister` ```python lwm2m.unregister() ``` +向lwm2m服务器发送退出登录请求,成功或失败结果通过回调函数进行通知。 + **参数描述:** 无参数。 - - **返回值描述:** 执行成功返回0,执行失败返回-1。注销结果需要调用查询接口进行查询。 ## 查询注册状态 -### `stat` +### `lwm2m.stat` ```python lwm2m.stat() ``` +查询当前登录状态。 + **参数描述:** 无参数。 - - **返回值描述:** 未注册状态返回整型值0,注册中状态返回整型值1,已注册状态返回整型值2,注销中状态返回整型值3,登录失败状态返回整型值4。 ## 发送心跳 -### `update` +### `lwm2m.update` ```python -lwm2m.update(SSID) +lwm2m.update(ssid) ``` +向lwm2m服务器发送心跳包,内部会有自动心跳流程,不建议主动调用此接口。 + **参数描述:** -* `SSID` - 配置的SSID或者是BS登录阶段BS下发的SSID,整型值。 - - +* `ssid` - 配置的ssid或者是BS登录阶段BS下发的ssid,整型值。 **返回值描述:** @@ -162,12 +165,14 @@ lwm2m.update(SSID) ## 注册回调函数 -### `register_call` +### `lwm2m.register_call` ```python lwm2m.register_call(usrfun) ``` +注册回调函数,此回调函数会通知上层应用登录结果,以及服务器下发的消息。 + **参数描述:** * `usrfun` - 设置消息回调函数,function类型,当服务端响应时触发该方法。 @@ -182,44 +187,35 @@ lwm2m.register_call(usrfun) | list[1] | 整型 | 事件编码(可以不处理忽略) | | list[2] | 整型 | 抓取到的URC字符串数据(具体事件说明请参考[事件说明](#事件说明),以此参数判断Lwm2m的连接事件为准 | - - **返回值描述:** -成功返回0,失败返回-1。注意如果要删除已经注册的回调函数,传入参数None. - -## 支持平台 - -| 支持平台 | 备注 | -| ----------- | ------------ | -| EC200UEU_AB | 公版不支持,定制型号支持 | -| BG95M8 | 公版不支持,定制型号支持 | -| EC200AAU_HA | | -| EG915NEA_AC | 公版不支持,定制型号支持 | -| EG912NEN_AA | | +成功返回0,失败返回-1。注意如果要删除已经注册的回调函数,传入参数None。 ## 事件说明 事件类型不同的平台可能稍有不同,例如APN某些平台没有,不影响功能,不影响使用。 -| 事件类型 | 说明 | 备注 | +| 事件类型 | 说明 | 备注 | | -------------------------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------ | -| +QLWURC: "pdp active",result,APN | PDP的激活结果。在向 LwM2M 发送注册请求之前,应激活 PDP 服务器。 | result:string类型
"successfully"
"failed"
APN:string类型
APN值 | -| +QLWURC: "initial",result,SSID | 客户端与LwM2M服务器连接的初始化结果。 | result:string类型
"successfully"
"failed"
SSID:整型类型
0-所有的服务器
其他值-其他的特殊服务器 | -| +QLWURC: "dtls",result,SSID | 使用加密方法时的 DTLS 握手结果。 | 同上 | -| +QLWURC: "bootstraping" | 当 Bootstrap 工作时,将报告此 URC。 | | -| +QLWURC: "bootstrap",result,SSID | Bootstrap 的工作结果。 | 同上 | -| +QLWURC: "registering" | 当客户端在 LwM2M 服务器上注册时将报告此 URC。 | 同上 | -| +QLWURC: "ready",result,SSID | 向LwM2M服务器发送注册请求后的注册结果。 | 同上 | -| +QLWURC: "update",result,SSID | 向LwM2M服务器发送更新请求后的更新结果。 | 同上 | -| +QLWURC: "deregister",SSID,code
+QLWURC: "deregister",code | 向LwM2M服务器发送注销请求后的注销结果。 | SSID:整型类型
0-所有的服务器
其他值-其他的特殊服务器
Code:整型
0-成功
1-失败
3-未知错误 | -| +QLWURC: "fota/pkgurl",url | LWM2M下发的url地址。 | | -| +QLWURC: "apn_changed",APN | LWM2M下发的APN值。 | | -| +QLWURC: "user_name_changed",user | LWM2M下发的user。 | | -| +QLWURC: "secret_changed",password | LWM2M下发的password。 | | -| +QLWURC: "authentication_type_changed", | LWM2M下发的Authentication。 | | -| +QLWURC: "lifetime_changed",lifetime | LWM2M下发的lifetime。 | | -| +QLWURC: "current_time_changed",data_time | LWM2M下发的data_time加UTC_OFFSET。 | | +| +QLWURC: "pdp active",result,apn | PDP的激活结果。在向lwm2m发送注册请求之前,应激活 PDP 服务器 | result:string类型
"successfully"
"failed"
apn:string类型
APN值 | +| +QLWURC: "initial",result,ssid | 客户端与lwm2m服务器连接的初始化结果 | result:string类型
"successfully"
"failed"
ssid:整型类型
0-所有的服务器
其他值-其他的特殊服务器 | +| +QLWURC: "dtls",result,ssid | 使用加密方法时的DTLS握手结果 | 同上 | +| +QLWURC: "bootstraping" | 当 Bootstrap 工作时,将报告此 URC | | +| +QLWURC: "bootstrap",result,ssid | Bootstrap 的工作结果 | 同上 | +| +QLWURC: "registering" | 当客户端在lwm2m服务器上注册时将报告此 URC | 同上 | +| +QLWURC: "ready",result,ssid | 向lwm2m服务器发送注册请求后的注册结果 | 同上 | +| +QLWURC: "update",result,ssid | 向lwm2m服务器发送更新请求后的更新结果 | 同上 | +| +QLWURC: "deregister",ssid,code
+QLWURC: "deregister",code | 向lwm2m服务器发送注销请求后的注销结果 | ssid:整型类型
0-所有的服务器
其他值-其他的特殊服务器
code:整型
0 - 成功
1 - 失败
3 - 未知错误 | +| +QLWURC: "fota/pkgurl",url | lwm2m服务器下发的url地址 | | +| +QLWURC: "apn_changed",APN | lwm2m服务器下发的apn值 | | +| +QLWURC: "user_name_changed",user | lwm2m服务器下发的用户名 | | +| +QLWURC: "secret_changed",password | lwm2m服务器下发的密码 | | +| +QLWURC: "authentication_type_changed", | lwm2m服务器下发的鉴权方式 | | +| +QLWURC: "lifetime_changed",lifetime | lwm2m服务器下发的存活周期(心跳周期) | | +| +QLWURC: "current_time_changed",data_time | lwm2m服务器下发的时间戳 | | + --- + ## 获取示例代码 + *[点击下载示例代码](https://github.com/QuecPython/examples/tree/main/network-comm/net-protocols/lwm2m/example_lwm2m.py)* -- Gitee