eddystone

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: BSD-2-Clause Imports: 8 Imported by: 18

README

eddystone : Golang package for support Eddystone beacon

GoDoc Build Status

Eddystone is an open beacon format from Google.

This package covers Eddystone-UID, Eddystone-URL, Eddystone-TLM from Eddystone Protocol Specification.

$ go get github.com/suapapa/go_eddystone

Example

Checkout example/beacon.go for using this package with gatt to make a Eddystone beacon in Golang.

Authors

Copyright (c) 2015-2020, go_eddystone authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Documentation

Overview

Package eddystone provides tools for making Eddystone frame

Index

Examples

Constants

View Source
const (
	// UID means UID frame
	UID Header = 0x00
	// URL means URL frame
	URL = 0x10
	// TLM means TLM frame
	TLM = 0x20
	// EID means EID frame
	EID = 0x30
	// Unknown means it may not Eddystone frame
	Unknown = 0xff
)

Eddystone frame types

View Source
const SvcUUID = 0xFEAA

SvcUUID is Eddystone service UUID

Variables

View Source
var (
	// SvcUUIDBytes is Eddystone service UUID in Little Endian format
	SvcUUIDBytes = []byte{0xAA, 0xFE}
)

Functions

func ComputeEIDValue added in v1.3.1

func ComputeEIDValue(identityKey []byte, ts uint32, k byte) (eid []byte, err error)

ComputeEIDValue returns 8 bytes EID value https://github.com/google/eddystone/blob/master/eddystone-eid/eid-computation.md

func ConstructNSByElidedUUID added in v1.3.1

func ConstructNSByElidedUUID(id uuid.UUID) []byte

ConstructNSByElidedUUID return 10 bytes namespace for UID frame by elided version 4 UUID

func ConstructNSByTruncatedHashFQDN added in v1.3.1

func ConstructNSByTruncatedHashFQDN(fqdn string) []byte

ConstructNSByTruncatedHashFQDN return 10 bytes namespace for UID frame by traucated hash of FQDN

func ParseTLMFrame

func ParseTLMFrame(f []byte) (batt uint16, temp float32, advCnt uint32, secCnt uint32)

ParseTLMFrame returns contents of TLM frame

func ParseUIDFrame

func ParseUIDFrame(f []byte) (ns, instance string, txPower int)

ParseUIDFrame returns contents of UID frame

func ParseURLFrame

func ParseURLFrame(f []byte) (url string, txPower int, err error)

ParseURLFrame returns contents of URL frame

Types

type Frame

type Frame []byte

Frame represent Eddystone frame

func MakeEIDFrameFromBytes added in v1.3.1

func MakeEIDFrameFromBytes(eid []byte, txPwr int) (Frame, error)

MakeEIDFrameFromBytes makes Eddystone-EID frame from EID bytes https://github.com/google/eddystone/tree/master/eddystone-eid

Example
package main

import (
	"fmt"

	eddystone "github.com/suapapa/go_eddystone"
)

func main() {
	eid, _ := eddystone.ComputeEIDValue([]byte("0123456789abcdef"), 0x12345678, 8)
	f, _ := eddystone.MakeEIDFrameFromBytes(eid, -30)
	fmt.Println(f)
	fmt.Println([]byte(f))
	// EID[EphemetalIdentifier:0xb846453b3c9e7b59 TxPwr:-30dBm]
	// [48 226 184 70 69 59 60 158 123 89]
}
Output:

func MakeTLMFrame

func MakeTLMFrame(batt uint16, temp float32, advCnt, secCnt uint32) (Frame, error)

MakeTLMFrame makes Eddystone-TLM frame https://github.com/google/eddystone/tree/master/eddystone-tlm

Example
package main

import (
	"fmt"

	eddystone "github.com/suapapa/go_eddystone"
)

func main() {
	f, _ := eddystone.MakeTLMFrame(3300, 23.5, 1, 2)
	fmt.Println(f)
	fmt.Println([]byte(f))
}
Output:

TLM[batt:3300 temp:23.500000, advCnt:1 secCnt:2]
[32 0 12 228 23 128 0 0 0 1 0 0 0 2]

func MakeUIDFrame

func MakeUIDFrame(namespace, instance string, txPwr int) (Frame, error)

MakeUIDFrame makes Eddystone-UID frame https://github.com/google/eddystone/tree/master/eddystone-uid

Example
package main

import (
	"fmt"

	eddystone "github.com/suapapa/go_eddystone"
)

func main() {
	f, _ := eddystone.MakeUIDFrame("0102030405060708090a", "0b0c0d0e0f10", -30)
	fmt.Println(f)
	fmt.Println([]byte(f))
}
Output:

UID[Namespace:0x0102030405060708090a Instance:0x0b0c0d0e0f10 TxPwr:-30dBm]
[0 226 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 0]

func MakeUIDFrameFromBytes added in v1.3.1

func MakeUIDFrameFromBytes(namespace, instance []byte, txPwr int) (Frame, error)

MakeUIDFrameFromBytes makes Eddystone-UID frame from namespace and instance bytes https://github.com/google/eddystone/tree/master/eddystone-uid

func MakeURLFrame

func MakeURLFrame(url string, txPwr int) (Frame, error)

MakeURLFrame makes Eddystone-URL frame https://github.com/google/eddystone/tree/master/eddystone-url

Example
package main

import (
	"fmt"

	eddystone "github.com/suapapa/go_eddystone"
)

func main() {
	f, _ := eddystone.MakeURLFrame("http://github.com", -30)
	fmt.Println(f)
	fmt.Println([]byte(f))
}
Output:

URL[Url:http://github.com TxPwr:-30dBm]
[16 226 2 103 105 116 104 117 98 7]

func (Frame) String

func (f Frame) String() string
type Header byte

Header for Eddystone frames

func ParseHeader added in v1.3.0

func ParseHeader(frames []byte) Header

ParseHeader returns type of Eddystone frame

func (Header) String added in v1.3.0

func (hdr Header) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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