iplayabc-speaker-iot-sdk
v1.1.10
Published
Downloads
642
Readme
Huaweicloud & Azure Speaker IOT SDK
const platform = new CloudPlatform({
AK: process.env.AK,
SK: process.env.SK,
ENDPOINT: process.env.IOT_END_POINT,
APP_ID: process.env.APP_ID,
PRODUCT_ID: process.env.PRODUCT_ID,
PROJECT_ID: process.env.PROJECT_ID,
IAM_ENDPOINT: process.env.IAM_ENDPOINT,
IAM_USER: process.env.IAM_USER,
IAM_PWD: process.env.HUAWEI_IAM_PWD,
IAM_DOMAIN_ID: process.env.IAM_DOMAIN_ID,
IAM_DOMAIN_NAME: process.env.IAM_DOMAIN_NAME,
})
deviceId = 'my-device-v1-1234567890';
let deviceInfo = await platform.getDevice(deviceId)
// remove device if exists
if (deviceInfo!=null) {
await platform.removeDevice(deviceId)
deviceInfo = await platform.getDevice(deviceId)
}
// device should not exist
chai.expect(deviceInfo).to.be.null
// create device
const password = await platform.createDeviceWithToken({
deviceId
})
// password should be a string
chai.expect(password).to.be.a('string');
// get device info
deviceInfo = await platform.getDevice(deviceId)
// device should exist
chai.expect(deviceInfo).to.not.be.null
// remove device
const removed = await platform.removeDevice(deviceId)
chai.expect(removed).to.be.true
// device should not exist
deviceInfo = await platform.getDevice(deviceId)
chai.expect(deviceInfo).to.be.null