ipod

package module
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 13 Imported by: 0

README

ipod

GoDoc Build Status

ipod is a golang userspace library implementation of the ipod accessory protocol. It includes an example client for use with https://github.com/oandrew/ipod-gadget

This is a total rewrite of what was included with the ipod-gadget project. It should work as a drop-in replacement for the old app.

New features:

  • Storing and replaying traces
  • Detailed verbose logging for debug
  • Better codebase with message type definitions
  • Tests
update 03/2020

kernel module needs to be recompiled due to a breaking change (hid descriptor).
This should fix the issue with hanging after GetDevAuthenticationInfo on some devices.
At least it's finally working in my own car :)

build and run

GO111MODULE=on go build github.com/oandrew/ipod/cmd/ipod
# or cross compiling
GO111MODULE=on GOOS=linux GOARCH=arm GOARM=6 go build github.com/oandrew/ipod/cmd/ipod

# with debug logging
./ipod -d serve /dev/iap0

# save a trace file
./ipod -d serve -w ipod.trace /dev/iap0

# simulate incoming requests from a trace file
./ipod -d replay ./ipod.trace

# view a trace file
./ipod -d view ./ipod.trace

Client app godoc https://godoc.org/github.com/oandrew/ipod/cmd/ipod

Refer to https://github.com/oandrew/ipod-gadget for more info on how to get the kernel part working.

Documentation

Overview

Package ipod implements the iPod Accessory protocol (iap)

Index

Constants

View Source
const (
	LingoGeneralID       = 0x00
	LingoSimpleRemoteID  = 0x02
	LingoDisplayRemoteID = 0x03
	LingoExtRemoteID     = 0x04
	LingoUSBHostID       = 0x06
	LingoRFTunerID       = 0x07
	LingoEqID            = 0x08
	LingoSportsID        = 0x09
	LingoDigitalAudioID  = 0x0A
	LingoStorageID       = 0x0C
)
View Source
const (
	PacketStartByte byte = 0x55
)

Variables

This section is empty.

Functions

func BoolToByte

func BoolToByte(b bool) byte

func ByteToBool

func ByteToBool(b byte) bool

func Checksum

func Checksum(p []byte) uint8

func DumpLingos

func DumpLingos() string

DumpLingos returns a list of all registered lingos and commands

func RegisterLingos

func RegisterLingos(lingoID uint8, m interface{}) error

RegisterLingos registers a set of lingo commands

func Respond

func Respond(req *Command, pw CommandWriter, payload interface{})

func Send

func Send(pw CommandWriter, payload interface{})

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes convers a string to a null-terminated byte slice

func TrxReset

func TrxReset()

Types

type CRC8

type CRC8 interface {
	hash.Hash
	Sum8() uint8
}

func NewCRC8

func NewCRC8() CRC8

type CmdBuffer

type CmdBuffer struct {
	Commands []*Command
}

func (*CmdBuffer) WriteCommand

func (cbuf *CmdBuffer) WriteCommand(cmd *Command) error

type Command

type Command struct {
	ID LingoCmdID
	//Optional
	Transaction *Transaction
	Payload     interface{}
}

Command represents iap packet payload

func BuildCommand

func BuildCommand(payload interface{}) (*Command, error)

type CommandReader

type CommandReader interface {
	ReadCommand() (*Command, error)
}

type CommandSerde

type CommandSerde struct {
	TrxEnabled bool
}

func (*CommandSerde) MarshalCmd

func (s *CommandSerde) MarshalCmd(cmd *Command) ([]byte, error)

func (*CommandSerde) UnmarshalCmd

func (s *CommandSerde) UnmarshalCmd(pkt []byte) (*Command, error)

type CommandWriter

type CommandWriter interface {
	WriteCommand(*Command) error
}

type FrameReadWriter

type FrameReadWriter interface {
	FrameReader
	FrameWriter
}

FrameReadWriter is the interface implemented by iap transports i.e. usbhid

type FrameReader

type FrameReader interface {
	// ReadFrame reads a frame that contains
	// one or more iap packets
	ReadFrame() ([]byte, error)
}

type FrameWriter

type FrameWriter interface {
	// WriteFrame writes a frame that contains
	// one or more iap packets
	WriteFrame(data []byte) error
}

type LingoCmdID

type LingoCmdID uint32

LingoCmdID represents Lingo ID and Command ID

func LookupID

func LookupID(v interface{}) (id LingoCmdID, ok bool)

LookupID finds a registered LingoCmdID by the type of v i.e. reverse to Lookup

func NewLingoCmdID

func NewLingoCmdID(lingo, cmd uint16) LingoCmdID

func (LingoCmdID) CmdID

func (id LingoCmdID) CmdID() uint16

func (LingoCmdID) GoString

func (id LingoCmdID) GoString() string

func (LingoCmdID) LingoID

func (id LingoCmdID) LingoID() uint8

func (LingoCmdID) String

func (id LingoCmdID) String() string

type LookupResult

type LookupResult struct {
	Payload     interface{}
	Transaction bool
}

LookupResult contains the result of a Lookup. Payload is a pointer to a new zero value of the found type Transaction specifies if the Transaction should be present in the packet.

func Lookup

func Lookup(id LingoCmdID, payloadSize int, defaultTrxEnabled bool) (LookupResult, bool)

Lookup finds a the payload by LingoCmdID using payloadSize as a hint

type PacketReader

type PacketReader struct {
	// contains filtered or unexported fields
}

func NewPacketReader

func NewPacketReader(frame []byte) *PacketReader

func (*PacketReader) ReadPacket

func (pd *PacketReader) ReadPacket() ([]byte, error)

type PacketWriter

type PacketWriter struct {
	// contains filtered or unexported fields
}

func NewPacketWriter

func NewPacketWriter() *PacketWriter

func (*PacketWriter) Bytes

func (pw *PacketWriter) Bytes() []byte

func (*PacketWriter) WritePacket

func (pw *PacketWriter) WritePacket(payload []byte) error

type Transaction

type Transaction uint16

func NewTransaction

func NewTransaction(t uint16) *Transaction

func TrxNext

func TrxNext() *Transaction

func (*Transaction) Copy

func (tr *Transaction) Copy() *Transaction

func (*Transaction) Delta

func (tr *Transaction) Delta(d int) *Transaction

func (Transaction) GoString

func (tr Transaction) GoString() string

func (Transaction) String

func (tr Transaction) String() string

type UnknownPayload

type UnknownPayload []byte

UnknownPayload is a payload that represents an unknown command

Directories

Path Synopsis
cmd
ipod
ipod talks to an ipod accessory using iap protocol.
ipod talks to an ipod accessory using iap protocol.
Package hid implements iap over hid transport
Package hid implements iap over hid transport

Jump to

Keyboard shortcuts

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