File: app_descr.go

package info (click to toggle)
golang-github-muka-go-bluetooth 5.60-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,688 kB
  • sloc: makefile: 92; sh: 2
file content (68 lines) | stat: -rw-r--r-- 1,350 bytes parent folder | download
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
package service

import (
	"github.com/godbus/dbus/v5"
	"github.com/muka/go-bluetooth/api"
	"github.com/muka/go-bluetooth/bluez"
	"github.com/muka/go-bluetooth/bluez/profile/gatt"
)

type DescrReadCallback func(c *Descr, options map[string]interface{}) ([]byte, error)
type DescrWriteCallback func(c *Descr, value []byte) ([]byte, error)

type Descr struct {
	UUID string
	app  *App
	char *Char

	path dbus.ObjectPath

	Properties *gatt.GattDescriptor1Properties
	iprops     *api.DBusProperties

	readCallback  DescrReadCallback
	writeCallback DescrWriteCallback
}

func (s *Descr) DBusProperties() *api.DBusProperties {
	return s.iprops
}

func (s *Descr) DBusObjectManager() *api.DBusObjectManager {
	return s.App().DBusObjectManager()
}

func (s *Descr) DBusConn() *dbus.Conn {
	return s.App().DBusConn()
}

func (s *Descr) Path() dbus.ObjectPath {
	return s.path
}

func (s *Descr) Char() *Char {
	return s.char
}

func (s *Descr) Interface() string {
	return gatt.GattDescriptor1Interface
}

func (s *Descr) GetProperties() bluez.Properties {
	s.Properties.Characteristic = s.char.Path()
	return s.Properties
}

func (s *Descr) App() *App {
	return s.app
}

// Expose descr to dbus
func (s *Descr) Expose() error {
	return api.ExposeDBusService(s)
}

// Remove descr from dbus
func (s *Descr) Remove() error {
	return api.RemoveDBusService(s)
}