iot.iconTag.js 750 B

1234567891011121314151617181920212223242526272829
  1. //IoT Scanner
  2. //This agi script will list the manager cached device list. If the list not exists
  3. //It will perform an auto scan instead.
  4. //Require the iot lib
  5. requirelib("iot");
  6. function main(){
  7. //Check if the IoT Controller is ready
  8. if (iot.ready() == true){
  9. //List the iot device in cache
  10. var deviceList = iot.list();
  11. if (deviceList.length == 0){
  12. sendResp("No iot device found");
  13. return;
  14. }
  15. //Get the icon of the first device
  16. var iconTagName = iot.iconTag(deviceList[0].DeviceUUID);
  17. sendResp("Tag icon for this device is: " + iconTagName + "\n" + "Icon image file can be found in SystemAO/iot/hub/img/devices/" + iconTagName + ".png" );
  18. }else{
  19. sendResp("IoT Manager not ready");
  20. }
  21. }
  22. //Run the main function
  23. main();