IoT中使用云云对接的网关和子设备的自定义配置管理

最近在测试一些问题,需要启动两个网关,所以使用到自定义配置管理,示例代码如下:

bridgeBootstrap = new BridgeBootstrap();

ConfigFactory.init(

        ConfigFactory.getBridgeConfigManager("application-self-1.conf"),

        selfDefineDeviceConfigManager);

private static DeviceConfigManager selfDefineDeviceConfigManager = new DeviceConfigManager() {

    @Override
   public DeviceIdentity getDeviceIdentity(String originalIdentity) {

        System.out.println("DeviceConfigManager, originalIdentity:====="+originalIdentity);

        DeviceIdentity deviceIdentity = null;

        if("demoDevice1"==originalIdentity){

            deviceIdentity = new DeviceIdentity("aaaaaaa","subdevice1","a2fccb945ba4f5b5a8e50b");

        }else if("demoDevice2"==originalIdentity){

            deviceIdentity = new DeviceIdentity("aaaaaaa","subdevice2","db496509fbcd438cc03c2");

        }

        return deviceIdentity;

    }


    @Override
   public String getOriginalIdentity(String productKey, String deviceName) {

        System.out.println("DeviceConfigManager, productKey:====="+productKey);

        System.out.println("DeviceConfigManager, deviceName:====="+deviceName);


        String originalIdentity = null;

        if(deviceName == "subdevice1"){

            originalIdentity = "demoDevice1";

        }else if(deviceName == "subdevice2"){

            originalIdentity = "demoDevice2";

        }

        return originalIdentity;

    }

};


网关信息保存在application-self-1.conf中,挂载的子设备需要在DeviceConfigManager中动态获取。

上一篇:c语言运算符号详细说明


下一篇:编译并调用iot中云端api的pub c++版本