예제 #1
0
파일: device.go 프로젝트: currantlabs/ble
// 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")
}
예제 #2
0
파일: goble.go 프로젝트: 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
}