MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    [npm library] @bugsounet/internet

    Scheduled Pinned Locked Moved Development
    3 Posts 2 Posters 479 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? Offline
      A Former User
      last edited by

      @bugsounet/internet

      I created this library if you want to check internet connexion in your module.
      This library is very simplified and ready for use in your node_helper.js

      This library is used in MMM-Assistant2Display

      single node routine for checking internet status

      Installation

      npm install @bugsounet/internet
      

      Sample with pir contructor

      const Internet = require("@bugsounet/internet")
      
      this.config = {
        delay: 10 * 1000,
        scan: "google.com",
        command: "pm2 restart 0",
        showAlert: true
      }
      
      var debug = true
      
      this.internet = new Internet(this.config, callback, debug)
      this.internet.start()
      setTimeout(() => { this.internet.stop() } , 60 * 1000)
      
      function callback(status, value) {
        if (status == "INTERNET_PING") console.log ("Ping:", value)
        if (status == "INTERNET_DOWN") console.log ("Conexion lost... Retry:", value)
        if (status == "INTERNET_RESTART") console.log ("Internet is back")
      }
      

      constructor of internet

      internet(internetConfig, callback, debug)

      internetConfig {}
      • delay - set the interval for internet checking.
      • scan - ping point name or address.
      • command - command to execute when internet afresh available
      • showAlert - send a callback Alert about internet connection lost and available
      callback (status,value)
      • INTERNET_PING - return current ping with value
      • INTERNET_DOWN - return internet down status with number of retry in value
      • INTERNET_RESTART- return internet available status

      INTERNET_DOWN and INTERNET_RESTART will be sended only if showAlert feature is enable

      debug

      if you want debuging information, just set to true

      Functions

      • start() : start internet scan
      • stop() : force stop scan
      1 Reply Last reply Reply Quote 1
      • bheplerB Offline
        bhepler Module Developer
        last edited by

        Wow. You’ve been busy.

        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User
          last edited by

          it’s just my personal npm libraries :)

          I have 3 more … but i have to Make readme file (too lazy actually) :p

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy