---
# System prepended metadata

title: LwM2M
tags: [ThingsBoard]

---

---
title: LwM2M
tags: ThingsBoard
---

## LwM2M Configuration
1. upload LwM2M model
2. create a device profile with transport `LwM2M`
	* [detail config](https://thingsboard.io/docs/reference/lwm2m-api/)
3. create a device with LwM2M profile
4. set device credentials ( endpointName )
5. start a bootstrap server using leshan-bsserver-demo
6. add a client configuration ( http://bsDomain:8080 )
	![](https://i.imgur.com/jGtywrt.png)
	* endpointName
		![](https://i.imgur.com/oMB0Qit.png)
	* LwM2M Server ( coap://tbDomain:5685 )
		![](https://i.imgur.com/rHInl0e.png)
	* Bootstrap Server ( coap://bsDomain:5683 )
		![](https://i.imgur.com/cVfkIkd.png)
7. start a client using leshan-client-demo
	* example: 
	```
	java -jar leshan-client-demo-2.0.0-SNAPSHOT-jar-with-dependencies.jar -u coap://bsDomain:5683 -n test -b
	// -u: server url
	// -b: if connect a bootstrap server
	// -n: endpointName
	````

## Reference
[IKEA 也在用的 IoT 協定：LwM2M 簡介與快速入門](https://www.yottau.com.tw/article/194)
[ThingBoard LWM2M Transport API](https://thingsboard.io/docs/reference/lwm2m-api/)
[LwM2M Object and Resource Registry Library](https://github.com/OpenMobileAlliance/lwm2m-registry)
[Java LwM2M library by Eclipse - Leshan](https://github.com/eclipse/leshan)
[C LwM2M library by Eclipse - Wakaama](https://github.com/eclipse-wakaama/wakaama)