Documentation
¶
Index ¶
- type Client
- func (client *Client) DecryptReport(report ReportResponse, locationPrivateKey []byte) (DecryptedLocation, error)
- func (client *Client) DownloadDataByte(ctx context.Context, messageID, byteIndex, lookBackDays int, ...) (*DataByte, error)
- func (client *Client) DownloadLocation(ctx context.Context, lookBackDays int) (ret []DecryptedLocation, err error)
- type DataByte
- type DecryptedLocation
- type MultiReportRequest
- type MultiReportResponse
- type ReportResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
LocationReportHttpAddress string
LocationPrivateKey []byte
LocationAdvertisementKey []byte
CustomMagicKey []byte
// contains filtered or unexported fields
}
Client is a HTTP client of hzgl/air-bridge-ws (Apple Find My HTTP service adapter).
func (*Client) DecryptReport ¶
func (client *Client) DecryptReport(report ReportResponse, locationPrivateKey []byte) (DecryptedLocation, error)
DecryptReport decrypts the encrypted payload of a location report. Apple device encrypts its own location by the public key broadcast by a bluetooth beacon, and uploads the encrypted location report to Apple.
func (*Client) DownloadDataByte ¶
func (client *Client) DownloadDataByte(ctx context.Context, messageID, byteIndex, lookBackDays int, maxBitReportSpread time.Duration) (*DataByte, error)
DownloadDataByte retrieves a data byte for the specified message ID and byte index. maxBitReportSpread defines the maximum time between updates of the byte. It prevents incidental retrieval of outdated bits.
func (*Client) DownloadLocation ¶
func (client *Client) DownloadLocation(ctx context.Context, lookBackDays int) (ret []DecryptedLocation, err error)
DownloadLocation downloads the recent (from latest to oldest) location reports and decrypts them.
type DataByte ¶
type DataByte struct {
// Value is the byte value, assembled from reports of individually retrieved bits.
Value byte
// ReportTime is the timestamp of the latest bit retrieved across the byte.
ReportTime time.Time
// BitReportSpread is the maximum spread (latest - oldest) of the report representing each bit.
BitReportSpread time.Duration
// BitReport is the retrieved FindMy location report correspoding to each bit in big endian (most significant first).
BitReport []ReportResponse
}
DataByte represents a byte of data retrieved from Find My network. Note that bits are transmitted independently from each other and will arrive out of order.
type DecryptedLocation ¶
type DecryptedLocation struct {
// Latitude in decimal degrees, positive is north and negative is south.
Latitude float64
// Longitude in decimal degrees, positive is east and negative is east.
Longitude float64
// AccuracyMetres is the self-reported location accuracy of the apple device which heard the beacon.
AccuracyMetres byte
// ConfidencePercent appears to fluctuate between 0-3 for accuracy < 150 metres. I am uncertain what the percentage means.
ConfidencePercent byte
// Timestamp is the wall clock reported by the apple device which heard the beacon.
Timestamp time.Time
}
DecryptedLocation represents a location report encrypted by an Apple device
func (*DecryptedLocation) Valid ¶
func (loc *DecryptedLocation) Valid() bool
type MultiReportRequest ¶
type MultiReportRequest struct {
HashedAdvertisedPublicKey []string `json:"ids"`
Days int `json:"days"`
}
MultiReportRequest is the location report request payload for hzgl/air-bridge-ws (Apple Find My HTTP service adapter).
type MultiReportResponse ¶
type MultiReportResponse struct {
Results []ReportResponse `json:"results"`
}
MultiReportRequest is the location report response payload.
func (*MultiReportResponse) ToMap ¶
func (resp *MultiReportResponse) ToMap() map[string]ReportResponse
ToMap returns a map of hashed advertisement public key to its latest location report.
type ReportResponse ¶
type ReportResponse struct {
DatePublishedUnixMillis int64 `json:"datePublished"`
EncryptedPayloadBase64 string `json:"payload"`
Description string `json:"description"`
HashedAdvertisedPublicKey string `json:"id"`
StatusCode int `json:"statusCode"`
}
func (ReportResponse) EncryptedPayload ¶
func (resp ReportResponse) EncryptedPayload() []byte