2026-06-26 20b96473f2520590a0dca6b775b81e3ea06a77a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
 
import lombok.extern.slf4j.Slf4j;
import org.eclipse.californium.core.CoapResource;
import org.eclipse.californium.core.server.resources.CoapExchange;
 
/**
 * IoT 网关 CoAP 协议的设备动态注册资源(/auth/register/device)
 * <p>
 * 用于直连设备/网关的一型一密动态注册,不需要认证
 *
 * @author 芋道源码
 */
@Slf4j
public class IotCoapRegisterResource extends CoapResource {
 
    public static final String PATH = "device";
 
    private final IotCoapRegisterHandler registerHandler;
 
    public IotCoapRegisterResource(IotCoapRegisterHandler registerHandler) {
        super(PATH);
        this.registerHandler = registerHandler;
        log.info("[IotCoapRegisterResource][创建 CoAP 设备动态注册资源: /auth/register/{}]", PATH);
    }
 
    @Override
    public void handlePOST(CoapExchange exchange) {
        log.debug("[handlePOST][收到设备动态注册请求]");
        registerHandler.handle(exchange);
    }
 
}