java获取设备信息_JAVAsdk 获取接入设备信息

代码如下:

public class DeviceDemo {

public static String ACCESS_KEY_ID = "d705dc8058fb47adb14a0b40078bf36e"; // 用户的Access

// Key

// ID

public static String SECRET_ACCESS_KEY = "16ca7c2f2906417da824eed0ad83f44e"; // 用户的Secret

// Access

// Key

public static String ENDPOINT = "347c71eb7f424a4f9c6f552b72eafa41.mqtt.iot.gz.baidubce.com";

public static IotDmClient getIotDmClientHttp() {

// 创建配置

BceClientConfiguration config = new BceClientConfiguration()

.withCredentials(

new DefaultBceCredentials(ACCESS_KEY_ID,

SECRET_ACCESS_KEY)).withEndpoint(ENDPOINT);

config.withProtocol(Protocol.HTTP);

// 初始化一个IotDmClient

IotDmClient client = new IotDmClient(config);

return client;

}

public static IotDmClient getIotDmClientHttps() {

// 创建配置

BceClientConfiguration config = new BceClientConfiguration()

.withProtocol(Protocol.HTTPS) // 使用HTTPS协议

.withCredentials(

new DefaultBceCredentials(ACCESS_KEY_ID,

SECRET_ACCESS_KEY)).withEndpoint(ENDPOINT);

// 初始化一个IotDmClient

IotDmClient client = new IotDmClient(config);

return client;

}

public static List getDevices() {

DeviceAccessDetail detail = getIotDmClientHttp().getDeviceAccessDetail(

"mylight1");

// 获取通信协议,当前为mqtt

String protocol = detail.getProtocol();

// 获取设备接入的IoT Hub endpoint

List endpoints = detail.getEndpoints();

// 获取设备pub到物管理服务的topic信息

List pubTopics = detail.getPubTopics();

// 获取设备sub物管理服务的topic信息

List subTopics = detail.getSubTopics();

// System.out.println(getIotDmClientHttps().getRootGroups());

// DeviceQueryResponse response =

// getIotDmClientHttps().getDeviceProfiles(

// new DeviceQueryRequest().withCondition("{}"));

//

// // 获取设备信息列表

// List profiles = response.getDeviceProfiles();

//

return null;

}

public static void main(String[] args) {

getDevices();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值