api

package
v3.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Algorithm_TDOA     = "Tdoa"
	Algorithm_RSSI     = "Rssi"
	Algorithm_RSSITDOA = "RssiTdoaCombined"
)

Algorithms supported by the location solver.

Variables

View Source
var DefaultServerURL = func() *url.URL {
	parsed, err := url.Parse(defaultServerURL)
	if err != nil {
		panic(fmt.Sprintf("loragls: failed to parse base URL: %v", err))
	}
	return parsed
}()

DefaultServerURL is the default server URL for LoRa Cloud Geolocation.

Functions

This section is empty.

Types

type AbstractLocationSolverResponse added in v3.12.2

type AbstractLocationSolverResponse interface {
	Result() AbstractLocationSolverResult
	Errors() []string
	Warnings() []string

	Raw() *json.RawMessage
}

AbstractLocationSolverResponse provides a unified interface to the location solver responses.

type AbstractLocationSolverResult added in v3.12.2

type AbstractLocationSolverResult interface {
	Location() *ttnpb.Location
	Algorithm() string
}

AbstractLocationSolverResult provides a unified interface to the location solver results.

type AccessPoint added in v3.12.2

type AccessPoint struct {
	MACAddress     string `json:"macAddress"`
	SignalStrength int64  `json:"signalStrength"`
}

AccessPoint contains the metadata of a WiFi access point. https://www.loracloud.com/documentation/geolocation?url=v2.html#wifiaccesspoint

type AntennaLocation added in v3.12.2

type AntennaLocation struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Altitude  float64 `json:"altitude"`
}

AntennaLocation contains the location information of a gateway. https://www.loracloud.com/documentation/geolocation?url=v2.html#antennalocation

type Client

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

Client is an API client for the LoRa Cloud Geolocation service.

func New

func New(cl *http.Client, opts ...Option) (*Client, error)

New creates a new Client with the given options.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, version, category, operation string, body interface{}) (*http.Response, error)

Do executes a new HTTP request with the given parameters and body and returns the response.

func (*Client) SolveGNSS added in v3.12.2

SolveGNSS attempts to solve the location of the end-device using the provided GNSS request.

func (*Client) SolveMultiFrame added in v3.12.2

func (c *Client) SolveMultiFrame(ctx context.Context, request *MultiFrameRequest) (*ExtendedLocationSolverResponse, error)

SolveMultiFrame attempts to solve the location of the end-device using the provided multi frame request.

func (*Client) SolveSingleFrame

func (c *Client) SolveSingleFrame(ctx context.Context, request *SingleFrameRequest) (*ExtendedLocationSolverResponse, error)

SolveSingleFrame attempts to solve the location of the end-device using the provided single frame request.

func (*Client) SolveWiFi added in v3.12.2

SolveWiFi attempts to solve the location of the end-device using the provided WiFi request.

type ExtendedGNSSLocationSolverResponse added in v3.12.2

type ExtendedGNSSLocationSolverResponse struct {
	GNSSLocationSolverResponse

	Raw *json.RawMessage
}

ExtendedGNSSLocationSolverResponse extends GNSSLocationSolverResponse with the raw JSON representation.

func (*ExtendedGNSSLocationSolverResponse) AbstractResponse added in v3.12.2

AbstractResponse converts the GNSS location solver response to the abstract location response format.

func (ExtendedGNSSLocationSolverResponse) MarshalJSON added in v3.12.2

func (r ExtendedGNSSLocationSolverResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Note that the Raw representation takes precedence in the marshaling process, if it is available.

func (*ExtendedGNSSLocationSolverResponse) UnmarshalJSON added in v3.12.2

func (r *ExtendedGNSSLocationSolverResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Marshaler.

type ExtendedLocationSolverResponse added in v3.12.2

type ExtendedLocationSolverResponse struct {
	LocationSolverResponse

	Raw *json.RawMessage
}

ExtendedLocationSolverResponse extends LocationSolverResponse with the raw JSON representation.

func (ExtendedLocationSolverResponse) AbstractResponse added in v3.12.2

AbstractResponse converts the location solver response to the abstract location response format.

func (ExtendedLocationSolverResponse) MarshalJSON added in v3.12.2

func (r ExtendedLocationSolverResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Note that the Raw representation takes precedence in the marshaling process, if it is available.

func (*ExtendedLocationSolverResponse) UnmarshalJSON added in v3.12.2

func (r *ExtendedLocationSolverResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Marshaler.

type ExtendedWiFiLocationSolverResponse added in v3.12.2

type ExtendedWiFiLocationSolverResponse struct {
	WiFiLocationSolverResponse

	Raw *json.RawMessage
}

ExtendedWiFiLocationSolverResponse extends WiFiLocationQueryResponse with the raw JSON representation.

func (*ExtendedWiFiLocationSolverResponse) AbstractResponse added in v3.12.2

func (r *ExtendedWiFiLocationSolverResponse) AbstractResponse() abstractLocationSolverResponse

AbstractResponse converts the WiFi location solver response to the abstract location response format.

func (ExtendedWiFiLocationSolverResponse) MarshalJSON added in v3.12.2

func (r ExtendedWiFiLocationSolverResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Note that the Raw representation takes precedence in the marshaling process, if it is available.

func (*ExtendedWiFiLocationSolverResponse) UnmarshalJSON added in v3.12.2

func (r *ExtendedWiFiLocationSolverResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Marshaler.

type Frame

type Frame []Uplink

Frame contains the uplink metadata for each reception. https://www.loracloud.com/documentation/geolocation?url=v3.html#frame

type GNSSLocationSolverResponse added in v3.12.2

type GNSSLocationSolverResponse struct {
	Result   *GNSSLocationSolverResult `json:"result"`
	Errors   []string                  `json:"errors"`
	Warnings []string                  `json:"warnings"`
}

GNSSLocationSolverResponse contains the GNSS location query response. https://www.loracloud.com/documentation/geolocation?url=gnss.html#single-capture-http-request

type GNSSLocationSolverResult added in v3.12.2

type GNSSLocationSolverResult struct {
	LLH      []float64 `json:"llh"`
	Accuracy float64   `json:"accuracy"`
}

GNSSLocationSolverResult contains the result of a GNSS location query. https://www.loracloud.com/documentation/geolocation?url=gnss.html#locationsolverresult

type GNSSRequest added in v3.12.2

type GNSSRequest struct {
	Payload Hex `json:"payload"`
}

GNSSRequest contains the location query request based on a GNSS payload. https://www.loracloud.com/documentation/geolocation?url=gnss.html#single-capture-http-request

type Gateway

type Gateway struct {
	GatewayID string  `json:"gatewayId"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Altitude  float64 `json:"altitude"`
}

Gateway contains the description of a LoRaWAN gateway. https://www.loracloud.com/documentation/geolocation?url=v3.html#gateway

type Hex added in v3.12.2

type Hex []byte

Hex represents hex encoded bytes.

func (Hex) MarshalJSON added in v3.12.2

func (h Hex) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Hex) String added in v3.12.2

func (h Hex) String() string

String implements fmt.Stringer.

func (*Hex) UnmarshalJSON added in v3.12.2

func (h *Hex) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements json.Unmarshaler.

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Tolerance uint64  `json:"toleranceHoriz"`
}

Location contains the coordinates contained in a location query result.

type LocationSolverResponse added in v3.12.2

type LocationSolverResponse struct {
	Result   *LocationSolverResult `json:"result"`
	Errors   []string              `json:"errors"`
	Warnings []string              `json:"warnings"`
}

LocationSolverResponse contains the location query response. https://www.loracloud.com/documentation/geolocation?url=v3.html#singleframe-http-request https://www.loracloud.com/documentation/geolocation?url=v3.html#multiframe-http-request

type LocationSolverResult

type LocationSolverResult struct {
	UsedGateways uint8    `json:"numUsedGateways"`
	HDOP         *float64 `json:"HDOP"`
	Algorithm    string   `json:"algorithmType"`
	Location     Location `json:"locationEst"`
}

LocationSolverResult contains the result of a location query. https://www.loracloud.com/documentation/geolocation?url=v3.html#locationsolverresult

type MultiFrameRequest added in v3.12.2

type MultiFrameRequest struct {
	Gateways []Gateway `json:"gateways"`
	Frames   []Frame   `json:"frames"`
}

MultiFrameRequest contains the location query request for multiple LoRaWAN frames. https://www.loracloud.com/documentation/geolocation?url=v3.html#multiframe-http-request

func BuildMultiFrameRequest added in v3.12.2

func BuildMultiFrameRequest(ctx context.Context, mds [][]*ttnpb.RxMetadata) *MultiFrameRequest

BuildMultiFrameRequest builds a MultiFrameRequest from the provided metadata.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an option for the API client.

func WithBaseURL

func WithBaseURL(baseURL *url.URL) Option

WithBaseURL uses the given base URL for the requests of the client.

func WithToken

func WithToken(token string) Option

WithToken uses the given authentication token in the client.

type OptionFunc

type OptionFunc func(*Client)

OptionFunc is an Option implemented as a function.

type SingleFrameRequest

type SingleFrameRequest struct {
	Gateways []Gateway `json:"gateways"`
	Frame    Frame     `json:"frame"`
}

SingleFrameRequest contains the location query request for a single LoRaWAN frame. https://www.loracloud.com/documentation/geolocation?url=v3.html#singleframe-http-request

func BuildSingleFrameRequest

func BuildSingleFrameRequest(ctx context.Context, metadata []*ttnpb.RxMetadata) *SingleFrameRequest

BuildSingleFrameRequest builds a SingleFrameRequest from the provided metadata.

type TDOAUplink struct {
	GatewayID       string          `json:"gatewayId"`
	RSSI            float64         `json:"rssi"`
	SNR             float64         `json:"snr"`
	TDOA            uint64          `json:"toa"`
	AntennaID       *uint32         `json:"antennaId"`
	AntennaLocation AntennaLocation `json:"antennaLocation"`
}

TDOAUplink contains the metadata of an uplink. https://www.loracloud.com/documentation/geolocation?url=v2.html#uplinktdoa

type Uplink struct {
	GatewayID string
	AntennaID *uint32
	TDOA      *uint64
	RSSI      float64
	SNR       float64
}

Uplink contains the metadata of a LoRaWAN uplink. https://www.loracloud.com/documentation/geolocation?url=v3.html#uplink

func (*Uplink) MarshalJSON

func (u *Uplink) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Uplink) UnmarshalJSON

func (u *Uplink) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type WiFiLocationSolverResponse added in v3.12.2

type WiFiLocationSolverResponse struct {
	Result   *WiFiLocationSolverResult `json:"result"`
	Errors   []string                  `json:"errors"`
	Warnings []string                  `json:"warnings"`
}

WiFiLocationSolverResponse contains the result of a WiFi location query. https://www.loracloud.com/documentation/geolocation?url=v2.html#singleframe-wi-fi-tdoa-request

type WiFiLocationSolverResult added in v3.12.2

type WiFiLocationSolverResult struct {
	Latitude         float64 `json:"latitude"`
	Longitude        float64 `json:"longitude"`
	Altitude         float64 `json:"altitude"`
	Accuracy         float64 `json:"accuracy"`
	Algorithm        string  `json:"algorithmType"`
	GatewaysReceived float64 `json:"numberOfGatewaysReceived"`
	GatewaysUsed     float64 `json:"numberOfGatewaysUsed"`
}

WiFiLocationSolverResult contains the result of a WiFi location query. https://www.loracloud.com/documentation/geolocation?url=v2.html#locationresult

type WiFiRequest added in v3.12.2

type WiFiRequest struct {
	LoRaWAN          []TDOAUplink  `json:"lorawan"`
	WiFiAccessPoints []AccessPoint `json:"wifiAccessPoints"`
}

WiFiRequest contains a WiFi / TDOA location query. https://www.loracloud.com/documentation/geolocation?url=v2.html#singleframe-wi-fi-tdoa-request

func BuildWiFiRequest added in v3.12.2

func BuildWiFiRequest(ctx context.Context, metadata []*ttnpb.RxMetadata, accessPoints []AccessPoint) *WiFiRequest

BuildWiFiRequest builds a WiFiRequest from the provided metadata and payload.

Jump to

Keyboard shortcuts

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