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
- Variables
- func Version() string
- type Doxie
- func (d *Doxie) Delete(items ...string) (bool, error)
- func (d *Doxie) ExternalPower() (bool, error)
- func (d *Doxie) Recent() (string, error)
- func (d *Doxie) Restart() error
- func (d *Doxie) Scan(name string) (image.Image, error)
- func (d *Doxie) ScannerFirmware() (string, error)
- func (d *Doxie) Scans() ([]ScanItem, error)
- func (d *Doxie) Thumbnail(name string) (image.Image, error)
- type ScanItem
Constants ¶
const ( Major = 2 Minor = 0 Patch = 0 )
Semantic versioning - http://semver.org/
Variables ¶
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") )
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 ¶
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 ¶
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) ExternalPower ¶
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 ¶
Recent returns the last scan if available, if there is no recent scan available, an empty string is returned.
func (*Doxie) ScannerFirmware ¶
ScannerFirmware the scanners firmware version.
func (*Doxie) Scans ¶
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.