Example #1
0
// NewDevice returns a BLE device.
func NewDevice(opts ...Option) (*Device, error) {
	d := &Device{
		rspc:   make(chan msg),
		conns:  make(map[string]*conn),
		chConn: make(chan *conn),
		chars:  make(map[int]*ble.Characteristic),
		base:   1,
	}
	if err := d.Option(opts...); err != nil {
		return nil, err
	}

	d.pm = xpc.XpcConnect("com.apple.blued", d)
	d.cm = xpc.XpcConnect("com.apple.blued", d)

	return d, errors.Wrap(d.Init(), "can't init")
}
Example #2
0
File: goble.go Project: raff/goble
func New() *BLE {
	ble := &BLE{peripherals: map[string]*Peripheral{}, Emitter: Emitter{}}
	ble.Emitter.Init()
	ble.conn = xpc.XpcConnect("com.apple.blued", ble)
	return ble
}