berrylan

package module
v0.0.0-...-a40c1e2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 6 Imported by: 1

README

go-ble-berrylan

Golang implementation of the BerryLan BLE server for go-ble

Introduction

This library implements the BerryLan BLE server protocol. It can be used to commission WiFi settings for a(n) (IoT) device.

Although BerryLan is tailored towards NetworkManager, it could be used with other networking applications too.

Dependencies

This library makes use of go-ble. Currently, it only runs on Linux.

Examples

An example application is included that provides a 'dummy' implementation of a backend. It can be used together with the BerryLan application ( Apple App Store, Google Play Store).

To run this example, navigate to the examples/dummy folder, and run go run main.go. Root access may be necessary to access the Bluetooth peripheral.

License

See the LICENSE.md file (MIT license).

Documentation

Index

Constants

WirelessConnectionStatus enum values. This maps directly on the enum values of the specification.

View Source
const (
	NetworkStatusUnknown         = NetworkStatus(spec.NetworkStatusUnknown)
	NetworkStatusAsleep          = NetworkStatus(spec.NetworkStatusAsleep)
	NetworkStatusDisconnected    = NetworkStatus(spec.NetworkStatusDisconnected)
	NetworkStatusDisconnecting   = NetworkStatus(spec.NetworkStatusDisconnecting)
	NetworkStatusConnecting      = NetworkStatus(spec.NetworkStatusConnecting)
	NetworkStatusLocal           = NetworkStatus(spec.NetworkStatusLocal)
	NetworkStatusConnectedSite   = NetworkStatus(spec.NetworkStatusConnectedSite)
	NetworkStatusConnectedGlobal = NetworkStatus(spec.NetworkStatusConnectedGlobal)
)

NetworkStatus enum values. This maps directly on the enum values of the specification.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	Ssid           string `json:"ssid"`
	MACAddress     string `json:"macAddress"`
	SignalStrength int    `json:"signalStrength"`
	Protected      bool   `json:"protected"`
	IPAddress      string `json:"ipAddress"`
}

ConnectionInfo struct.

type ConnectionStatusUpdateHandler

type ConnectionStatusUpdateHandler func(status WirelessConnectionStatus)

ConnectionStatusUpdateHandler event handler function.

type Interface

type Interface interface {
	WirelessInterface
	NetworkInterface
}

Interface is a combined interface of WirelessInterface and NetworkInterface, for convenience reasons.

type NetworkInfo

type NetworkInfo struct {
	Ssid           string `json:"ssid"`
	MACAddress     string `json:"macAddress"`
	SignalStrength int    `json:"signalStrength"`
	Protected      bool   `json:"protected"`
}

NetworkInfo struct.

type NetworkInterface

type NetworkInterface interface {
	EnableNetworking(enabled bool) error
	EnableWireless(enabled bool) error

	HandleNetworkStatusUpdate(f NetworkStatusUpdateHandler)
	HandleWirelessStateUpdate(f WirelessStateUpdateHandler)
	HandleNetworkingStateUpdate(f NetworkingStateUpdateHandler)
}

NetworkInterface is the interface for communicating with the (system) networking service. It is responsible for enabling the networkint service and/or the wireless service.

type NetworkService

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

NetworkService represents the BLE wireless service.

func NewNetworkService

func NewNetworkService(networkInterface NetworkInterface) *NetworkService

NewNetworkService initializes a new NetworkService. It wraps an interface to the actual network service.

func (*NetworkService) Create

func (n *NetworkService) Create() *ble.Service

Create returns a ble.Service with all the required characteristics for a network service.

type NetworkStatus

type NetworkStatus spec.NetworkStatus

NetworkStatus enum type.

func (*NetworkStatus) String

func (s *NetworkStatus) String() string

NetworkStatusToString returns a string representation of a given NetworkStatus.

type NetworkStatusUpdateHandler

type NetworkStatusUpdateHandler func(status NetworkStatus)

NetworkStatusUpdateHandler event handler function.

type NetworkingStateUpdateHandler

type NetworkingStateUpdateHandler func(enabled bool)

NetworkingStateUpdateHandler event handler function

type WirelessConnectionStatus

type WirelessConnectionStatus spec.WirelessConnectionStatus

WirelessConnectionStatus enum type.

func (*WirelessConnectionStatus) String

func (s *WirelessConnectionStatus) String() string

WirelessConnectionStatusToString returns a string representation of a given WirelessConnectionStatus.

type WirelessInterface

type WirelessInterface interface {
	StartAccessPoint(ssid string, passphrase string) error
	GetConnection() *ConnectionInfo
	GetNetworks() []NetworkInfo
	ScanNetwork()
	Connect(ssid string, passphrase string, hidden bool) error
	Disconnect() error

	HandleConnectionStatusUpdate(f ConnectionStatusUpdateHandler)
}

WirelessInterface is the interface for managing the wireless connection.

type WirelessService

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

WirelessService represents the BLE wireless service.

func NewWirelessService

func NewWirelessService(wirelessInterface WirelessInterface) *WirelessService

NewWirelessService initializes a new WirelessService. It wraps an interface to the actual wireless service.

func (*WirelessService) Create

func (w *WirelessService) Create() *ble.Service

Create returns a ble.Service with all the required characteristics for a wireless service.

type WirelessStateUpdateHandler

type WirelessStateUpdateHandler func(enabled bool)

WirelessStateUpdateHandler event handler function.

Directories

Path Synopsis
examples
dummy module

Jump to

Keyboard shortcuts

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