Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connman-simplified

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connman-simplified

Node.js package that simplifies Connman (Opensource connection manager) usage. Uses connman-api.

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Connman simplified

Node.js package that simplifies Connman (Opensource connection manager) usage.
Enables you to easilly control connections over wifi and ethernet. Get realtime status changes.
Uses Connman-api package internally.
Connman: http://www.connman.net/

  • Abstracts Connman API making your code shorter and simpler.
  • Includes network cache system (for when scanning is impossible in hotspot mode).
  • Uses regular Node.js naming conventions.

Examples

Try to connect to favorite wifi network, if fails become hotspot. Log the wifi state changes.

var connman = require('connman-simplified')();
connman.init(function(err) {
  connman.initWiFi(function(err,wifi,properties) {
  
    if(!properties.connected) { // not yet connected? 
      wifi.joinFavorite(function(err) {
        if(err) wifi.openHotspot();
      });
    }
    wifi.on('state',function(value) {
      console.log("WiFi state change: ",value);
    });
    
  });
});

Join specific network, disconnect after 5 seconds.

var connman = require('connman-simplified')();
connman.init(function(err) {
  connman.initWiFi(function(err,wifi,properties) {
  
    wifi.join("myhomenetwork",'myPassphrase');
    
    setTimeout(function() {
      wifi.disconnect();
    },5000);
    
  });
});

Open a hotspot, get cached available networks, close after 5 seconds, get fresh available networks. Retrieving networks from cache is usefull because usually hardware can't scan while being hotspot.

var connman = require('connman-simplified')();
connman.init(function(err) {
  connman.initWiFi(function(err,wifi,properties) {
    
    wifi.openHotspot("myhotspot","aPassphrase",function(err) {
      // get cached available networks (collected earlier)
      wifi.getNetworksCache(function(err,list) {
        console.log("networks from cache: ",list);
      });
      
      setTimeout(function() {
        wifi.closeHotspot(function(err) {
          // get fresh available networks
          wifi.getNetworks(function(err,list) {
            console.log("networks: ",list);
          });
        });
      },5000);
    });
    
  });
});

Get a more readable networks list.
Uses common Connman services format, see: https://01.org/connman/documentation

var connman = require('connman-simplified')();
connman.init(function(err) {
  connman.initWiFi(function(err,wifi,properties) {
    
    wifi.getNetworks(function(err,list) {
      // get more readable list using getServicesString:
      console.log("networks: ",wifi.getServicesString(list));
    });
    
  });
});

Bigger interactive example is included.

Debugging

Uses Debug package, to see all logs run:

$export DEBUG=*

License

Licensed under the MIT License

Author

Peter Uithoven @ Doodle3D

Keywords

FAQs

Package last updated on 18 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc