Giter Club home page Giter Club logo

exbee's Introduction

Exbee

Communicate with XBee wireless radios in Elixir.

Installation

Add exbee to your list of dependencies in mix.exs:

def deps do
  [{:exbee, "~> 0.1.0"}]
end

Usage

Exbee assumes that XBee modules are set to API mode. In API mode, XBee modules send and receive commands via encoded frames.

Discover attached serial ports

iex> Exbee.serial_ports()
%{
  "COM1" => %{description: "USB Serial", manufacturer: "FTDI", product_id: 1, vendor_id: 2},
  "COM2" => %{...},
  "COM3" => %{...}
}

Start an Exbee process

Frames are sent via the Exbee.send_frame/2 function. Frames received on the serial port are reported as messages to the current process. The messages have the form: {:exbee, frame}

This example starts an Exbee process and sends an Exbee.ATCommandFrame to change the value of the NJ parameter. Upon receiving the command, the XBee module will return an Exbee.ATCommandResultFrame indicating the status of the request.

iex> {:ok, pid} = Exbee.start_link(serial_port: "COM1", speed: 9600)
iex> Exbee.send_frame(pid, %Exbee.ATCommandFrame{command: "NJ", value: 1})
:ok

iex> flush()
{:exbee, %Exbee.ATCommandResultFrame{command: "NJ", status: :ok, value: ...}}

Configuration

Exbee options can either be passed directly to Exbee.start_link/1, or they'll be read from :exbee config values. For example, to default to a specific serial port, add this to the project's config.exs file.

config :exbee,
  serial_port: "COM1"

The following options are available:

  • :serial_port - The serial interface connected to the Xbee device.
  • :speed - (number) set the initial baudrate (e.g., 115200)
  • :data_bits - (5, 6, 7, 8) set the number of data bits (usually 8)
  • :stop_bits - (1, 2) set the number of stop bits (usually 1)
  • :parity - (:none, :even, :odd, :space, or :mark) set the parity. Usually this is :none. Other values:
    • :space means that the parity bit is always 0
    • :mark means that the parity bit is always 1
  • :flow_control - (:none, :hardware, or :software) set the flow control strategy.

Mix Tasks

  • mix exbee.serial_ports - List available serial ports
  • mix exbee.at.options - List available configuration options
  • mix exbee.at.query - Query configuration values. Options: [command --serial-port]
  • mix exbee.at.set - Set a configuration value. Options: [command=value --serial-port]

License

This software is licensed under the Apache 2 License.

exbee's People

Contributors

cdmwebs avatar folo23 avatar rigers avatar rockwood avatar

Watchers

 avatar  avatar  avatar  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.