code: func (p *Client) DiscoverServices(filter []ble.UUID) ([]*ble.Service, error) {
  	p.Lock()
  	defer p.Unlock()
  	if p.profile == nil {
  		p.profile = &ble.Profile{}
  	}
  	start := uint16(0x0001)
  	for {
  		length, b, err := p.ac.ReadByGroupType(start, 0xFFFF, ble.PrimaryServiceUUID)
  		if err == ble.ErrAttrNotFound {
  			return p.profile.Services, nil
  		}
  		if err != nil {
  			return nil, err
  		}
  		for len(b) != 0 {
  			h := binary.LittleEndian.Uint16(b[:2])
  			endh := binary.LittleEndian.Uint16(b[2:4])
  			u := ble.UUID(b[4:length])
  			if filter == nil || ble.Contains(filter, u) {
  				s := &ble.Service{
  					UUID:      u,
  					Handle:    h,
  					EndHandle: endh,
  				}
  				p.profile.Services = append(p.profile.Services, s)
  			}
  			if endh == 0xFFFF {
  				return p.profile.Services, nil
  			}
  			start = endh + 1
  			b = b[length:]
  		}
  	}
  }
docs: // DiscoverServices finds all the primary services on a server. [Vol 3, Part G, 4.4.1]
  // If filter is specified, only filtered services are returned.