Documentation
¶
Index ¶
- type AbPacket
- type AcPacket
- type AoPacket
- type ArPacket
- type AsPacket
- type AuPacket
- type BleAdvertisement
- type BleData
- type BleManufacturerData
- type BleServiceData
- type CommandDefinition
- type FirmwareBranch
- type HttpComm
- type HttpScheme
- type PaPacket
- type PbPacket
- type PcPacket
- type PdPacket
- type PiPacket
- type PmPacket
- type Position
- type PrPacket
- type PsPacket
- type TcpComm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbPacket ¶
type AbPacket struct {
// Is the list of devices that the server wants to send from the device
Devices *[]BleData
}
Based on the `Layrz Protocol v2` specification. AbPacket is the Blueooth Low Energy packet sent from the server to the device
func (*AbPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type AcPacket ¶
type AcPacket struct {
// Is the list of commands that the server wants to send to the device
Commands []CommandDefinition
}
Based on the `Layrz Protocol v2` specification. AcPacket is the Command queue packet sent from the server to the device
func (*AcPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type AoPacket ¶
Based on the `Layrz Protocol v2` specification. AoPacket is the success packet sent from the server to the device
func (*AoPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type ArPacket ¶
type ArPacket struct {
// Is the reason of the error
Reason string
}
Based on the `Layrz Protocol v2` specification. ArPacket is the error packet sent from the server to the device
func (*ArPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type AsPacket ¶
type AsPacket struct{}
Based on the `Layrz Protocol v2` specification. AsPacket is the success authentication packet sent from the server to the device
func (*AsPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a AsPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type AuPacket ¶
type AuPacket struct{}
Based on the `Layrz Protocol v2` specification. AuPacket is the authorization request packet sent from the server to the device
func (*AuPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a AuPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type BleAdvertisement ¶
type BleAdvertisement struct {
// Is the detected Mac Address. This Mac Adress came from the detected device, not the
// device that is detecting.
MacAddress string
// Is when the device was detected.
Timestamp time.Time
// Is the closest latitude of the device. Defined by the device that is detecting.
// This value is optional
Latitude float64
// Is the closest longitude of the device. Defined by the device that is detecting.
// This value is optional
Longitude float64
// Is the closest altitude of the device. Defined by the device that is detecting.
// This value is optional
Altitude float64
// Is the signal strength of the detected device.
Rssi int
// Is the transmission power of the detected device.
// This value is optional
TxPower int
// Is the model of the detected device. This model should be equals to the model of the device
// and the model defined by Layrz.
Model string
// Is the list of manufacturer data advertised by the device.
ManufacturerData []BleManufacturerData
// Is the list of service data advertised by the device.
ServiceData []BleServiceData
// Is the name of the device. This name is optional.
DeviceName string
}
Defines a detection of a BLE advertisement.
type BleManufacturerData ¶
type BleManufacturerData struct {
// Is the manufacturer identifier.
CompanyId int
// Is the manufacturer data.
Data []byte
}
Defines the manufacturer data advertised by the device.
type BleServiceData ¶
Defines the service data advertised by the device.
type CommandDefinition ¶
type CommandDefinition struct {
// Is the command id, this value is unique and should be used to
// send the ACK packet PdPacket to the server
CommandId int
// Is the command name, this value is used to identify the command
CommandName *string
// Is the command arguments, may contain any value depending of
// the command definition
Args *map[string]interface{}
}
Defines the command structure based on the `Layrz Protocol v2` specification
type FirmwareBranch ¶
type FirmwareBranch string
const ( Development FirmwareBranch = "1" Stable FirmwareBranch = "0" )
type HttpComm ¶
type HttpComm struct {
Scheme HttpScheme
Host string
Ident string
Passwd string
// contains filtered or unexported fields
}
func (*HttpComm) GetCommands ¶
Get new commands from the server
func (*HttpComm) New ¶
func (p *HttpComm) New(scheme HttpScheme, host, ident, password string)
New creates a new intance of LayrzProtocol using HTTP communication
type HttpScheme ¶
type HttpScheme string
const ( HTTP HttpScheme = "http" HTTPS HttpScheme = "https" )
type PaPacket ¶
type PaPacket struct {
// Defines the ident of the device
Ident *string
// Defines the password of the device
Password *string
}
Based on the `Layrz Protocol v2` specification. PaPacket is the Authentication packet sent from the device to the server.
func (*PaPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PbPacket ¶
type PbPacket struct {
// Is the list of BLE advertisements detected by the device.
Advertisements *[]BleAdvertisement
}
Based on the `Layrz Protocol v2` specification. PbPacket is the Bluetooth low energy packet sent from the device to the server.
func (*PbPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PcPacket ¶
type PcPacket struct {
// Is the timestamp of the response packet
Timestamp time.Time
// Is the command id of the response packet
CommandId int
// Is the message of the response packet
Message *string
}
Based on the `Layrz Protocol v2` specification. PcPacket is the Packet command response sent from the device to the server
func (*PcPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PdPacket ¶
type PdPacket struct {
// Is the timestamp of the response packet
Timestamp time.Time
// Is the position of the device
Position *Position
// Is the extra data sent by the device
ExtraData *map[string]interface{}
}
Based on the `Layrz Protocol v2` specification. PdPacket is the Data packet sent from the device to the server
func (*PdPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PiPacket ¶
type PiPacket struct {
// [ident] is the Unique identifier, sent as part of the package as `IMEI`
Ident string
// [firmwareId] is the firmware internal ID, this is in newer versions is a Layrz ID, otherwise is a unique
// identifier set by the hardware department of Layrz LTD. Also, is idenfified in the package as `FW_ID`
FirmwareId string
// [firmwareBuild] is the firmware version, is an incremental number that is increased in each release.
// This is identified in the package as `FW_BUILD`
FirmwareBuild int
// [deviceId] is the device internal ID, this is in newer versions is a Layrz ID, otherwise is a unique
// identifier set by the hardware department of Layrz LTD. Also, is idenfified in the package as `SYS_DEV_ID`
DeviceId int
// [hardwareId] is the hardware internal ID, this is in newer versions is a Layrz ID, otherwise is a unique
// identifier set by the hardware department of Layrz LTD. Also, is idenfified in the package as `SYS_DEV_HW_ID`
HardwareId int
// [modelId] is the model internal ID, this is in newer versions is a Layrz ID, otherwise is a unique
// identifier set by the hardware department of Layrz LTD. Also, is idenfified in the package
// as `SYS_DEV_MODEL_ID`
ModelId int
// [firmwareBranch] is the branch of the firmware, this is identified in the package as `SYS_DEV_FW_BRANCH`
FirmwareBranch FirmwareBranch
// [fotaEnabled] is a boolean that indicates if the device is capable of receiving FOTA updates.
// This is identified in the package as `FOTA_ENABLED`
FotaEnabled bool
}
Based on the `Layrz Protocol v2` specification. PiPacket is the identification packet sent from the device to the server
func (*PiPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PmPacket ¶
type PmPacket struct {
// Is the timestamp of the response packet
Filename *string
// Is the command id of the response packet
ContentType *string
// Is the message of the response packet
Data *[]byte
}
Based on the `Layrz Protocol v2` specification. PmPacket is the media packet sent from the device to the server
func (*PmPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type Position ¶
type Position struct {
// Is the latitude of the device
Latitude *float64
// Is the longitude of the device
Longitude *float64
// Is the altitude of the device
Altitude *float64
// Is the speed of the device
Speed *float64
// Is the direction of the device
Direction *float64
// Is the satellite count of the device
SatelliteCount *int
// Is the horizontal accuracy of the device
Hdop *float64
}
type PrPacket ¶
type PrPacket struct{}
Based on the `Layrz Protocol v2` specification. PrPacket is the syncronization packet sent from the device to the server
func (*PrPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PrPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type PsPacket ¶
type PsPacket struct {
// Is the timestamp of the response packet
Timestamp time.Time
// Is the current configuration of the device
Params *map[string]interface{}
}
Based on the `Layrz Protocol v2` specification. PsPacket is the Settings packet sent from the device to the server
func (*PsPacket) FromPacket ¶
FromPacket is a method that converts a raw packet to a PaPacket based on the `Layrz Protocol v2` specification
Returns an error if the packet is invalid
type TcpComm ¶
type TcpComm struct {
Host string
Port int
Ident string
Passwd string
// contains filtered or unexported fields
}
func (*TcpComm) SetCallback ¶
SetCallback sets the callback function to be called when a packet is received