Documentation
¶
Overview ¶
Package util provides utilities.
Index ¶
- func GetSerialNumberForAccessoryName(name string, storage Storage) string
- func MAC48Address(input string) string
- func RandomHexString() string
- func RemoveAccentsFromString(v string) string
- func XHMURI(pincode, setupId string, categoryId uint8, flags []SetupFlag) (string, error)
- type Container
- type SetupFlag
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSerialNumberForAccessoryName ¶
GetSerialNumberForAccessoryName returns the serial for a specific name stored in storage. When no serial number is stored for this name yet, a new one is created using RandomHexString()
func MAC48Address ¶
MAC48Address returns a MAC-48-like address from the argument string
func RemoveAccentsFromString ¶
RemoveAccentsFromString removes accent characters from string From https://stackoverflow.com/a/40405242/424814
Types ¶
type Container ¶
type Container interface {
// SetByte sets one byte for a key
SetByte(key, value byte)
// SetBytes sets bytes for a key
SetBytes(key byte, value []byte)
// SetString sets a string for a key
SetString(key byte, value string)
// GetByte returns one byte for a key
GetByte(key byte) byte
// GetBytes returns bytes for a key
GetBytes(key byte) []byte
// GetString return a string for a key
GetString(key byte) string
// BytesBuffer returns the raw bytes
BytesBuffer() *bytes.Buffer
}
Container is a dictionary using byte keys and values.
func NewTLV8Container ¶
func NewTLV8Container() Container
NewTLV8Container returns a type-length-value container which implements the Container interface. Packets which value exceed a length of 8 bit (255) will be split up in multiple packets.
type SetupFlag ¶
type SetupFlag uint8
var SetupFlagBTLE SetupFlag = 4
var SetupFlagIP SetupFlag = 2
var SetupFlagIPWAC SetupFlag = 8
var SetupFlagNFC SetupFlag = 1
var SetupFlagNone SetupFlag = 0
type Storage ¶
type Storage interface {
// Set sets bytes for a key
Set(key string, value []byte) error
// Delete removes bytes for a key
Delete(key string) error
// Get returns bytes for a key
Get(key string) ([]byte, error)
// KeysWithSuffix returns all keys with a specific suffix
KeysWithSuffix(suffix string) ([]string, error)
}
Storage stores bytes for a key.
func NewFileStorage ¶
NewFileStorage create a file storage for the specified directory. The folder is created if necessary. Every key-value pair is stored in a seperate file.
func NewTempFileStorage ¶
NewTempFileStorage returns a new storage inside temporary folder.