Repository navigation
Expand file tree
/
Copy pathble.go
More file actions
76 lines (62 loc) · 3.29 KB
/
Copy pathble.go
File metadata and controls
76 lines (62 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package bluetooth
import "tinygo.org/x/bluetooth/ble"
// The core value types live in the ble subpackage, so that the protocol
// subpackages can use them without an import cycle. These are aliases, not new
// types, so bluetooth.UUID and ble.UUID are interchangeable.
type (
// UUID is a 16-bit, 32-bit, or 128-bit BLE UUID.
UUID = ble.UUID
// MAC represents a MAC address, in little endian format.
MAC = ble.MAC
// MACAddress contains a Bluetooth address which is a MAC address.
MACAddress = ble.MACAddress
// AttributeProtocolError represents an ATT error code as defined in the
// Bluetooth Core Specification, Section 3.4.1.1 (ATT_ERROR_RSP), Table 3.4.
AttributeProtocolError = ble.AttributeProtocolError
)
// ATT error codes from the Bluetooth Core Specification, Table 3.4.
const (
ErrAttInvalidHandle = ble.ErrAttInvalidHandle
ErrAttReadNotPermitted = ble.ErrAttReadNotPermitted
ErrAttWriteNotPermitted = ble.ErrAttWriteNotPermitted
ErrAttInvalidPDU = ble.ErrAttInvalidPDU
ErrAttInsufficientAuthentication = ble.ErrAttInsufficientAuthentication
ErrAttRequestNotSupported = ble.ErrAttRequestNotSupported
ErrAttInvalidOffset = ble.ErrAttInvalidOffset
ErrAttInsufficientAuthorization = ble.ErrAttInsufficientAuthorization
ErrAttPrepareQueueFull = ble.ErrAttPrepareQueueFull
ErrAttNotFound = ble.ErrAttNotFound
ErrAttNotLong = ble.ErrAttNotLong
ErrAttInsufficientEncKeySize = ble.ErrAttInsufficientEncKeySize
ErrAttInvalidLength = ble.ErrAttInvalidLength
ErrAttUnlikelyError = ble.ErrAttUnlikelyError
ErrAttInsufficientEncryption = ble.ErrAttInsufficientEncryption
ErrAttUnsupportedGroupType = ble.ErrAttUnsupportedGroupType
ErrAttInsufficientResources = ble.ErrAttInsufficientResources
ErrAttOutOfSync = ble.ErrAttOutOfSync
ErrAttValueNotAllowed = ble.ErrAttValueNotAllowed
)
// NewUUID returns a new 128-bit UUID for a 16 byte array in big endian order.
func NewUUID(uuid [16]byte) UUID { return ble.NewUUID(uuid) }
// New16BitUUID returns a new 128-bit UUID based on a 16-bit UUID.
func New16BitUUID(shortUUID uint16) UUID { return ble.New16BitUUID(shortUUID) }
// New32BitUUID returns a new 128-bit UUID based on a 32-bit UUID.
func New32BitUUID(shortUUID uint32) UUID { return ble.New32BitUUID(shortUUID) }
// ParseUUID parses the given UUID, which must be in one of the following
// forms: 0000, 00000000, or 00000000-0000-1000-8000-00805F9B34FB.
func ParseUUID(s string) (UUID, error) { return ble.ParseUUID(s) }
// UUIDFromBytes returns the UUID for a 16 byte array in little endian order.
func UUIDFromBytes(b [16]byte) UUID { return ble.UUIDFromBytes(b) }
// ParseMAC parses the given MAC address, which must be in
// 11:22:33:AA:BB:CC format.
func ParseMAC(s string) (MAC, error) { return ble.ParseMAC(s) }
// NewMACAddress returns a MACAddress for the given MAC, marked as random or
// public.
func NewMACAddress(mac MAC, random bool) MACAddress { return ble.NewMACAddress(mac, random) }
// The error values are aliased so that a comparison against the old name still
// holds.
var (
ErrInvalidMAC = ble.ErrInvalidMAC
ErrInvalidBinaryMac = ble.ErrInvalidBinaryMac
ErrInvalidBinaryUUID = ble.ErrInvalidBinaryUUID
)