Git Product home page Git Product logo

gofi's Introduction

gofi

gofi provides a super simple API for sending and receiving data-link packets over WiFi.

Supported Platforms

Right now, gofi is only supported on OS X. This will surely change soon, as I plan to write an implementation for Linux.

Usage

NOTE: you can find full documentation on Godoc.

To start transferring data over a WiFi device, you must create a Handle. For example:

handle, err := gofi.NewHandle("en1")

If you do not know the interface name for your WiFi device ahead of time, gofi gives you an easy way to figure it out:

name, err := gofi.DefaultInterfaceName()
if err != nil {
    // The system has no default WiFi defice!!!
    panic("do something here")
}
handle, err := gofi.NewHandle(name)

Since WiFi communications can take place on any number of channels, you will most likely want to hop channels immediately. You can do this using the SetChannel function:

handle.SetChannel(gofi.Channel{Number: 11})

Once you're tuned into a channel, you can receive packets using the Receive function. For example:

for {
	frame, radio, err := handle.Receive()
	if err != nil {
        // Could not read any more data! Maybe the device was unplugged.
		break
	}
	sourceMACAddress := frame[4:10]
	fmt.Println("got", len(frame), "bytes on frequency", radio.Frequency,
        "MHz", "from MAC", sourceMACAddress)
}

Sending packets is simple as well, but crafting the packets is up to you!

frame := gofi.Frame("\x80\x00\x00...")
if err := handle.Send(frame, 0); err != nil {
    // Could not send the packet! Did you remember to compute the trailing checksum?
}

gofi's People

Contributors

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