iot.scan.js 461 B

123456789101112131415161718192021
  1. //IoT Scanner
  2. //This agi script force the IoT Manager to update the IoT scan results
  3. //Require the iot lib
  4. requirelib("iot");
  5. function main(){
  6. //Check if the IoT Controller is ready
  7. if (iot.ready() == true){
  8. var deviceList = iot.scan();
  9. //Return the value as JSON string
  10. sendResp(deviceList.length + " IoT devices discovered. Run iot.list.js to see the list.");
  11. }else{
  12. sendResp("IoT Manager not ready");
  13. }
  14. }
  15. //Run the main function
  16. main();