Device

Function

IdentifyInfoByKey

Kiểm tra thiết bị với key tương ứng có tồn tại trong dự án hay không. Trả về DeviceInfo

Device().IdentifyInfoByKey({key: string})
Ví dụ
let res = await Device().IdentifyInfoByKey({ key: '0000000'});
if (res.success){
  // Thiết bị tồn tại 
  let deviceInfo = res.data;
}else{
  // Thiết bị không tồn tại
}

IdentifyInfoByKeyWithAd

Kiểm tra thiết bị với thông tin key, projectId có tồn tại hay không. Trả về DeviceInfo

Device().IdentifyInfoByKeyWithAd({key: string, projectId: string})
Ví dụ
let res = await Device().IdentifyInfoByKeyWithAd({ key: '0000000', projectId: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'});
if (res.success){
  // Thiết bị tồn tại
  let deviceInfo = res.data;
}else{
  // Thiết bị không tồn tại
}

CreateDevice

Tạo thiết bị với các thông tin tương ứng, trường name bắt buộc, còn lại có thể để trống. Nếu tìm thấy trả về DeviceInfo, nếu không Throw Exception

Device().CreateDevice({name: string, key: string, templateId: string, orgId: string, groupId: string})

Có thể dùng trường key để lưu định danh thiết bị (imei, serial,...)

Ví dụ
let createDevice = await Device().CreateDevice({ name: 'new_device', key: '00000');
if (createDevice.success){
  // Tạo thiết bị thành công
  let deviceInfo = createDevice.data;
}else{
  // Tạo thiết không bị thành công
}

IdentifyInfo

Tìm thiết bị với id tương ứng. Nếu tìm thấy trả về DeviceInfo, nếu không Throw Exception

Device().IdentifyInfo({id: string})
Ví dụ
let res = await Device().IdentifyInfo({id: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'})
if (res.success){
  // Thiết bị tồn tại
  deviceInfo = res.data;
}else{
  // Thiết bị không tồn tại
}

Type

DeviceInfo

{
    id: string,
    name: string,
    owner: string,
    group: string,
    groupname: string,
    type: string,
    typename: string,
    status: string,
    metadata: Uint8Array | string,
    variablesList: Array<string>,
    orgid: string,
    orgname: string,
    createby: string,
    projectid: string,
    templateid: string,
    key: string,
    thingid: string,
    handlemsgsvc: string,
    additionalinfo: Uint8Array | string,
}

Last updated