iot.list.js 544 B

123456789101112131415161718192021222324
  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. //Return the value as JSON string
  12. HTTP_HEADER = "application/json; charset=utf-8";
  13. sendResp(JSON.stringify(deviceList));
  14. }else{
  15. sendResp("IoT Manager not ready");
  16. }
  17. }
  18. //Run the main function
  19. main();