LWM2M - Lightweight M2M (Machine to Machine)
Create Object
lwm2m
lw=lwm2m()
Parameter Description:
No parameters.
Return Value Description:
Returns the lwm2m object.
Initialize Object
init
lwm2m.init()
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(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:
Returns an integer value of 0 for success, an integer value of -1 for failure, and an integer value of -2 for unsupported operations.
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. |
Field Name | Data Type | Field Description |
---|---|---|
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 |
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. |
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 |
Register
register
lwm2m.register()
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()
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()
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(SSID)
Parameter Description:
SSID
- Configured SSID or the SSID issued during BS login in the bootstrap stage, integer value.
Return Value Description:
Returns 0 for success, -1 for failure. The result of the update is notified through the callback function.
Register Callback Function
register_call
lwm2m.register_call(usrfun)
Parameter Description:
usrfun
- The callback function to be set, which is called when the server responds.
回调函数参数
list
- The callback function notification data, list type, described in detail below:
Element | Data Type | Description |
---|---|---|
list[0] | Integer | Event type (can be ignored) |
list[1] | Integer | Event code (can be ignored) |
list[2] | Integer | Captured URC string data (specific event description can be found in 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 |
---|---|
EC600UEU_AC | Standard version not supported, customized versions supported |
BG95M8 | |
BG95M3 | |
EC200AAU_HA | |
EG915NEA_AC | Standard version not supported, customized versions supported |
EG912NEN_AA |
Event-Description
The event types may vary slightly across platforms, for example, some platforms do not have APN, which does not affect functionality or usage.
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: "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. |