GithubHelp home page GithubHelp logo

isabella232 / ebus-connman Goto Github PK

View Code? Open in Web Editor NEW

This project forked from helium/ebus-connman

0.0 0.0 0.0 715 KB

An erlang connman client using ebus

License: Apache License 2.0

Makefile 1.18% Erlang 98.82%

ebus-connman's Introduction

Travis Hex.pm Version Hex.pm License Erlang Versions Build Tool

ebus-connman

The connman application provides an Erlang binding for the connman connection manager.

Features

  • Get current available services
  • Connect to an SSID by name instead of Service ID
  • Notifications on connectivity state changes.

Install

Add ebus-connman to your deps section in rebar.config:

{deps, [connman]}.

To ensure that connman is tarted when your application starts also add it to the applications section in your application's .app.src file. For example:

{application, my_app,
 [{description, "An application using connman"},
  {vsn, "git"},
  {registered, []},
  {applications,
   [kernel,
    stdlib,
    connman
   ]},
  {env,[]}
 ]}.

Examples

Get Services

Here's an example of talking to connman to get the current list of connectivity related technologies:

Eshell V10.1  (abort with ^G)E
1>  {ok, C} = connman:connman()
{ok,<0.221.0>}
2>  connman:services(C).
{ok,[{"/net/connman/service/wifi_a0c589a1baee_425452205570706572204150_managed_psk",
      #{"AutoConnect" => true,
        "Domains" => ["Home"],
        "Domains.Configuration" => [],
        "Ethernet" =>
            #{"Address" => "A0:C5:89:A1:BA:EE","Interface" => "wlp2s0",
              "MTU" => 1500,"Method" => "auto"},
        "Favorite" => true,
        "IPv4" =>
            #{"Address" => "192.168.2.60","Gateway" => "192.168.2.1",
              "Method" => "dhcp","Netmask" => "255.255.255.0"},
        "IPv4.Configuration" => #{"Method" => "dhcp"},
        "IPv6" => #{},
        "IPv6.Configuration" =>
            #{"Method" => "auto","Privacy" => "disabled"},
        "Immutable" => false,"Name" => "BTR Upper AP",
        "Nameservers" => ["192.168.2.1"],
        "Nameservers.Configuration" => [],"Provider" => #{},
        "Proxy" => #{"Method" => "direct"},
        "Proxy.Configuration" => #{},
        "Security" => ["psk"],
        "State" => "online","Strength" => 58,
        "Timeservers" => ["192.168.2.1"],
        "Timeservers.Configuration" => [],"Type" => "wifi",
        "mDNS" => false,"mDNS.Configuration" => false}}]}

State Change Notifications

To get notified when connectivity of the system changes, call register_state_notify. As an example:

Eshell V10.1  (abort with ^G)E
1> {ok, C} = connman:connman()
{ok,<0.221.0>}
2> connman:register_state_notify(self()).
ok

Now when the state of the network changes, the given handler pid will receive a message:

10> flush().
{state_changed, online}

The values for state are the atom versions of the connman connectivity names: offline, idle, ready, online. Refer to the connman documentation for the latestdocumentation on the meaning of the state names.

Connect to an SSID

As an extension of normal connman behavior the API allows connecting to an SSID by name and given a password will block until the connection is established or fails. connman will try to find the given SSID and will attempt to connect to it.

Eshell V10.1  (abort with ^G)E
1> {ok, C} = connman:connman().
{ok,<0.257.0>}
2> connman:connect(C, wifi, "My Access Point", "My AP Password").
ok

Building

Fork the repo and simply use make to build the library.

ebus-connman's People

Contributors

fvasquez avatar madninja avatar vagabond avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.