# leshan-analysis **Repository Path**: JJput/leshan-analysis ## Basic Information - **Project Name**: leshan-analysis - **Description**: leshan代码阅读,并注解 - **Primary Language**: Unknown - **License**: EPL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2021-09-17 - **Last Updated**: 2025-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![Leshan](https://eclipse.org/leshan/img/multicolor-leshan.png) [Eclipse Leshan™](https://eclipse.org/leshan) is an OMA Lightweight M2M server and client Java implementation. [What is OMA LWM2M ?](https://omaspecworks.org/what-is-oma-specworks/iot/lightweight-m2m-lwm2m/) [Object and Resource Registry](http://www.openmobilealliance.org/wp/OMNA/LwM2M/LwM2MRegistry.html). 拆解leshan项目笔记,为了方便理解,在相关代码处加上了相关知识点注释。 仅供参考!! LeshanServerDemo ----------------------- ![](https://jjput-halo.oss-cn-guangzhou.aliyuncs.com/markdown20210917170621.png) LeshanServerDemo main中主要对LeshanServer(coap关键实现)和JettyServer(容器服务)进行初始化配置 。 JmDNS应该是用来实现局域网组网的。 下面详细拆解一下LeshanServer&JettyServer具体都做了些什么 ### LeshanServer * coap config配置:这就不解释了,来用leshan的应该都是冲coap的吧 * DTLS config配置:DTLS是运行于UDP协议之上的安全通信协议,详情可以看书密码技术与物联网安全mbedtls开发实战(徐凯 崔红鹏) 附上PDF:https://www.ixiera.com/uploads/soft/210730/1-210I0112S3.pdf * Model init:这里的模型,应该是各种数据模型,比如:温度模型,规定了上下限值,以及随机数据规则等。 ### JettyServer 本地leshan演示 ----------------------- Get and run the last binary of our demo **server** : ``` wget https://ci.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar java -jar ./leshan-server-demo.jar ``` Get and run the last binary of our demo **client** : ``` wget https://ci.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-client-demo.jar java -jar ./leshan-client-demo.jar ``` Get and run the last binary of our **bootstrap** demo server : ``` wget https://ci.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-bsserver-demo.jar java -jar ./leshan-bsserver-demo.jar ``` :information_source: : _All the demos have a `--help` option._ Compile Leshan & Run Demos ------------- Get sources : ```bash #using ssh git clone git@github.com:eclipse/leshan.git ``` or ``` #using https git clone https://github.com/eclipse/leshan.git ``` Compile it, by running in leshan root folder : ``` mvn clean install ``` Run demo **server**: ``` java -jar leshan-server-demo/target/leshan-server-demo-*-SNAPSHOT-jar-with-dependencies.jar ``` Connect on Leshan demo UI: http://localhost:8080 Leshan server Demo provides a very simple UI to get the list of connected clients and interact with clients resources. Now you can register a LWM2M client by running our **client** demo: ``` java -jar leshan-client-demo/target/leshan-client-demo-*-SNAPSHOT-jar-with-dependencies.jar ``` or trying the [Eclipse Wakaama](http://eclipse.org/wakaama) test client. You can also try our **bootstrap** demo server: ``` java -jar leshan-bsserver-demo/target/leshan-bsserver-demo-*-SNAPSHOT-jar-with-dependencies.jar ``` Let's start to code ! --------------------- Now you played a bit with our demo, you should start to code your own server or client using our [Getting-started](https://github.com/eclipse/leshan/wiki/Getting-started) guide.