创建账号
中国电信天翼物联网CTWing门户网站
注册好之后在个人中心进行认证,否则无法进行设备相关的操作
进入控制台
认证通过后的账号,左侧菜单比较丰富,因此可以对产品设备操作了
输入验证码 点击开通
之后就可以创建产品,添加设备了
先看效果
控制台添加成功
再在物联网ctw平台 也可以看到记录
下面开始直接附上主要代码
public static void main(String[] args) {String appKey ="***";String appSecret = "****";String masterKey = "****";String productId = "****";CreateDevice createDevice = new CreateDevice();createDevice.setDeviceName("设备1");createDevice.setImei("****");createDevice.setDeviceSn("***");createDevice.setOperator("admin");CreateDeviceOther createDeviceOther = new CreateDeviceOther();createDeviceOther.setImsi("****");createDeviceOther.setPskValue("****");createDeviceOther.setAutoObserver(0);createDevice.setProductId(Integer.valueOf(productId));createDevice.setOther(createDeviceOther);AepDeviceManagementClient client = AepDeviceManagementClient.newClient().appKey(appKey).appSecret(appSecret).build();CreateDeviceRequest request = new CreateDeviceRequest();request.setParamMasterKey(masterKey);request.setBody(JSONObject.toJSONBytes(createDevice));CreateDeviceResponse response = null;try {response = client.CreateDevice(request);System.out.println("response = " + response);} catch (Exception e) {e.printStackTrace();} finally {client.shutdown();}}