Documentation ¶
Index ¶
- Constants
- func IBeaconListener(validbeacons []BeaconData, brs chan BeaconRecord)
- func LoadFileToCert(file string) *x509.CertPool
- func StartClient()
- func StartServer(x509cert, x509key, drivername, dsn string, end chan struct{})
- type BeaconData
- type BeaconLog
- type BeaconLogPacket
- type BeaconRecord
- type BeaconResponsePacket
- type ServerConfig
- type Uuid
Constants ¶
const ( // Milliseconds TIMEOUT_BEACON_REFRESH = 60000 TIMEOUT_BEACON = 50 BACKOFF_MAX = 30 * time.Second BACKOFF_MIN = 50 * time.Millisecond BACKOFF_MULTIPLIER = 2 )
const ( ERROR_TRACE = 0 ERROR_DEBUG = 1 ERROR_INFO = 2 ERROR_WARN = 3 ERROR_ERROR = 4 ERROR_FATAL = 5 )
const ( ERROR_NULL = iota ERROR_DESYNC )
const ( DEFAULT_PORT = "32969" MAX_BEACONS = 256 MAX_LOGS = 256 MAX_CTRL = 65535 // Based on the size of the encompassing types this is the max size // of a packet, all others should be dropped // 16 is for UUID, 1 is for Flags MAX_SIZE = MAX_CTRL + MAX_LOGS*12 + MAX_BEACONS*20 + 16 + 1 CURRENT_VERSION = 1 )
const ( // binary mask that leaves the version of the packet protocol as is VERSION_MASK = 0x0F // any protocol failures RESPONSE_INVALID = 0x10 // request is ok and will complete RESPONSE_OK = 0x20 // should be returned if the server is rate limiting the client RESPONSE_TOOMANY = 0x40 // the client should restart RESPONSE_RESTART = 0x80 // the client should shutdown RESPONSE_SHUTDOWN = 0x100 // the client should attempt to update its code and restart RESPONSE_UPDATE = 0x200 // the client should accept the beacon list updates sent by the server RESPONSE_BEACON_UPDATES = 0x400 // the server is notifying the client there is a problem on its side that // it cannot recover from RESPONSE_INTERNAL_FAILURE = 0x800 // the client should run the command in its shell RESPONSE_SYSTEM = 0x8000 // the client is requesting beacon updates from the server REQUEST_BEACON_UPDATES = 0x10 // the client is ending a control log, i.e. the stdout from the system // response REQUEST_CONTROL_LOG = 0x20 // the client is signalling that it has completed the control and the // server can stop sending it REQUEST_CONTROL_COMPLETE = 0x40 )
Variables ¶
This section is empty.
Functions ¶
func IBeaconListener ¶
func IBeaconListener(validbeacons []BeaconData, brs chan BeaconRecord)
IBeaconListener is public provider for BeaconRecords
func LoadFileToCert ¶
LoadFileToCert is a helper that opens a file by string and returns a x509 cert pool giving a fatal error on failure
func StartClient ¶
func StartClient()
Main entry point for the client app that is run on the edge devices
func StartServer ¶
func StartServer(x509cert, x509key, drivername, dsn string, end chan struct{})
StartServer is the main interface for the BeaconServer
Types ¶
type BeaconData ¶
20 Bytes corresponding to the iBeacon profile
func (*BeaconData) MarshalBinary ¶
func (b *BeaconData) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface. Output is 20 bytes
func (*BeaconData) String ¶
func (b *BeaconData) String() string
func (*BeaconData) UnmarshalBinary ¶
func (b *BeaconData) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryMarshaler interface.
type BeaconLog ¶
type BeaconLog struct { Datetime time.Time Rssi int16 // Index of value within a packet BeaconIndex uint16 }
12 Bytes which represents one time series value
func (*BeaconLog) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface. Output is 12 bytes
func (*BeaconLog) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryMarshaler interface.
type BeaconLogPacket ¶
type BeaconLogPacket struct { // Request flags Flags uint8 // Sender uuid // Edge UUID Uuid Uuid Logs []BeaconLog Beacons []BeaconData // Extra unstructed data ControlData string }
BeaconLogPacket should be sent by clients to the server
func (*BeaconLogPacket) MarshalBinary ¶
func (b *BeaconLogPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*BeaconLogPacket) UnmarshalBinary ¶
func (b *BeaconLogPacket) UnmarshalBinary(data []byte) error
type BeaconRecord ¶
type BeaconRecord struct { BeaconData Datetime time.Time Rssi int16 }
BeaconRecord represents a complete Beacon record including ID data and time & power
type BeaconResponsePacket ¶
type BeaconResponsePacket struct { // Response flags Flags uint16 //LengthData uint32 // Unstructered data Data string }
BeaconResponsePacket is the response to the client from the server
func (*BeaconResponsePacket) MarshalBinary ¶
func (b *BeaconResponsePacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*BeaconResponsePacket) UnmarshalBinary ¶
func (b *BeaconResponsePacket) UnmarshalBinary(d []byte) error
UnmarshalBinary implements the encoding.BinaryMarshaler interface.
type ServerConfig ¶
type ServerConfig struct { X509cert string X509key string // Database drivername, must be psql Drivername string // Database data source name DSN string }
Required BeaconServer config
func GetFlags ¶
func GetFlags() (out ServerConfig)