doxiego

package module
v0.0.0-...-bdd8ee6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2016 License: MIT Imports: 13 Imported by: 0

README

DoxieGo

DoxieGo is command line tool and Go library to communicate with a Doxie Go Wi-Fi scanner.

Note: This project is not affiliated with Apparent or Doxie.

Installation

go get github.com/umahmood/doxiego
cd $GOPATH/src/github.com/umahmood/doxiego
go test ./...

Usage from the command line

Find Doxie on the network:

$ doxiego -hello
Name: Doxie_0591E0
Model: DX250
Has Password: false
Wi-Fi Firmware: 1.29
MAC: FA-B2-5A-66-EE-94
Mode: AP (Doxies own Wi-Fi network)
URL: http://192.168.1.100:8080/

Display a list of all scans:

$ doxiego -scans
name: IMG_0002.JPG size: 959458 modified: 2010-05-01 00:03:26
name: IMG_0003.JPG size: 941949 modified: 2010-05-01 00:06:44

Delete a list of scans (multiple scan names are comma separated):

$ doxiego -delete img_0002.jpg,img_0003.jpg

Download a scan as a thumbnail:

$ doxiego -get-thumbnail img_0002.jpg
downloaded thumbnail img_0002.jpg

Download a scan:

$ doxiego -get-scan img_0003.jpg
downloaded scan img_0003.jpg

Download all scans:

$ doxiego -get-scans
downloaded scan IMG_0002.JPG
downloaded scan IMG_0003.JPG

For help:

$ doxiego -help

Usage from the API:

See GoDoc for full capability of the API.

package main

import (
    "fmt"

    "github.com/umahmood/doxiego"
)

func main() {
    doxieGo, err := doxiego.Hello()
    if err != nil {
        //...
    }

    fmt.Println("Doxie name", doxieGo.Name)

    // if the scanner has a password set, fill in the password field
    doxieGo.Password = "mypassword"

    // get a list of scanned items on the scanner
    items, err := doxieGo.Scans()
    if err != nil {
        //...
    }
    
    for _, s := range items {
        fmt.Println("name:", s.Name, "size:", s.Size, "modified:", s.Modified)
    }

    // download a scan
    img, err := doxieGo.Scan("img_0001.jpg")
    if err != nil {
        //...
    }
    //...
    jpeg.Encode(file, img, nil)

    // delete scans off the scanner
    ok, err := doxieGo.Delete("img_0001.jpg", "img_0002.jpg")
    if err != nil {
        //...
    } else if ok {
        fmt.Println("scans deleted.")
    }
}

Documentation

http://godoc.org/github.com/umahmood/doxiego

Testing

  • The code base has been tested with a single Doxie Go Wi-Fi scanner, in both AP and Client network modes.

License

See the LICENSE file for license rights and limitations (MIT).

Documentation

Overview

Package doxiego communicates with a Doxie Go scanner.

The below example demonstrates how to use the API to communicate with a Doxie scanner.

package main

import (
    "fmt"

    "github.com/umahmood/doxiego"
)

func main() {
    doxieGo, err := doxiego.Hello()
    if err != nil {
        //...
    }

    fmt.Println("Doxie name", doxieGo.Name)

    // if the scanner has a password set, fill in the password field
    doxieGo.Password = "mypassword"

    // get a list of scanned items on the scanner
    items, err := doxieGo.Scans()
    if err != nil {
        //...
    }

    for _, s := range items {
        fmt.Println("name:", s.Name, "size:", s.Size, "modified:", s.Modified)
    }

    // download a scan
    img, err := doxieGo.Scan("img_0001.jpg")
    if err != nil {
        //...
    }

    jpeg.Encode(file, img, nil)

    // delete scans off the scanner
    ok, err := doxieGo.Delete("img_0001.jpg", "img_0002.jpg")
    if err != nil {
        //...
    } else if ok {
        fmt.Println("scans deleted.")
    }
}

Index

Constants

View Source
const (
	Major = 2
	Minor = 0
	Patch = 0
)

Semantic versioning - http://semver.org/

Variables

View Source
var (
	// ErrHTTPRequest error when making a http request to the scanner
	ErrHTTPRequest error
	// ErrDoxieNotFound error when the scanner is not reachable
	ErrDoxieNotFound = errors.New("doxie: scanner not found on Wi-Fi network")
	// ErrScanNotFound error when scans.json endpoint returns an empty body
	ErrScanNotFound = errors.New("doxie: scan(s) not found scanners memory may be busy")
	// ErrDeletingScan error when the endpoint cannot delete a scan
	ErrDeletingScan = errors.New("doxie: error deleting scan(s)")
	// ErrDownloadingScan request for scan returns no data
	ErrDownloadingScan = errors.New("doxie: error downloading scan")
	// ErrNoThumbnail thumbnail has not yet been generated.
	ErrNoThumbnail = errors.New("doxie: thumbnail not yet generated")
)
View Source
var (
	// APModeIP ip of scanner when it creates its own network
	APModeIP = "192.168.1.100"
	// StaticIP of the scanner when it joins client network
	StaticIP string
	// Port default port of the doxie scanner
	Port = 8080
)

Functions

func Version

func Version() string

Version returns library version.

Types

type Doxie

type Doxie struct {
	// Has password been set to authenticate API access.
	HasPassword bool
	// Scanner Model
	Model string
	// Name of the scanner, defaults to the form "Doxie_XXXXXX"
	Name string
	// FirmwareWiFi version
	FirmwareWiFi string
	// MAC address of the scanner
	MAC string
	// Mode signals if the scanner is in AP or Client mode
	Mode string
	// If in client mode, the name of the network joined
	Network string
	// If in client mode, the IP of the network joined
	IP string
	// URL of the Doxie API
	URL string
	// Scanner password
	Password string
}

Doxie represents a Doxie scanner instance

func Hello

func Hello() (*Doxie, error)

Hello returns status information for the scanner, firmware, network mode, and password configuration. Accessing this command does not require a password if one has been set. The values returned depend on whether the scanner is creating its own network or joining an existing network.

func (*Doxie) Delete

func (d *Doxie) Delete(items ...string) (bool, error)

Delete deletes multiple scans in a single operation.

func (*Doxie) ExternalPower

func (d *Doxie) ExternalPower() (bool, error)

ExternalPower indicates whether the scanner is connected to its AC adapter versus running on battery power. This value is not cached, so it immediately reflects any state changes.

func (*Doxie) Recent

func (d *Doxie) Recent() (string, error)

Recent returns the last scan if available, if there is no recent scan available, an empty string is returned.

func (*Doxie) Restart

func (d *Doxie) Restart() error

Restart restarts the scanner's Wi-Fi system.

func (*Doxie) Scan

func (d *Doxie) Scan(name string) (image.Image, error)

Scan gets a scanned item by name.

func (*Doxie) ScannerFirmware

func (d *Doxie) ScannerFirmware() (string, error)

ScannerFirmware the scanners firmware version.

func (*Doxie) Scans

func (d *Doxie) Scans() ([]ScanItem, error)

Scans returns an array of all scans currently in the scanners memory. After scanning a document, the scan will available several seconds later. Calling this function immediately after scanning something may return a blank result, even if there are other scans on the scanner, due to the scanner's memory being in use. Consider retrying if len(ScanItems) is zero.

func (*Doxie) Thumbnail

func (d *Doxie) Thumbnail(name string) (image.Image, error)

Thumbnail gets a 240x240 thumbnail of the scan. Returns error ErrNoThumbnail if the thumbnail has not yet been generated, retrying after a delay is recommended to handle such cases.

type ScanItem

type ScanItem struct {
	Name     string
	Size     int
	Modified string
}

ScanItem list of scans in the scanners memory

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL