func (d *Device) Advertise(ctx context.Context, adv ble.Advertisement) error {
	rsp, err := d.sendReq(d.pm, cmdAdvertiseStart, xpc.Dict{
		"kCBAdvDataLocalName":    adv.LocalName(),
		"kCBAdvDataServiceUUIDs": adv.Services(),
		"kCBAdvDataAppleMfgData": adv.ManufacturerData(),
	})
	if err != nil {
		return err
	}
	if err := rsp.err(); err != nil {
		return err
	}
	<-ctx.Done()
	_ = d.stopAdvertising()
	return ctx.Err()
}
Advertise advertises the given Advertisement
package darwin
import (
	"bytes"
	"context"
	"encoding/binary"
	"fmt"
	"log"
	"time"
	"github.com/pkg/errors"
	"github.com/raff/goble/xpc"
	"github.com/rigado/ble"
	"sync"
)
type Device struct {
	pm xpc.XPC  
	cm xpc.XPC  
	role int  
	rspc chan msg
	conns    map[string]*conn
	connLock sync.Mutex
	advHandlerSync bool
	advHandler     ble.AdvHandler
	chConn         chan *conn
	chars map[int]*ble.Characteristic
	base  int
}
func NewDevice(opts ...ble.Option) (*Device, error) {
	err := initXpcIDs()
	if err != nil {
		return nil, err
	}
	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(serviceID, d)
	d.cm = xpc.XpcConnect(serviceID, d)
	return d, errors.Wrap(d.Init(), "can't init")
}
func (d *Device) Option(opts ...ble.Option) error {
	var err error
	for _, opt := range opts {
		err = opt(d)
	}
	return err
}
func (d *Device) Init() error {
	rsp, err := d.sendReq(d.cm, cmdInit, xpc.Dict{
		"kCBMsgArgName": fmt.Sprintf("gopher-%v", time.Now().Unix()),
		"kCBMsgArgOptions": xpc.Dict{
			"kCBInitOptionShowPowerAlert": 1,
		},
		"kCBMsgArgType": 0,
	})
	if err != nil {
		return err
	}
	s := State(rsp.state())
	if s != StatePoweredOn {
		return fmt.Errorf("state: %s", s)
	}
	rsp, err = d.sendReq(d.pm, cmdInit, xpc.Dict{
		"kCBMsgArgName": fmt.Sprintf("gopher-%v", time.Now().Unix()),
		"kCBMsgArgOptions": xpc.Dict{
			"kCBInitOptionShowPowerAlert": 1,
		},
		"kCBMsgArgType": 1,
	})
	if err != nil {
		return err
	}
	s = State(rsp.state())
	if s != StatePoweredOn {
		return fmt.Errorf("state: %s", s)
	}
	return nil
}