id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
132,100
honeycombio/honeytail
parsers/postgresql/postgresql.go
handleEvents
func (p *Parser) handleEvents(rawEvents <-chan []string, send chan<- event.Event, wg *sync.WaitGroup) { defer wg.Done() // TODO: spin up a group of goroutines to do this for rawEvent := range rawEvents { ev := p.handleEvent(rawEvent) if ev != nil { send <- *ev } } }
go
func (p *Parser) handleEvents(rawEvents <-chan []string, send chan<- event.Event, wg *sync.WaitGroup) { defer wg.Done() // TODO: spin up a group of goroutines to do this for rawEvent := range rawEvents { ev := p.handleEvent(rawEvent) if ev != nil { send <- *ev } } }
[ "func", "(", "p", "*", "Parser", ")", "handleEvents", "(", "rawEvents", "<-", "chan", "[", "]", "string", ",", "send", "chan", "<-", "event", ".", "Event", ",", "wg", "*", "sync", ".", "WaitGroup", ")", "{", "defer", "wg", ".", "Done", "(", ")", ...
// handleEvents receives sets of grouped log lines, each representing a single // log statement. It attempts to parse them, and sends the events it constructs // down the send channel.
[ "handleEvents", "receives", "sets", "of", "grouped", "log", "lines", "each", "representing", "a", "single", "log", "statement", ".", "It", "attempts", "to", "parse", "them", "and", "sends", "the", "events", "it", "constructs", "down", "the", "send", "channel",...
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/postgresql/postgresql.go#L162-L171
132,101
honeycombio/honeytail
parsers/postgresql/postgresql.go
addFieldsToEvent
func addFieldsToEvent(fields map[string]string, ev *event.Event) { for k, v := range fields { // Try to convert values to integer types where sensible, and extract // timestamp for event switch k { case "session_id", "pid", "session_line_number": if typed, err := strconv.Atoi(v); err == nil { ev.Data[k]...
go
func addFieldsToEvent(fields map[string]string, ev *event.Event) { for k, v := range fields { // Try to convert values to integer types where sensible, and extract // timestamp for event switch k { case "session_id", "pid", "session_line_number": if typed, err := strconv.Atoi(v); err == nil { ev.Data[k]...
[ "func", "addFieldsToEvent", "(", "fields", "map", "[", "string", "]", "string", ",", "ev", "*", "event", ".", "Event", ")", "{", "for", "k", ",", "v", ":=", "range", "fields", "{", "// Try to convert values to integer types where sensible, and extract", "// timest...
// addFieldsToEvent takes a map of key-value metadata extracted from a log // line, and adds them to the given event. It'll convert values to integer // types where possible, and try to populate the event's timestamp.
[ "addFieldsToEvent", "takes", "a", "map", "of", "key", "-", "value", "metadata", "extracted", "from", "a", "log", "line", "and", "adds", "them", "to", "the", "given", "event", ".", "It", "ll", "convert", "values", "to", "integer", "types", "where", "possibl...
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/postgresql/postgresql.go#L238-L268
132,102
honeycombio/honeytail
parsers/extregexp.go
FindStringSubmatchMap
func (r *ExtRegexp) FindStringSubmatchMap(s string) (string, map[string]string) { match := r.FindStringSubmatch(s) if match == nil { return "", nil } captures := make(map[string]string) for i, name := range r.SubexpNames() { if i == 0 { continue } if name != "" { // ignore unnamed matches capture...
go
func (r *ExtRegexp) FindStringSubmatchMap(s string) (string, map[string]string) { match := r.FindStringSubmatch(s) if match == nil { return "", nil } captures := make(map[string]string) for i, name := range r.SubexpNames() { if i == 0 { continue } if name != "" { // ignore unnamed matches capture...
[ "func", "(", "r", "*", "ExtRegexp", ")", "FindStringSubmatchMap", "(", "s", "string", ")", "(", "string", ",", "map", "[", "string", "]", "string", ")", "{", "match", ":=", "r", ".", "FindStringSubmatch", "(", "s", ")", "\n", "if", "match", "==", "ni...
// FindStringSubmatchMap behaves the same as FindStringSubmatch except instead // of a list of matches with the names separate, it returns the full match and a // map of named submatches
[ "FindStringSubmatchMap", "behaves", "the", "same", "as", "FindStringSubmatch", "except", "instead", "of", "a", "list", "of", "matches", "with", "the", "names", "separate", "it", "returns", "the", "full", "match", "and", "a", "map", "of", "named", "submatches" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/extregexp.go#L14-L31
132,103
honeycombio/honeytail
leash.go
getParserAndOptions
func getParserAndOptions(options GlobalOptions) (parsers.Parser, interface{}) { var parser parsers.Parser var opts interface{} switch options.Reqs.ParserName { case "regex": parser = &regex.Parser{} opts = &options.Regex opts.(*regex.Options).NumParsers = int(options.NumSenders) case "nginx": parser = &ngi...
go
func getParserAndOptions(options GlobalOptions) (parsers.Parser, interface{}) { var parser parsers.Parser var opts interface{} switch options.Reqs.ParserName { case "regex": parser = &regex.Parser{} opts = &options.Regex opts.(*regex.Options).NumParsers = int(options.NumSenders) case "nginx": parser = &ngi...
[ "func", "getParserAndOptions", "(", "options", "GlobalOptions", ")", "(", "parsers", ".", "Parser", ",", "interface", "{", "}", ")", "{", "var", "parser", "parsers", ".", "Parser", "\n", "var", "opts", "interface", "{", "}", "\n", "switch", "options", ".",...
// getParserOptions takes a parser name and the global options struct // it returns the options group for the specified parser
[ "getParserOptions", "takes", "a", "parser", "name", "and", "the", "global", "options", "struct", "it", "returns", "the", "options", "group", "for", "the", "specified", "parser" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L208-L255
132,104
honeycombio/honeytail
leash.go
makeDynsampleKey
func makeDynsampleKey(ev *event.Event, options GlobalOptions) string { key := make([]string, len(options.DynSample)) for i, field := range options.DynSample { if val, ok := ev.Data[field]; ok { switch val := val.(type) { case bool: key[i] = strconv.FormatBool(val) case int64: key[i] = strconv.Forma...
go
func makeDynsampleKey(ev *event.Event, options GlobalOptions) string { key := make([]string, len(options.DynSample)) for i, field := range options.DynSample { if val, ok := ev.Data[field]; ok { switch val := val.(type) { case bool: key[i] = strconv.FormatBool(val) case int64: key[i] = strconv.Forma...
[ "func", "makeDynsampleKey", "(", "ev", "*", "event", ".", "Event", ",", "options", "GlobalOptions", ")", "string", "{", "key", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "options", ".", "DynSample", ")", ")", "\n", "for", "i", ",", "fiel...
// makeDynsampleKey pulls in all the values necessary from the event to create a // key for dynamic sampling
[ "makeDynsampleKey", "pulls", "in", "all", "the", "values", "necessary", "from", "the", "event", "to", "create", "a", "key", "for", "dynamic", "sampling" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L457-L477
132,105
honeycombio/honeytail
leash.go
whitelistKey
func whitelistKey(whiteKeys []string, key string) bool { for _, whiteKey := range whiteKeys { if key == whiteKey { return true } } return false }
go
func whitelistKey(whiteKeys []string, key string) bool { for _, whiteKey := range whiteKeys { if key == whiteKey { return true } } return false }
[ "func", "whitelistKey", "(", "whiteKeys", "[", "]", "string", ",", "key", "string", ")", "bool", "{", "for", "_", ",", "whiteKey", ":=", "range", "whiteKeys", "{", "if", "key", "==", "whiteKey", "{", "return", "true", "\n", "}", "\n", "}", "\n", "ret...
// return true if the key is in the whitelist
[ "return", "true", "if", "the", "key", "is", "in", "the", "whitelist" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L547-L554
132,106
honeycombio/honeytail
leash.go
sendToLibhoney
func sendToLibhoney(ctx context.Context, toBeSent chan event.Event, toBeResent chan event.Event, delaySending chan int, doneSending chan bool) { for { // check and see if we need to back off the API because of rate limiting select { case delay := <-delaySending: time.Sleep(time.Duration(delay) * time.Millise...
go
func sendToLibhoney(ctx context.Context, toBeSent chan event.Event, toBeResent chan event.Event, delaySending chan int, doneSending chan bool) { for { // check and see if we need to back off the API because of rate limiting select { case delay := <-delaySending: time.Sleep(time.Duration(delay) * time.Millise...
[ "func", "sendToLibhoney", "(", "ctx", "context", ".", "Context", ",", "toBeSent", "chan", "event", ".", "Event", ",", "toBeResent", "chan", "event", ".", "Event", ",", "delaySending", "chan", "int", ",", "doneSending", "chan", "bool", ")", "{", "for", "{",...
// sendToLibhoney reads from the toBeSent channel and shoves the events into // libhoney events, sending them on their way.
[ "sendToLibhoney", "reads", "from", "the", "toBeSent", "channel", "and", "shoves", "the", "events", "into", "libhoney", "events", "sending", "them", "on", "their", "way", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L558-L592
132,107
honeycombio/honeytail
leash.go
sendEvent
func sendEvent(ev event.Event) { if ev.SampleRate == -1 { // drop the event! logrus.WithFields(logrus.Fields{ "event": ev, }).Debug("droppped event due to sampling") return } libhEv := libhoney.NewEvent() libhEv.Metadata = ev libhEv.Timestamp = ev.Timestamp libhEv.SampleRate = uint(ev.SampleRate) if e...
go
func sendEvent(ev event.Event) { if ev.SampleRate == -1 { // drop the event! logrus.WithFields(logrus.Fields{ "event": ev, }).Debug("droppped event due to sampling") return } libhEv := libhoney.NewEvent() libhEv.Metadata = ev libhEv.Timestamp = ev.Timestamp libhEv.SampleRate = uint(ev.SampleRate) if e...
[ "func", "sendEvent", "(", "ev", "event", ".", "Event", ")", "{", "if", "ev", ".", "SampleRate", "==", "-", "1", "{", "// drop the event!", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "ev", ",", "}", ")", ".", "D...
// sendEvent does the actual handoff to libhoney
[ "sendEvent", "does", "the", "actual", "handoff", "to", "libhoney" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L595-L619
132,108
honeycombio/honeytail
leash.go
handleResponses
func handleResponses(responses chan libhoney.Response, stats *responseStats, toBeResent chan event.Event, delaySending chan int, options GlobalOptions) { go logStats(stats, options.StatusInterval) for rsp := range responses { stats.update(rsp) logfields := logrus.Fields{ "status_code": rsp.StatusCode, "b...
go
func handleResponses(responses chan libhoney.Response, stats *responseStats, toBeResent chan event.Event, delaySending chan int, options GlobalOptions) { go logStats(stats, options.StatusInterval) for rsp := range responses { stats.update(rsp) logfields := logrus.Fields{ "status_code": rsp.StatusCode, "b...
[ "func", "handleResponses", "(", "responses", "chan", "libhoney", ".", "Response", ",", "stats", "*", "responseStats", ",", "toBeResent", "chan", "event", ".", "Event", ",", "delaySending", "chan", "int", ",", "options", "GlobalOptions", ")", "{", "go", "logSta...
// handleResponses reads from the response queue, logging a summary and debug // re-enqueues any events that failed to send in a retryable way
[ "handleResponses", "reads", "from", "the", "response", "queue", "logging", "a", "summary", "and", "debug", "re", "-", "enqueues", "any", "events", "that", "failed", "to", "send", "in", "a", "retryable", "way" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L623-L647
132,109
honeycombio/honeytail
leash.go
logStats
func logStats(stats *responseStats, interval uint) { logrus.Debugf("Initializing stats reporting. Will print stats once/%d seconds", interval) if interval == 0 { // interval of 0 means don't print summary status return } ticker := time.NewTicker(time.Second * time.Duration(interval)) for range ticker.C { sta...
go
func logStats(stats *responseStats, interval uint) { logrus.Debugf("Initializing stats reporting. Will print stats once/%d seconds", interval) if interval == 0 { // interval of 0 means don't print summary status return } ticker := time.NewTicker(time.Second * time.Duration(interval)) for range ticker.C { sta...
[ "func", "logStats", "(", "stats", "*", "responseStats", ",", "interval", "uint", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "interval", ")", "\n", "if", "interval", "==", "0", "{", "// interval of 0 means don't print summary status", "return", "\...
// logStats dumps and resets the stats once every minute
[ "logStats", "dumps", "and", "resets", "the", "stats", "once", "every", "minute" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/leash.go#L650-L660
132,110
honeycombio/honeytail
parsers/nginx/nginx.go
typeifyParsedLine
func typeifyParsedLine(pl map[string]string) map[string]interface{} { // try to convert numbers, if possible msi := make(map[string]interface{}, len(pl)) for k, v := range pl { switch { case strings.Contains(v, "."): f, err := strconv.ParseFloat(v, 64) if err == nil { msi[k] = f continue } cas...
go
func typeifyParsedLine(pl map[string]string) map[string]interface{} { // try to convert numbers, if possible msi := make(map[string]interface{}, len(pl)) for k, v := range pl { switch { case strings.Contains(v, "."): f, err := strconv.ParseFloat(v, 64) if err == nil { msi[k] = f continue } cas...
[ "func", "typeifyParsedLine", "(", "pl", "map", "[", "string", "]", "string", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "// try to convert numbers, if possible", "msi", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", "...
// typeifyParsedLine attempts to cast numbers in the event to floats or ints
[ "typeifyParsedLine", "attempts", "to", "cast", "numbers", "in", "the", "event", "to", "floats", "or", "ints" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/nginx/nginx.go#L127-L151
132,111
honeycombio/honeytail
parsers/nginx/nginx.go
getTimestamp
func (n *Parser) getTimestamp(evMap map[string]interface{}) time.Time { var ( setBothFieldsMsg = "Timestamp format and field must both be set to be used, one was not. Using current time instead." ) // Custom (user-defined) timestamp field/format takes priority over the // default parsing behavior. Try that first...
go
func (n *Parser) getTimestamp(evMap map[string]interface{}) time.Time { var ( setBothFieldsMsg = "Timestamp format and field must both be set to be used, one was not. Using current time instead." ) // Custom (user-defined) timestamp field/format takes priority over the // default parsing behavior. Try that first...
[ "func", "(", "n", "*", "Parser", ")", "getTimestamp", "(", "evMap", "map", "[", "string", "]", "interface", "{", "}", ")", "time", ".", "Time", "{", "var", "(", "setBothFieldsMsg", "=", "\"", "\"", "\n", ")", "\n\n", "// Custom (user-defined) timestamp fie...
// tries to extract a timestamp from the log line
[ "tries", "to", "extract", "a", "timestamp", "from", "the", "log", "line" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/nginx/nginx.go#L154-L182
132,112
honeycombio/honeytail
tail/tail.go
GetSampledEntries
func GetSampledEntries(ctx context.Context, conf Config, sampleRate uint) ([]chan string, error) { unsampledLinesChans, err := GetEntries(ctx, conf) if err != nil { return nil, err } if sampleRate == 1 { return unsampledLinesChans, nil } sampledLinesChans := make([]chan string, 0, len(unsampledLinesChans)) ...
go
func GetSampledEntries(ctx context.Context, conf Config, sampleRate uint) ([]chan string, error) { unsampledLinesChans, err := GetEntries(ctx, conf) if err != nil { return nil, err } if sampleRate == 1 { return unsampledLinesChans, nil } sampledLinesChans := make([]chan string, 0, len(unsampledLinesChans)) ...
[ "func", "GetSampledEntries", "(", "ctx", "context", ".", "Context", ",", "conf", "Config", ",", "sampleRate", "uint", ")", "(", "[", "]", "chan", "string", ",", "error", ")", "{", "unsampledLinesChans", ",", "err", ":=", "GetEntries", "(", "ctx", ",", "c...
// GetSampledEntries wraps GetEntries and returns a list of channels that // provide sampled entries
[ "GetSampledEntries", "wraps", "GetEntries", "and", "returns", "a", "list", "of", "channels", "that", "provide", "sampled", "entries" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L68-L97
132,113
honeycombio/honeytail
tail/tail.go
GetEntries
func GetEntries(ctx context.Context, conf Config) ([]chan string, error) { if conf.Type != RotateStyleSyslog { return nil, errors.New("Only Syslog style rotation currently supported") } // expand any globs in the list of files so our list all represents real files var filenames []string for _, filePath := range ...
go
func GetEntries(ctx context.Context, conf Config) ([]chan string, error) { if conf.Type != RotateStyleSyslog { return nil, errors.New("Only Syslog style rotation currently supported") } // expand any globs in the list of files so our list all represents real files var filenames []string for _, filePath := range ...
[ "func", "GetEntries", "(", "ctx", "context", ".", "Context", ",", "conf", "Config", ")", "(", "[", "]", "chan", "string", ",", "error", ")", "{", "if", "conf", ".", "Type", "!=", "RotateStyleSyslog", "{", "return", "nil", ",", "errors", ".", "New", "...
// GetEntries sets up a list of channels that get one line at a time from each // file down each channel.
[ "GetEntries", "sets", "up", "a", "list", "of", "channels", "that", "get", "one", "line", "at", "a", "time", "from", "each", "file", "down", "each", "channel", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L109-L151
132,114
honeycombio/honeytail
tail/tail.go
removeStateFiles
func removeStateFiles(files []string, conf Config) []string { newFiles := []string{} for _, file := range files { if file == conf.Options.StateFile { logrus.WithFields(logrus.Fields{ "file": file, }).Debug("skipping tailing file because it is named the same as the statefile flag") continue } if str...
go
func removeStateFiles(files []string, conf Config) []string { newFiles := []string{} for _, file := range files { if file == conf.Options.StateFile { logrus.WithFields(logrus.Fields{ "file": file, }).Debug("skipping tailing file because it is named the same as the statefile flag") continue } if str...
[ "func", "removeStateFiles", "(", "files", "[", "]", "string", ",", "conf", "Config", ")", "[", "]", "string", "{", "newFiles", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "file", ":=", "range", "files", "{", "if", "file", "==", "conf...
// removeStateFiles goes through the list of files and removes any that appear // to be statefiles to avoid .leash.state.leash.state.leash.state from appearing // when you use an overly permissive glob
[ "removeStateFiles", "goes", "through", "the", "list", "of", "files", "and", "removes", "any", "that", "appear", "to", "be", "statefiles", "to", "avoid", ".", "leash", ".", "state", ".", "leash", ".", "state", ".", "leash", ".", "state", "from", "appearing"...
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L156-L175
132,115
honeycombio/honeytail
tail/tail.go
tailStdIn
func tailStdIn(ctx context.Context) chan string { lines := make(chan string) input := bufio.NewReader(os.Stdin) go func() { defer close(lines) for { // check for signal triggered exit select { case <-ctx.Done(): return default: } line, partialLine, err := input.ReadLine() if err != nil {...
go
func tailStdIn(ctx context.Context) chan string { lines := make(chan string) input := bufio.NewReader(os.Stdin) go func() { defer close(lines) for { // check for signal triggered exit select { case <-ctx.Done(): return default: } line, partialLine, err := input.ReadLine() if err != nil {...
[ "func", "tailStdIn", "(", "ctx", "context", ".", "Context", ")", "chan", "string", "{", "lines", ":=", "make", "(", "chan", "string", ")", "\n", "input", ":=", "bufio", ".", "NewReader", "(", "os", ".", "Stdin", ")", "\n", "go", "func", "(", ")", "...
// tailStdIn is a special case to tail STDIN without any of the // fancy stuff that the tail module provides
[ "tailStdIn", "is", "a", "special", "case", "to", "tail", "STDIN", "without", "any", "of", "the", "fancy", "stuff", "that", "the", "tail", "module", "provides" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L257-L285
132,116
honeycombio/honeytail
tail/tail.go
getStartLocation
func getStartLocation(stateFile string, logfile string) *tail.SeekInfo { beginning := &tail.SeekInfo{} end := &tail.SeekInfo{0, 2} fh, err := os.Open(stateFile) if err != nil { logrus.WithFields(logrus.Fields{ "starting at": "end", "error": err, }).Debug("getStartLocation failed to open the statefile") ret...
go
func getStartLocation(stateFile string, logfile string) *tail.SeekInfo { beginning := &tail.SeekInfo{} end := &tail.SeekInfo{0, 2} fh, err := os.Open(stateFile) if err != nil { logrus.WithFields(logrus.Fields{ "starting at": "end", "error": err, }).Debug("getStartLocation failed to open the statefile") ret...
[ "func", "getStartLocation", "(", "stateFile", "string", ",", "logfile", "string", ")", "*", "tail", ".", "SeekInfo", "{", "beginning", ":=", "&", "tail", ".", "SeekInfo", "{", "}", "\n", "end", ":=", "&", "tail", ".", "SeekInfo", "{", "0", ",", "2", ...
// getStartLocation reads the state file and creates an appropriate start // location. See details at the top of this file on how the loc is chosen.
[ "getStartLocation", "reads", "the", "state", "file", "and", "creates", "an", "appropriate", "start", "location", ".", "See", "details", "at", "the", "top", "of", "this", "file", "on", "how", "the", "loc", "is", "chosen", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L289-L342
132,117
honeycombio/honeytail
tail/tail.go
updateStateFile
func updateStateFile(state *State, t *tail.Tail, file string, stateFh *os.File) { logStat := unix.Stat_t{} unix.Stat(file, &logStat) currentPos, err := t.Tell() if err != nil { return } state.INode = uint64(logStat.Ino) state.Offset = currentPos out, err := json.Marshal(state) if err != nil { return } st...
go
func updateStateFile(state *State, t *tail.Tail, file string, stateFh *os.File) { logStat := unix.Stat_t{} unix.Stat(file, &logStat) currentPos, err := t.Tell() if err != nil { return } state.INode = uint64(logStat.Ino) state.Offset = currentPos out, err := json.Marshal(state) if err != nil { return } st...
[ "func", "updateStateFile", "(", "state", "*", "State", ",", "t", "*", "tail", ".", "Tail", ",", "file", "string", ",", "stateFh", "*", "os", ".", "File", ")", "{", "logStat", ":=", "unix", ".", "Stat_t", "{", "}", "\n", "unix", ".", "Stat", "(", ...
// updateStateFile updates the state file once per second with the current // values for the logfile's inode number and offset
[ "updateStateFile", "updates", "the", "state", "file", "once", "per", "second", "with", "the", "current", "values", "for", "the", "logfile", "s", "inode", "number", "and", "offset" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/tail/tail.go#L424-L441
132,118
honeycombio/honeytail
parsers/regex/regex.go
ParseLineRegexes
func ParseLineRegexes(regexStrs []string) ([]*regexp.Regexp, error) { regexes := make([]*regexp.Regexp, 0) for _, regexStr := range regexStrs { regex, err := ParseLineRegex(regexStr) if err != nil { return regexes, err } regexes = append(regexes, regex) } return regexes, nil }
go
func ParseLineRegexes(regexStrs []string) ([]*regexp.Regexp, error) { regexes := make([]*regexp.Regexp, 0) for _, regexStr := range regexStrs { regex, err := ParseLineRegex(regexStr) if err != nil { return regexes, err } regexes = append(regexes, regex) } return regexes, nil }
[ "func", "ParseLineRegexes", "(", "regexStrs", "[", "]", "string", ")", "(", "[", "]", "*", "regexp", ".", "Regexp", ",", "error", ")", "{", "regexes", ":=", "make", "(", "[", "]", "*", "regexp", ".", "Regexp", ",", "0", ")", "\n", "for", "_", ","...
// Compile multiple log line regexes
[ "Compile", "multiple", "log", "line", "regexes" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/regex/regex.go#L51-L61
132,119
honeycombio/honeytail
parsers/regex/regex.go
ParseLineRegex
func ParseLineRegex(regexStr string) (*regexp.Regexp, error) { // Regex can't be blank if regexStr == "" { logrus.Debug("LineRegex is blank; required field") return nil, errors.New("Must provide a regex for parsing log lines; use `--regex.line_regex` flag.") } // Compile regex lineRegex, err := regexp.Compile...
go
func ParseLineRegex(regexStr string) (*regexp.Regexp, error) { // Regex can't be blank if regexStr == "" { logrus.Debug("LineRegex is blank; required field") return nil, errors.New("Must provide a regex for parsing log lines; use `--regex.line_regex` flag.") } // Compile regex lineRegex, err := regexp.Compile...
[ "func", "ParseLineRegex", "(", "regexStr", "string", ")", "(", "*", "regexp", ".", "Regexp", ",", "error", ")", "{", "// Regex can't be blank", "if", "regexStr", "==", "\"", "\"", "{", "logrus", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", ...
// Compile a regex & validate expectations for log line parsing
[ "Compile", "a", "regex", "&", "validate", "expectations", "for", "log", "line", "parsing" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/regex/regex.go#L64-L95
132,120
honeycombio/honeytail
response_stats.go
newResponseStats
func newResponseStats() *responseStats { r := &responseStats{} r.totalStatusCodes = make(map[int]int) r.lock = &sync.Mutex{} r.reset() return r }
go
func newResponseStats() *responseStats { r := &responseStats{} r.totalStatusCodes = make(map[int]int) r.lock = &sync.Mutex{} r.reset() return r }
[ "func", "newResponseStats", "(", ")", "*", "responseStats", "{", "r", ":=", "&", "responseStats", "{", "}", "\n", "r", ".", "totalStatusCodes", "=", "make", "(", "map", "[", "int", "]", "int", ")", "\n", "r", ".", "lock", "=", "&", "sync", ".", "Mu...
// newResponseStats initializes the struct's complex data types
[ "newResponseStats", "initializes", "the", "struct", "s", "complex", "data", "types" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L36-L42
132,121
honeycombio/honeytail
response_stats.go
update
func (r *responseStats) update(rsp libhoney.Response) { r.lock.Lock() defer r.lock.Unlock() r.count += 1 r.statusCodes[rsp.StatusCode] += 1 r.bodies[strings.TrimSpace(string(rsp.Body))] += 1 if rsp.Err != nil { r.errors[rsp.Err.Error()] += 1 } if r.minDuration == 0 { r.minDuration = rsp.Duration } if rsp....
go
func (r *responseStats) update(rsp libhoney.Response) { r.lock.Lock() defer r.lock.Unlock() r.count += 1 r.statusCodes[rsp.StatusCode] += 1 r.bodies[strings.TrimSpace(string(rsp.Body))] += 1 if rsp.Err != nil { r.errors[rsp.Err.Error()] += 1 } if r.minDuration == 0 { r.minDuration = rsp.Duration } if rsp....
[ "func", "(", "r", "*", "responseStats", ")", "update", "(", "rsp", "libhoney", ".", "Response", ")", "{", "r", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "lock", ".", "Unlock", "(", ")", "\n", "r", ".", "count", "+=", "1", "\n...
// update adds a response into the stats container
[ "update", "adds", "a", "response", "into", "the", "stats", "container" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L45-L65
132,122
honeycombio/honeytail
response_stats.go
logAndReset
func (r *responseStats) logAndReset() { r.lock.Lock() defer r.lock.Unlock() r.log() r.reset() }
go
func (r *responseStats) logAndReset() { r.lock.Lock() defer r.lock.Unlock() r.log() r.reset() }
[ "func", "(", "r", "*", "responseStats", ")", "logAndReset", "(", ")", "{", "r", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "lock", ".", "Unlock", "(", ")", "\n", "r", ".", "log", "(", ")", "\n", "r", ".", "reset", "(", ")", ...
// log the current stats and reset them all to zero. // thread safe.
[ "log", "the", "current", "stats", "and", "reset", "them", "all", "to", "zero", ".", "thread", "safe", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L69-L74
132,123
honeycombio/honeytail
response_stats.go
log
func (r *responseStats) log() { var avg time.Duration if r.count != 0 { avg = r.sumDuration / time.Duration(r.count) } else { avg = 0 } logrus.WithFields(logrus.Fields{ "count": r.count, "lifetime_count": r.totalCount + r.count, "slowest": r.maxDuration, "fastest": r.minD...
go
func (r *responseStats) log() { var avg time.Duration if r.count != 0 { avg = r.sumDuration / time.Duration(r.count) } else { avg = 0 } logrus.WithFields(logrus.Fields{ "count": r.count, "lifetime_count": r.totalCount + r.count, "slowest": r.maxDuration, "fastest": r.minD...
[ "func", "(", "r", "*", "responseStats", ")", "log", "(", ")", "{", "var", "avg", "time", ".", "Duration", "\n", "if", "r", ".", "count", "!=", "0", "{", "avg", "=", "r", ".", "sumDuration", "/", "time", ".", "Duration", "(", "r", ".", "count", ...
// log the current statistics to logrus. // NOT thread safe.
[ "log", "the", "current", "statistics", "to", "logrus", ".", "NOT", "thread", "safe", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L78-L101
132,124
honeycombio/honeytail
response_stats.go
logFinal
func (r *responseStats) logFinal() { r.lock.Lock() defer r.lock.Unlock() r.totalCount += r.count for code, count := range r.statusCodes { r.totalStatusCodes[code] += count } logrus.WithFields(logrus.Fields{ "total attempted sends": r.totalCount, "number sent by response status code": r.totalSt...
go
func (r *responseStats) logFinal() { r.lock.Lock() defer r.lock.Unlock() r.totalCount += r.count for code, count := range r.statusCodes { r.totalStatusCodes[code] += count } logrus.WithFields(logrus.Fields{ "total attempted sends": r.totalCount, "number sent by response status code": r.totalSt...
[ "func", "(", "r", "*", "responseStats", ")", "logFinal", "(", ")", "{", "r", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "lock", ".", "Unlock", "(", ")", "\n", "r", ".", "totalCount", "+=", "r", ".", "count", "\n", "for", "code...
// log the total count on its own
[ "log", "the", "total", "count", "on", "its", "own" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L104-L115
132,125
honeycombio/honeytail
response_stats.go
reset
func (r *responseStats) reset() { r.totalCount += r.count for code, count := range r.statusCodes { r.totalStatusCodes[code] += count } r.count = 0 r.statusCodes = make(map[int]int) r.bodies = make(map[string]int) r.errors = make(map[string]int) r.maxDuration = 0 r.sumDuration = 0 r.minDuration = 0 }
go
func (r *responseStats) reset() { r.totalCount += r.count for code, count := range r.statusCodes { r.totalStatusCodes[code] += count } r.count = 0 r.statusCodes = make(map[int]int) r.bodies = make(map[string]int) r.errors = make(map[string]int) r.maxDuration = 0 r.sumDuration = 0 r.minDuration = 0 }
[ "func", "(", "r", "*", "responseStats", ")", "reset", "(", ")", "{", "r", ".", "totalCount", "+=", "r", ".", "count", "\n", "for", "code", ",", "count", ":=", "range", "r", ".", "statusCodes", "{", "r", ".", "totalStatusCodes", "[", "code", "]", "+...
// reset the counters to zero. // NOT thread safe
[ "reset", "the", "counters", "to", "zero", ".", "NOT", "thread", "safe" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/response_stats.go#L119-L131
132,126
honeycombio/honeytail
main.go
setVersionUserAgent
func setVersionUserAgent(backfill bool, parserName string) { if BuildID == "" { version = "dev" } else { version = BuildID } if backfill { parserName += " backfill" } libhoney.UserAgentAddition = fmt.Sprintf("honeytail/%s (%s)", version, parserName) }
go
func setVersionUserAgent(backfill bool, parserName string) { if BuildID == "" { version = "dev" } else { version = BuildID } if backfill { parserName += " backfill" } libhoney.UserAgentAddition = fmt.Sprintf("honeytail/%s (%s)", version, parserName) }
[ "func", "setVersionUserAgent", "(", "backfill", "bool", ",", "parserName", "string", ")", "{", "if", "BuildID", "==", "\"", "\"", "{", "version", "=", "\"", "\"", "\n", "}", "else", "{", "version", "=", "BuildID", "\n", "}", "\n", "if", "backfill", "{"...
// setVersion sets the internal version ID and updates libhoney's user-agent
[ "setVersion", "sets", "the", "internal", "version", "ID", "and", "updates", "libhoney", "s", "user", "-", "agent" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/main.go#L199-L209
132,127
honeycombio/honeytail
main.go
handleOtherModes
func handleOtherModes(fp *flag.Parser, modes OtherModes) { if modes.Version { fmt.Println("Honeytail version", version) os.Exit(0) } if modes.Help { fp.WriteHelp(os.Stdout) fmt.Println("") os.Exit(0) } if modes.WriteManPage { fp.WriteManPage(os.Stdout) os.Exit(0) } if modes.WriteDefaultConfig { i...
go
func handleOtherModes(fp *flag.Parser, modes OtherModes) { if modes.Version { fmt.Println("Honeytail version", version) os.Exit(0) } if modes.Help { fp.WriteHelp(os.Stdout) fmt.Println("") os.Exit(0) } if modes.WriteManPage { fp.WriteManPage(os.Stdout) os.Exit(0) } if modes.WriteDefaultConfig { i...
[ "func", "handleOtherModes", "(", "fp", "*", "flag", ".", "Parser", ",", "modes", "OtherModes", ")", "{", "if", "modes", ".", "Version", "{", "fmt", ".", "Println", "(", "\"", "\"", ",", "version", ")", "\n", "os", ".", "Exit", "(", "0", ")", "\n", ...
// handleOtherModes takse care of all flags that say we should just do something // and exit rather than actually parsing logs
[ "handleOtherModes", "takse", "care", "of", "all", "flags", "that", "say", "we", "should", "just", "do", "something", "and", "exit", "rather", "than", "actually", "parsing", "logs" ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/main.go#L213-L242
132,128
honeycombio/honeytail
parsers/arangodb/arangodb.go
ParseLine
func (m *ArangoLineParser) ParseLine(line string) (_ map[string]interface{}, err error) { // Do the actual work here, we look for log lines in the log topic "requests", // there are two types, one is a DEBUG line (could be switched off) containing // the request body, the other is the INFO line marking the end of th...
go
func (m *ArangoLineParser) ParseLine(line string) (_ map[string]interface{}, err error) { // Do the actual work here, we look for log lines in the log topic "requests", // there are two types, one is a DEBUG line (could be switched off) containing // the request body, the other is the INFO line marking the end of th...
[ "func", "(", "m", "*", "ArangoLineParser", ")", "ParseLine", "(", "line", "string", ")", "(", "_", "map", "[", "string", "]", "interface", "{", "}", ",", "err", "error", ")", "{", "// Do the actual work here, we look for log lines in the log topic \"requests\",", ...
// ParseLine method for an ArangoLineParser implementing LineParser.
[ "ParseLine", "method", "for", "an", "ArangoLineParser", "implementing", "LineParser", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/arangodb/arangodb.go#L99-L160
132,129
honeycombio/honeytail
parsers/arangodb/arangodb.go
ProcessLines
func (p *Parser) ProcessLines(lines <-chan string, send chan<- event.Event, prefixRegex *parsers.ExtRegexp) { wg := sync.WaitGroup{} for i := 0; i < numParsers; i++ { wg.Add(1) go func() { for line := range lines { line = strings.TrimSpace(line) // take care of any headers on the line var prefixFie...
go
func (p *Parser) ProcessLines(lines <-chan string, send chan<- event.Event, prefixRegex *parsers.ExtRegexp) { wg := sync.WaitGroup{} for i := 0; i < numParsers; i++ { wg.Add(1) go func() { for line := range lines { line = strings.TrimSpace(line) // take care of any headers on the line var prefixFie...
[ "func", "(", "p", "*", "Parser", ")", "ProcessLines", "(", "lines", "<-", "chan", "string", ",", "send", "chan", "<-", "event", ".", "Event", ",", "prefixRegex", "*", "parsers", ".", "ExtRegexp", ")", "{", "wg", ":=", "sync", ".", "WaitGroup", "{", "...
// ProcessLines method for Parser.
[ "ProcessLines", "method", "for", "Parser", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/parsers/arangodb/arangodb.go#L170-L221
132,130
honeycombio/honeytail
sample/deterministic_sampler.go
bytesToUint32be
func bytesToUint32be(b []byte) uint32 { return uint32(b[3]) | (uint32(b[2]) << 8) | (uint32(b[1]) << 16) | (uint32(b[0]) << 24) }
go
func bytesToUint32be(b []byte) uint32 { return uint32(b[3]) | (uint32(b[2]) << 8) | (uint32(b[1]) << 16) | (uint32(b[0]) << 24) }
[ "func", "bytesToUint32be", "(", "b", "[", "]", "byte", ")", "uint32", "{", "return", "uint32", "(", "b", "[", "3", "]", ")", "|", "(", "uint32", "(", "b", "[", "2", "]", ")", "<<", "8", ")", "|", "(", "uint32", "(", "b", "[", "1", "]", ")",...
// bytesToUint32 takes a slice of 4 bytes representing a big endian 32 bit // unsigned value and returns the equivalent uint32.
[ "bytesToUint32", "takes", "a", "slice", "of", "4", "bytes", "representing", "a", "big", "endian", "32", "bit", "unsigned", "value", "and", "returns", "the", "equivalent", "uint32", "." ]
a4d169e4b0f5204538da680d276e09be979ee26c
https://github.com/honeycombio/honeytail/blob/a4d169e4b0f5204538da680d276e09be979ee26c/sample/deterministic_sampler.go#L43-L45
132,131
currantlabs/ble
uuid.go
Parse
func Parse(s string) (UUID, error) { s = strings.Replace(s, "-", "", -1) b, err := hex.DecodeString(s) if err != nil { return nil, err } if err := lenErr(len(b)); err != nil { return nil, err } return UUID(Reverse(b)), nil }
go
func Parse(s string) (UUID, error) { s = strings.Replace(s, "-", "", -1) b, err := hex.DecodeString(s) if err != nil { return nil, err } if err := lenErr(len(b)); err != nil { return nil, err } return UUID(Reverse(b)), nil }
[ "func", "Parse", "(", "s", "string", ")", "(", "UUID", ",", "error", ")", "{", "s", "=", "strings", ".", "Replace", "(", "s", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "b", ",", "err", ":=", "hex", ".", "DecodeString", "(", ...
// Parse parses a standard-format UUID string, such // as "1800" or "34DA3AD1-7110-41A1-B1EF-4430F509CDE7".
[ "Parse", "parses", "a", "standard", "-", "format", "UUID", "string", "such", "as", "1800", "or", "34DA3AD1", "-", "7110", "-", "41A1", "-", "B1EF", "-", "4430F509CDE7", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/uuid.go#L23-L33
132,132
currantlabs/ble
uuid.go
MustParse
func MustParse(s string) UUID { u, err := Parse(s) if err != nil { panic(err) } return u }
go
func MustParse(s string) UUID { u, err := Parse(s) if err != nil { panic(err) } return u }
[ "func", "MustParse", "(", "s", "string", ")", "UUID", "{", "u", ",", "err", ":=", "Parse", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "u", "\n", "}" ]
// MustParse parses a standard-format UUID string, // like Parse, but panics in case of error.
[ "MustParse", "parses", "a", "standard", "-", "format", "UUID", "string", "like", "Parse", "but", "panics", "in", "case", "of", "error", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/uuid.go#L37-L43
132,133
currantlabs/ble
uuid.go
Contains
func Contains(s []UUID, u UUID) bool { if s == nil { return true } for _, a := range s { if a.Equal(u) { return true } } return false }
go
func Contains(s []UUID, u UUID) bool { if s == nil { return true } for _, a := range s { if a.Equal(u) { return true } } return false }
[ "func", "Contains", "(", "s", "[", "]", "UUID", ",", "u", "UUID", ")", "bool", "{", "if", "s", "==", "nil", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "a", ":=", "range", "s", "{", "if", "a", ".", "Equal", "(", "u", ")", "{"...
// Contains returns a boolean reporting whether u is in the slice s.
[ "Contains", "returns", "a", "boolean", "reporting", "whether", "u", "is", "in", "the", "slice", "s", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/uuid.go#L71-L83
132,134
currantlabs/ble
uuid.go
Reverse
func Reverse(u []byte) []byte { // Special-case 16 bit UUIDS for speed. l := len(u) if l == 2 { return []byte{u[1], u[0]} } b := make([]byte, l) for i := 0; i < l/2+1; i++ { b[i], b[l-i-1] = u[l-i-1], u[i] } return b }
go
func Reverse(u []byte) []byte { // Special-case 16 bit UUIDS for speed. l := len(u) if l == 2 { return []byte{u[1], u[0]} } b := make([]byte, l) for i := 0; i < l/2+1; i++ { b[i], b[l-i-1] = u[l-i-1], u[i] } return b }
[ "func", "Reverse", "(", "u", "[", "]", "byte", ")", "[", "]", "byte", "{", "// Special-case 16 bit UUIDS for speed.", "l", ":=", "len", "(", "u", ")", "\n", "if", "l", "==", "2", "{", "return", "[", "]", "byte", "{", "u", "[", "1", "]", ",", "u",...
// Reverse returns a reversed copy of u.
[ "Reverse", "returns", "a", "reversed", "copy", "of", "u", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/uuid.go#L86-L97
132,135
currantlabs/ble
linux/hci/buffer.go
Get
func (c *Client) Get() *bytes.Buffer { b := <-c.p.ch b.Reset() c.sent <- b return b }
go
func (c *Client) Get() *bytes.Buffer { b := <-c.p.ch b.Reset() c.sent <- b return b }
[ "func", "(", "c", "*", "Client", ")", "Get", "(", ")", "*", "bytes", ".", "Buffer", "{", "b", ":=", "<-", "c", ".", "p", ".", "ch", "\n", "b", ".", "Reset", "(", ")", "\n", "c", ".", "sent", "<-", "b", "\n", "return", "b", "\n", "}" ]
// Get returns a buffer from the shared buffer pool.
[ "Get", "returns", "a", "buffer", "from", "the", "shared", "buffer", "pool", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/buffer.go#L48-L53
132,136
currantlabs/ble
linux/hci/buffer.go
Put
func (c *Client) Put() { select { case b := <-c.sent: c.p.ch <- b default: } }
go
func (c *Client) Put() { select { case b := <-c.sent: c.p.ch <- b default: } }
[ "func", "(", "c", "*", "Client", ")", "Put", "(", ")", "{", "select", "{", "case", "b", ":=", "<-", "c", ".", "sent", ":", "c", ".", "p", ".", "ch", "<-", "b", "\n", "default", ":", "}", "\n", "}" ]
// Put puts the oldest sent buffer back to the shared pool.
[ "Put", "puts", "the", "oldest", "sent", "buffer", "back", "to", "the", "shared", "pool", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/buffer.go#L56-L62
132,137
currantlabs/ble
linux/hci/buffer.go
PutAll
func (c *Client) PutAll() { for { select { case b := <-c.sent: c.p.ch <- b default: return } } }
go
func (c *Client) PutAll() { for { select { case b := <-c.sent: c.p.ch <- b default: return } } }
[ "func", "(", "c", "*", "Client", ")", "PutAll", "(", ")", "{", "for", "{", "select", "{", "case", "b", ":=", "<-", "c", ".", "sent", ":", "c", ".", "p", ".", "ch", "<-", "b", "\n", "default", ":", "return", "\n", "}", "\n", "}", "\n", "}" ]
// PutAll puts all the sent buffers back to the shared pool.
[ "PutAll", "puts", "all", "the", "sent", "buffers", "back", "to", "the", "shared", "pool", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/buffer.go#L65-L74
132,138
currantlabs/ble
linux/device.go
NewDevice
func NewDevice() (*Device, error) { dev, err := hci.NewHCI() if err != nil { return nil, errors.Wrap(err, "can't create hci") } if err = dev.Init(); err != nil { return nil, errors.Wrap(err, "can't init hci") } s, err := gatt.NewServer() if err != nil { return nil, errors.Wrap(err, "can't create server") ...
go
func NewDevice() (*Device, error) { dev, err := hci.NewHCI() if err != nil { return nil, errors.Wrap(err, "can't create hci") } if err = dev.Init(); err != nil { return nil, errors.Wrap(err, "can't init hci") } s, err := gatt.NewServer() if err != nil { return nil, errors.Wrap(err, "can't create server") ...
[ "func", "NewDevice", "(", ")", "(", "*", "Device", ",", "error", ")", "{", "dev", ",", "err", ":=", "hci", ".", "NewHCI", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ...
// NewDevice returns the default HCI device.
[ "NewDevice", "returns", "the", "default", "HCI", "device", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/device.go#L16-L60
132,139
currantlabs/ble
linux/device.go
AdvertiseNameAndServices
func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, uuids ...ble.UUID) error { if err := d.HCI.AdvertiseNameAndServices(name, uuids...); err != nil { return err } <-ctx.Done() d.HCI.StopAdvertising() return ctx.Err() }
go
func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, uuids ...ble.UUID) error { if err := d.HCI.AdvertiseNameAndServices(name, uuids...); err != nil { return err } <-ctx.Done() d.HCI.StopAdvertising() return ctx.Err() }
[ "func", "(", "d", "*", "Device", ")", "AdvertiseNameAndServices", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "uuids", "...", "ble", ".", "UUID", ")", "error", "{", "if", "err", ":=", "d", ".", "HCI", ".", "AdvertiseNameAndServices...
// AdvertiseNameAndServices advertises device name, and specified service UUIDs. // It tres to fit the UUIDs in the advertising packet as much as possible. // If name doesn't fit in the advertising packet, it will be put in scan response.
[ "AdvertiseNameAndServices", "advertises", "device", "name", "and", "specified", "service", "UUIDs", ".", "It", "tres", "to", "fit", "the", "UUIDs", "in", "the", "advertising", "packet", "as", "much", "as", "possible", ".", "If", "name", "doesn", "t", "fit", ...
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/device.go#L92-L99
132,140
currantlabs/ble
linux/hci/hci.go
NewHCI
func NewHCI(opts ...Option) (*HCI, error) { h := &HCI{ id: -1, chCmdPkt: make(chan *pkt), chCmdBufs: make(chan []byte, 8), sent: make(map[int]*pkt), evth: map[int]handlerFn{}, subh: map[int]handlerFn{}, muConns: &sync.Mutex{}, conns: make(map[uint16]*Conn), chMasterConn: make(cha...
go
func NewHCI(opts ...Option) (*HCI, error) { h := &HCI{ id: -1, chCmdPkt: make(chan *pkt), chCmdBufs: make(chan []byte, 8), sent: make(map[int]*pkt), evth: map[int]handlerFn{}, subh: map[int]handlerFn{}, muConns: &sync.Mutex{}, conns: make(map[uint16]*Conn), chMasterConn: make(cha...
[ "func", "NewHCI", "(", "opts", "...", "Option", ")", "(", "*", "HCI", ",", "error", ")", "{", "h", ":=", "&", "HCI", "{", "id", ":", "-", "1", ",", "chCmdPkt", ":", "make", "(", "chan", "*", "pkt", ")", ",", "chCmdBufs", ":", "make", "(", "ch...
// NewHCI returns a hci device.
[ "NewHCI", "returns", "a", "hci", "device", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/hci.go#L37-L61
132,141
currantlabs/ble
linux/hci/socket/socket.go
NewSocket
func NewSocket(id int) (*Socket, error) { var err error // Create RAW HCI Socket. fd, err := unix.Socket(unix.AF_BLUETOOTH, unix.SOCK_RAW, unix.BTPROTO_HCI) if err != nil { return nil, errors.Wrap(err, "can't create socket") } if id != -1 { return open(fd, id) } req := devListRequest{devNum: hciMaxDevices...
go
func NewSocket(id int) (*Socket, error) { var err error // Create RAW HCI Socket. fd, err := unix.Socket(unix.AF_BLUETOOTH, unix.SOCK_RAW, unix.BTPROTO_HCI) if err != nil { return nil, errors.Wrap(err, "can't create socket") } if id != -1 { return open(fd, id) } req := devListRequest{devNum: hciMaxDevices...
[ "func", "NewSocket", "(", "id", "int", ")", "(", "*", "Socket", ",", "error", ")", "{", "var", "err", "error", "\n", "// Create RAW HCI Socket.", "fd", ",", "err", ":=", "unix", ".", "Socket", "(", "unix", ".", "AF_BLUETOOTH", ",", "unix", ".", "SOCK_R...
// NewSocket returns a HCI User Channel of specified device id. // If id is -1, the first available HCI device is returned.
[ "NewSocket", "returns", "a", "HCI", "User", "Channel", "of", "specified", "device", "id", ".", "If", "id", "is", "-", "1", "the", "first", "available", "HCI", "device", "is", "returned", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/socket/socket.go#L62-L87
132,142
currantlabs/ble
linux/adv/packet.go
NewPacket
func NewPacket(fields ...Field) (*Packet, error) { p := &Packet{b: make([]byte, 0, MaxEIRPacketLength)} for _, f := range fields { if err := f(p); err != nil { return nil, err } } return p, nil }
go
func NewPacket(fields ...Field) (*Packet, error) { p := &Packet{b: make([]byte, 0, MaxEIRPacketLength)} for _, f := range fields { if err := f(p); err != nil { return nil, err } } return p, nil }
[ "func", "NewPacket", "(", "fields", "...", "Field", ")", "(", "*", "Packet", ",", "error", ")", "{", "p", ":=", "&", "Packet", "{", "b", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "MaxEIRPacketLength", ")", "}", "\n", "for", "_", ",", "...
// NewPacket returns a new advertising Packet.
[ "NewPacket", "returns", "a", "new", "advertising", "Packet", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L26-L34
132,143
currantlabs/ble
linux/adv/packet.go
NewRawPacket
func NewRawPacket(bytes ...[]byte) *Packet { p := &Packet{b: make([]byte, 0, MaxEIRPacketLength)} for _, b := range bytes { p.b = append(p.b, b...) } return p }
go
func NewRawPacket(bytes ...[]byte) *Packet { p := &Packet{b: make([]byte, 0, MaxEIRPacketLength)} for _, b := range bytes { p.b = append(p.b, b...) } return p }
[ "func", "NewRawPacket", "(", "bytes", "...", "[", "]", "byte", ")", "*", "Packet", "{", "p", ":=", "&", "Packet", "{", "b", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "MaxEIRPacketLength", ")", "}", "\n", "for", "_", ",", "b", ":=", "ra...
// NewRawPacket returns a new advertising Packet.
[ "NewRawPacket", "returns", "a", "new", "advertising", "Packet", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L37-L43
132,144
currantlabs/ble
linux/adv/packet.go
append
func (p *Packet) append(typ byte, b []byte) error { if p.Len()+1+1+len(b) > MaxEIRPacketLength { return ErrNotFit } p.b = append(p.b, byte(len(b)+1)) p.b = append(p.b, typ) p.b = append(p.b, b...) return nil }
go
func (p *Packet) append(typ byte, b []byte) error { if p.Len()+1+1+len(b) > MaxEIRPacketLength { return ErrNotFit } p.b = append(p.b, byte(len(b)+1)) p.b = append(p.b, typ) p.b = append(p.b, b...) return nil }
[ "func", "(", "p", "*", "Packet", ")", "append", "(", "typ", "byte", ",", "b", "[", "]", "byte", ")", "error", "{", "if", "p", ".", "Len", "(", ")", "+", "1", "+", "1", "+", "len", "(", "b", ")", ">", "MaxEIRPacketLength", "{", "return", "ErrN...
// appends appends a field to the packet. It returns ErrNotFit if the field // doesn't fit into the packet, and leaves the packet intact.
[ "appends", "appends", "a", "field", "to", "the", "packet", ".", "It", "returns", "ErrNotFit", "if", "the", "field", "doesn", "t", "fit", "into", "the", "packet", "and", "leaves", "the", "packet", "intact", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L56-L64
132,145
currantlabs/ble
linux/adv/packet.go
Raw
func Raw(b []byte) Field { return func(p *Packet) error { if p.Len()+len(b) > MaxEIRPacketLength { return ErrNotFit } p.b = append(p.b, b...) return nil } }
go
func Raw(b []byte) Field { return func(p *Packet) error { if p.Len()+len(b) > MaxEIRPacketLength { return ErrNotFit } p.b = append(p.b, b...) return nil } }
[ "func", "Raw", "(", "b", "[", "]", "byte", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "if", "p", ".", "Len", "(", ")", "+", "len", "(", "b", ")", ">", "MaxEIRPacketLength", "{", "return", "ErrNotFit", "\n", ...
// Raw appends the bytes to the current packet. // This is helpful for creating new packet from existing packets.
[ "Raw", "appends", "the", "bytes", "to", "the", "current", "packet", ".", "This", "is", "helpful", "for", "creating", "new", "packet", "from", "existing", "packets", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L68-L76
132,146
currantlabs/ble
linux/adv/packet.go
IBeaconData
func IBeaconData(md []byte) Field { return func(p *Packet) error { return ManufacturerData(0x004C, md)(p) } }
go
func IBeaconData(md []byte) Field { return func(p *Packet) error { return ManufacturerData(0x004C, md)(p) } }
[ "func", "IBeaconData", "(", "md", "[", "]", "byte", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "return", "ManufacturerData", "(", "0x004C", ",", "md", ")", "(", "p", ")", "\n", "}", "\n", "}" ]
// IBeaconData returns an iBeacon advertising packet with specified parameters.
[ "IBeaconData", "returns", "an", "iBeacon", "advertising", "packet", "with", "specified", "parameters", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L79-L83
132,147
currantlabs/ble
linux/adv/packet.go
IBeacon
func IBeacon(u ble.UUID, major, minor uint16, pwr int8) Field { return func(p *Packet) error { if u.Len() != 16 { return ErrInvalid } md := make([]byte, 23) md[0] = 0x02 // Data type: iBeacon md[1] = 0x15 // Data length: 21 bytes copy(md[2:], b...
go
func IBeacon(u ble.UUID, major, minor uint16, pwr int8) Field { return func(p *Packet) error { if u.Len() != 16 { return ErrInvalid } md := make([]byte, 23) md[0] = 0x02 // Data type: iBeacon md[1] = 0x15 // Data length: 21 bytes copy(md[2:], b...
[ "func", "IBeacon", "(", "u", "ble", ".", "UUID", ",", "major", ",", "minor", "uint16", ",", "pwr", "int8", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "if", "u", ".", "Len", "(", ")", "!=", "16", "{", "retur...
// IBeacon returns an iBeacon advertising packet with specified parameters.
[ "IBeacon", "returns", "an", "iBeacon", "advertising", "packet", "with", "specified", "parameters", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L86-L100
132,148
currantlabs/ble
linux/adv/packet.go
Flags
func Flags(f byte) Field { return func(p *Packet) error { return p.append(flags, []byte{f}) } }
go
func Flags(f byte) Field { return func(p *Packet) error { return p.append(flags, []byte{f}) } }
[ "func", "Flags", "(", "f", "byte", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "return", "p", ".", "append", "(", "flags", ",", "[", "]", "byte", "{", "f", "}", ")", "\n", "}", "\n", "}" ]
// Flags is a flags.
[ "Flags", "is", "a", "flags", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L103-L107
132,149
currantlabs/ble
linux/adv/packet.go
ShortName
func ShortName(n string) Field { return func(p *Packet) error { return p.append(shortName, []byte(n)) } }
go
func ShortName(n string) Field { return func(p *Packet) error { return p.append(shortName, []byte(n)) } }
[ "func", "ShortName", "(", "n", "string", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "return", "p", ".", "append", "(", "shortName", ",", "[", "]", "byte", "(", "n", ")", ")", "\n", "}", "\n", "}" ]
// ShortName is a short local name.
[ "ShortName", "is", "a", "short", "local", "name", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L110-L114
132,150
currantlabs/ble
linux/adv/packet.go
CompleteName
func CompleteName(n string) Field { return func(p *Packet) error { return p.append(completeName, []byte(n)) } }
go
func CompleteName(n string) Field { return func(p *Packet) error { return p.append(completeName, []byte(n)) } }
[ "func", "CompleteName", "(", "n", "string", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "return", "p", ".", "append", "(", "completeName", ",", "[", "]", "byte", "(", "n", ")", ")", "\n", "}", "\n", "}" ]
// CompleteName is a compelete local name.
[ "CompleteName", "is", "a", "compelete", "local", "name", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L117-L121
132,151
currantlabs/ble
linux/adv/packet.go
ManufacturerData
func ManufacturerData(id uint16, b []byte) Field { return func(p *Packet) error { d := append([]byte{uint8(id), uint8(id >> 8)}, b...) return p.append(manufacturerData, d) } }
go
func ManufacturerData(id uint16, b []byte) Field { return func(p *Packet) error { d := append([]byte{uint8(id), uint8(id >> 8)}, b...) return p.append(manufacturerData, d) } }
[ "func", "ManufacturerData", "(", "id", "uint16", ",", "b", "[", "]", "byte", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "d", ":=", "append", "(", "[", "]", "byte", "{", "uint8", "(", "id", ")", ",", "uint8", ...
// ManufacturerData is manufacturer specific data.
[ "ManufacturerData", "is", "manufacturer", "specific", "data", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L124-L129
132,152
currantlabs/ble
linux/adv/packet.go
AllUUID
func AllUUID(u ble.UUID) Field { return func(p *Packet) error { if u.Len() == 2 { return p.append(allUUID16, u) } if u.Len() == 4 { return p.append(allUUID32, u) } return p.append(allUUID128, u) } }
go
func AllUUID(u ble.UUID) Field { return func(p *Packet) error { if u.Len() == 2 { return p.append(allUUID16, u) } if u.Len() == 4 { return p.append(allUUID32, u) } return p.append(allUUID128, u) } }
[ "func", "AllUUID", "(", "u", "ble", ".", "UUID", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "if", "u", ".", "Len", "(", ")", "==", "2", "{", "return", "p", ".", "append", "(", "allUUID16", ",", "u", ")", ...
// AllUUID is one of the complete service UUID list.
[ "AllUUID", "is", "one", "of", "the", "complete", "service", "UUID", "list", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L132-L142
132,153
currantlabs/ble
linux/adv/packet.go
SomeUUID
func SomeUUID(u ble.UUID) Field { return func(p *Packet) error { if u.Len() == 2 { return p.append(someUUID16, u) } if u.Len() == 4 { return p.append(someUUID32, u) } return p.append(someUUID128, u) } }
go
func SomeUUID(u ble.UUID) Field { return func(p *Packet) error { if u.Len() == 2 { return p.append(someUUID16, u) } if u.Len() == 4 { return p.append(someUUID32, u) } return p.append(someUUID128, u) } }
[ "func", "SomeUUID", "(", "u", "ble", ".", "UUID", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "if", "u", ".", "Len", "(", ")", "==", "2", "{", "return", "p", ".", "append", "(", "someUUID16", ",", "u", ")", ...
// SomeUUID is one of the incomplete service UUID list.
[ "SomeUUID", "is", "one", "of", "the", "incomplete", "service", "UUID", "list", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L145-L155
132,154
currantlabs/ble
linux/adv/packet.go
ServiceData16
func ServiceData16(id uint16, b []byte) Field { return func(p *Packet) error { uuid := ble.UUID16(id) if err := p.append(allUUID16, uuid); err != nil { return err } return p.append(serviceData16, append(uuid, b...)) } }
go
func ServiceData16(id uint16, b []byte) Field { return func(p *Packet) error { uuid := ble.UUID16(id) if err := p.append(allUUID16, uuid); err != nil { return err } return p.append(serviceData16, append(uuid, b...)) } }
[ "func", "ServiceData16", "(", "id", "uint16", ",", "b", "[", "]", "byte", ")", "Field", "{", "return", "func", "(", "p", "*", "Packet", ")", "error", "{", "uuid", ":=", "ble", ".", "UUID16", "(", "id", ")", "\n", "if", "err", ":=", "p", ".", "a...
// ServiceData16 is service data for a 16bit service uuid
[ "ServiceData16", "is", "service", "data", "for", "a", "16bit", "service", "uuid" ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L158-L166
132,155
currantlabs/ble
linux/adv/packet.go
Flags
func (p *Packet) Flags() (flags byte, present bool) { b := p.Field(flags) if len(b) < 2 { return 0, false } return b[2], true }
go
func (p *Packet) Flags() (flags byte, present bool) { b := p.Field(flags) if len(b) < 2 { return 0, false } return b[2], true }
[ "func", "(", "p", "*", "Packet", ")", "Flags", "(", ")", "(", "flags", "byte", ",", "present", "bool", ")", "{", "b", ":=", "p", ".", "Field", "(", "flags", ")", "\n", "if", "len", "(", "b", ")", "<", "2", "{", "return", "0", ",", "false", ...
// Flags returns the flags of the packet.
[ "Flags", "returns", "the", "flags", "of", "the", "packet", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L189-L195
132,156
currantlabs/ble
linux/adv/packet.go
LocalName
func (p *Packet) LocalName() string { if b := p.Field(shortName); b != nil { return string(b) } return string(p.Field(completeName)) }
go
func (p *Packet) LocalName() string { if b := p.Field(shortName); b != nil { return string(b) } return string(p.Field(completeName)) }
[ "func", "(", "p", "*", "Packet", ")", "LocalName", "(", ")", "string", "{", "if", "b", ":=", "p", ".", "Field", "(", "shortName", ")", ";", "b", "!=", "nil", "{", "return", "string", "(", "b", ")", "\n", "}", "\n", "return", "string", "(", "p",...
// LocalName returns the ShortName or CompleteName if it presents.
[ "LocalName", "returns", "the", "ShortName", "or", "CompleteName", "if", "it", "presents", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L198-L203
132,157
currantlabs/ble
linux/adv/packet.go
TxPower
func (p *Packet) TxPower() (power int, present bool) { b := p.Field(txPower) if len(b) < 3 { return 0, false } return int(int8(b[2])), true }
go
func (p *Packet) TxPower() (power int, present bool) { b := p.Field(txPower) if len(b) < 3 { return 0, false } return int(int8(b[2])), true }
[ "func", "(", "p", "*", "Packet", ")", "TxPower", "(", ")", "(", "power", "int", ",", "present", "bool", ")", "{", "b", ":=", "p", ".", "Field", "(", "txPower", ")", "\n", "if", "len", "(", "b", ")", "<", "3", "{", "return", "0", ",", "false",...
// TxPower returns the TxPower, if it presents.
[ "TxPower", "returns", "the", "TxPower", "if", "it", "presents", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L206-L212
132,158
currantlabs/ble
linux/adv/packet.go
UUIDs
func (p *Packet) UUIDs() []ble.UUID { var u []ble.UUID if b := p.Field(someUUID16); b != nil { u = uuidList(u, b, 2) } if b := p.Field(allUUID16); b != nil { u = uuidList(u, b, 2) } if b := p.Field(someUUID32); b != nil { u = uuidList(u, b, 4) } if b := p.Field(allUUID32); b != nil { u = uuidList(u, b, ...
go
func (p *Packet) UUIDs() []ble.UUID { var u []ble.UUID if b := p.Field(someUUID16); b != nil { u = uuidList(u, b, 2) } if b := p.Field(allUUID16); b != nil { u = uuidList(u, b, 2) } if b := p.Field(someUUID32); b != nil { u = uuidList(u, b, 4) } if b := p.Field(allUUID32); b != nil { u = uuidList(u, b, ...
[ "func", "(", "p", "*", "Packet", ")", "UUIDs", "(", ")", "[", "]", "ble", ".", "UUID", "{", "var", "u", "[", "]", "ble", ".", "UUID", "\n", "if", "b", ":=", "p", ".", "Field", "(", "someUUID16", ")", ";", "b", "!=", "nil", "{", "u", "=", ...
// UUIDs returns a list of service UUIDs.
[ "UUIDs", "returns", "a", "list", "of", "service", "UUIDs", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L215-L236
132,159
currantlabs/ble
linux/adv/packet.go
uuidList
func uuidList(u []ble.UUID, d []byte, w int) []ble.UUID { for len(d) > 0 { u = append(u, ble.UUID(d[:w])) d = d[w:] } return u }
go
func uuidList(u []ble.UUID, d []byte, w int) []ble.UUID { for len(d) > 0 { u = append(u, ble.UUID(d[:w])) d = d[w:] } return u }
[ "func", "uuidList", "(", "u", "[", "]", "ble", ".", "UUID", ",", "d", "[", "]", "byte", ",", "w", "int", ")", "[", "]", "ble", ".", "UUID", "{", "for", "len", "(", "d", ")", ">", "0", "{", "u", "=", "append", "(", "u", ",", "ble", ".", ...
// Utility function for creating a list of uuids.
[ "Utility", "function", "for", "creating", "a", "list", "of", "uuids", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/adv/packet.go#L274-L280
132,160
currantlabs/ble
profile.go
NewCharacteristic
func (s *Service) NewCharacteristic(u UUID) *Characteristic { return s.AddCharacteristic(&Characteristic{UUID: u}) }
go
func (s *Service) NewCharacteristic(u UUID) *Characteristic { return s.AddCharacteristic(&Characteristic{UUID: u}) }
[ "func", "(", "s", "*", "Service", ")", "NewCharacteristic", "(", "u", "UUID", ")", "*", "Characteristic", "{", "return", "s", ".", "AddCharacteristic", "(", "&", "Characteristic", "{", "UUID", ":", "u", "}", ")", "\n", "}" ]
// NewCharacteristic adds a characteristic to a service. // NewCharacteristic panics if the service already contains another characteristic with the same UUID.
[ "NewCharacteristic", "adds", "a", "characteristic", "to", "a", "service", ".", "NewCharacteristic", "panics", "if", "the", "service", "already", "contains", "another", "characteristic", "with", "the", "same", "UUID", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/profile.go#L93-L95
132,161
currantlabs/ble
profile.go
NewDescriptor
func (c *Characteristic) NewDescriptor(u UUID) *Descriptor { return c.AddDescriptor(&Descriptor{UUID: u}) }
go
func (c *Characteristic) NewDescriptor(u UUID) *Descriptor { return c.AddDescriptor(&Descriptor{UUID: u}) }
[ "func", "(", "c", "*", "Characteristic", ")", "NewDescriptor", "(", "u", "UUID", ")", "*", "Descriptor", "{", "return", "c", ".", "AddDescriptor", "(", "&", "Descriptor", "{", "UUID", ":", "u", "}", ")", "\n", "}" ]
// NewDescriptor adds a descriptor to a characteristic. // NewDescriptor panics if the characteristic already contains another descriptor with the same UUID.
[ "NewDescriptor", "adds", "a", "descriptor", "to", "a", "characteristic", ".", "NewDescriptor", "panics", "if", "the", "characteristic", "already", "contains", "another", "descriptor", "with", "the", "same", "UUID", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/profile.go#L131-L133
132,162
currantlabs/ble
profile.go
HandleIndicate
func (c *Characteristic) HandleIndicate(h NotifyHandler) { c.Property |= CharIndicate c.IndicateHandler = h }
go
func (c *Characteristic) HandleIndicate(h NotifyHandler) { c.Property |= CharIndicate c.IndicateHandler = h }
[ "func", "(", "c", "*", "Characteristic", ")", "HandleIndicate", "(", "h", "NotifyHandler", ")", "{", "c", ".", "Property", "|=", "CharIndicate", "\n", "c", ".", "IndicateHandler", "=", "h", "\n", "}" ]
// HandleIndicate makes the characteristic support indicate requests, and routes notification requests to h. // HandleIndicate must be called before the containing service is added to a server.
[ "HandleIndicate", "makes", "the", "characteristic", "support", "indicate", "requests", "and", "routes", "notification", "requests", "to", "h", ".", "HandleIndicate", "must", "be", "called", "before", "the", "containing", "service", "is", "added", "to", "a", "serve...
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/profile.go#L175-L178
132,163
currantlabs/ble
linux/att/server.go
notify
func (s *Server) notify(h uint16, data []byte) (int, error) { // Acquire and reuse notifyBuffer. Release it after usage. nBuf := <-s.chNotBuf defer func() { s.chNotBuf <- nBuf }() rsp := HandleValueNotification(nBuf) rsp.SetAttributeOpcode() rsp.SetAttributeHandle(h) buf := bytes.NewBuffer(rsp.AttributeValue())...
go
func (s *Server) notify(h uint16, data []byte) (int, error) { // Acquire and reuse notifyBuffer. Release it after usage. nBuf := <-s.chNotBuf defer func() { s.chNotBuf <- nBuf }() rsp := HandleValueNotification(nBuf) rsp.SetAttributeOpcode() rsp.SetAttributeHandle(h) buf := bytes.NewBuffer(rsp.AttributeValue())...
[ "func", "(", "s", "*", "Server", ")", "notify", "(", "h", "uint16", ",", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "// Acquire and reuse notifyBuffer. Release it after usage.", "nBuf", ":=", "<-", "s", ".", "chNotBuf", "\n", "defer...
// notify sends notification to remote central.
[ "notify", "sends", "notification", "to", "remote", "central", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/att/server.go#L70-L85
132,164
currantlabs/ble
linux/att/server.go
indicate
func (s *Server) indicate(h uint16, data []byte) (int, error) { // Acquire and reuse indicateBuffer. Release it after usage. iBuf := <-s.chIndBuf defer func() { s.chIndBuf <- iBuf }() rsp := HandleValueIndication(iBuf) rsp.SetAttributeOpcode() rsp.SetAttributeHandle(h) buf := bytes.NewBuffer(rsp.AttributeValue(...
go
func (s *Server) indicate(h uint16, data []byte) (int, error) { // Acquire and reuse indicateBuffer. Release it after usage. iBuf := <-s.chIndBuf defer func() { s.chIndBuf <- iBuf }() rsp := HandleValueIndication(iBuf) rsp.SetAttributeOpcode() rsp.SetAttributeHandle(h) buf := bytes.NewBuffer(rsp.AttributeValue(...
[ "func", "(", "s", "*", "Server", ")", "indicate", "(", "h", "uint16", ",", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "// Acquire and reuse indicateBuffer. Release it after usage.", "iBuf", ":=", "<-", "s", ".", "chIndBuf", "\n", "d...
// indicate sends indication to remote central.
[ "indicate", "sends", "indication", "to", "remote", "central", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/att/server.go#L88-L115
132,165
currantlabs/ble
linux/att/server.go
Loop
func (s *Server) Loop() { type sbuf struct { buf []byte len int } pool := make(chan *sbuf, 2) pool <- &sbuf{buf: make([]byte, s.rxMTU)} pool <- &sbuf{buf: make([]byte, s.rxMTU)} seq := make(chan *sbuf) go func() { b := <-pool for { n, err := s.conn.Read(b.buf) if n == 0 || err != nil { close(s...
go
func (s *Server) Loop() { type sbuf struct { buf []byte len int } pool := make(chan *sbuf, 2) pool <- &sbuf{buf: make([]byte, s.rxMTU)} pool <- &sbuf{buf: make([]byte, s.rxMTU)} seq := make(chan *sbuf) go func() { b := <-pool for { n, err := s.conn.Read(b.buf) if n == 0 || err != nil { close(s...
[ "func", "(", "s", "*", "Server", ")", "Loop", "(", ")", "{", "type", "sbuf", "struct", "{", "buf", "[", "]", "byte", "\n", "len", "int", "\n", "}", "\n", "pool", ":=", "make", "(", "chan", "*", "sbuf", ",", "2", ")", "\n", "pool", "<-", "&", ...
// Loop accepts incoming ATT request, and respond response.
[ "Loop", "accepts", "incoming", "ATT", "request", "and", "respond", "response", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/att/server.go#L118-L170
132,166
currantlabs/ble
linux/hci/option.go
OptDeviceID
func OptDeviceID(id int) Option { return func(h *HCI) error { h.id = id return nil } }
go
func OptDeviceID(id int) Option { return func(h *HCI) error { h.id = id return nil } }
[ "func", "OptDeviceID", "(", "id", "int", ")", "Option", "{", "return", "func", "(", "h", "*", "HCI", ")", "error", "{", "h", ".", "id", "=", "id", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// OptDeviceID sets HCI device ID.
[ "OptDeviceID", "sets", "HCI", "device", "ID", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/option.go#L13-L18
132,167
currantlabs/ble
linux/hci/option.go
OptDialerTimeout
func OptDialerTimeout(d time.Duration) Option { return func(h *HCI) error { h.dialerTmo = d return nil } }
go
func OptDialerTimeout(d time.Duration) Option { return func(h *HCI) error { h.dialerTmo = d return nil } }
[ "func", "OptDialerTimeout", "(", "d", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "h", "*", "HCI", ")", "error", "{", "h", ".", "dialerTmo", "=", "d", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// OptDialerTimeout sets dialing timeout for Dialer.
[ "OptDialerTimeout", "sets", "dialing", "timeout", "for", "Dialer", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/option.go#L21-L26
132,168
currantlabs/ble
linux/hci/option.go
OptListenerTimeout
func OptListenerTimeout(d time.Duration) Option { return func(h *HCI) error { h.listenerTmo = d return nil } }
go
func OptListenerTimeout(d time.Duration) Option { return func(h *HCI) error { h.listenerTmo = d return nil } }
[ "func", "OptListenerTimeout", "(", "d", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "h", "*", "HCI", ")", "error", "{", "h", ".", "listenerTmo", "=", "d", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// OptListenerTimeout sets dialing timeout for Listener.
[ "OptListenerTimeout", "sets", "dialing", "timeout", "for", "Listener", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/option.go#L29-L34
132,169
currantlabs/ble
linux/hci/option.go
OptConnParams
func OptConnParams(param cmd.LECreateConnection) Option { return func(h *HCI) error { h.params.connParams = param return nil } }
go
func OptConnParams(param cmd.LECreateConnection) Option { return func(h *HCI) error { h.params.connParams = param return nil } }
[ "func", "OptConnParams", "(", "param", "cmd", ".", "LECreateConnection", ")", "Option", "{", "return", "func", "(", "h", "*", "HCI", ")", "error", "{", "h", ".", "params", ".", "connParams", "=", "param", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// OptConnParams overrides default connection parameters.
[ "OptConnParams", "overrides", "default", "connection", "parameters", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/option.go#L37-L42
132,170
currantlabs/ble
linux/att/db.go
at
func (r *DB) at(h uint16) (a *attr, ok bool) { i := r.idx(int(h)) if i < 0 { return nil, false } return r.attrs[i], true }
go
func (r *DB) at(h uint16) (a *attr, ok bool) { i := r.idx(int(h)) if i < 0 { return nil, false } return r.attrs[i], true }
[ "func", "(", "r", "*", "DB", ")", "at", "(", "h", "uint16", ")", "(", "a", "*", "attr", ",", "ok", "bool", ")", "{", "i", ":=", "r", ".", "idx", "(", "int", "(", "h", ")", ")", "\n", "if", "i", "<", "0", "{", "return", "nil", ",", "fals...
// at returns attr a.
[ "at", "returns", "attr", "a", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/att/db.go#L35-L41
132,171
currantlabs/ble
linux/gatt/client.go
NewClient
func NewClient(conn ble.Conn) (*Client, error) { p := &Client{ subs: make(map[uint16]*sub), conn: conn, } p.ac = att.NewClient(conn, p) go p.ac.Loop() return p, nil }
go
func NewClient(conn ble.Conn) (*Client, error) { p := &Client{ subs: make(map[uint16]*sub), conn: conn, } p.ac = att.NewClient(conn, p) go p.ac.Loop() return p, nil }
[ "func", "NewClient", "(", "conn", "ble", ".", "Conn", ")", "(", "*", "Client", ",", "error", ")", "{", "p", ":=", "&", "Client", "{", "subs", ":", "make", "(", "map", "[", "uint16", "]", "*", "sub", ")", ",", "conn", ":", "conn", ",", "}", "\...
// NewClient returns a GATT Client.
[ "NewClient", "returns", "a", "GATT", "Client", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L19-L27
132,172
currantlabs/ble
linux/gatt/client.go
Address
func (p *Client) Address() ble.Addr { p.RLock() defer p.RUnlock() return p.conn.RemoteAddr() }
go
func (p *Client) Address() ble.Addr { p.RLock() defer p.RUnlock() return p.conn.RemoteAddr() }
[ "func", "(", "p", "*", "Client", ")", "Address", "(", ")", "ble", ".", "Addr", "{", "p", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "conn", ".", "RemoteAddr", "(", ")", "\n", "}" ]
// Address returns the address of the client.
[ "Address", "returns", "the", "address", "of", "the", "client", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L42-L46
132,173
currantlabs/ble
linux/gatt/client.go
Name
func (p *Client) Name() string { p.RLock() defer p.RUnlock() return p.name }
go
func (p *Client) Name() string { p.RLock() defer p.RUnlock() return p.name }
[ "func", "(", "p", "*", "Client", ")", "Name", "(", ")", "string", "{", "p", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "name", "\n", "}" ]
// Name returns the name of the client.
[ "Name", "returns", "the", "name", "of", "the", "client", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L49-L53
132,174
currantlabs/ble
linux/gatt/client.go
Profile
func (p *Client) Profile() *ble.Profile { p.RLock() defer p.RUnlock() return p.profile }
go
func (p *Client) Profile() *ble.Profile { p.RLock() defer p.RUnlock() return p.profile }
[ "func", "(", "p", "*", "Client", ")", "Profile", "(", ")", "*", "ble", ".", "Profile", "{", "p", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "profile", "\n", "}" ]
// Profile returns the discovered profile.
[ "Profile", "returns", "the", "discovered", "profile", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L56-L60
132,175
currantlabs/ble
linux/gatt/client.go
DiscoverProfile
func (p *Client) DiscoverProfile(force bool) (*ble.Profile, error) { if p.profile != nil && !force { return p.profile, nil } ss, err := p.DiscoverServices(nil) if err != nil { return nil, fmt.Errorf("can't discover services: %s\n", err) } for _, s := range ss { cs, err := p.DiscoverCharacteristics(nil, s) ...
go
func (p *Client) DiscoverProfile(force bool) (*ble.Profile, error) { if p.profile != nil && !force { return p.profile, nil } ss, err := p.DiscoverServices(nil) if err != nil { return nil, fmt.Errorf("can't discover services: %s\n", err) } for _, s := range ss { cs, err := p.DiscoverCharacteristics(nil, s) ...
[ "func", "(", "p", "*", "Client", ")", "DiscoverProfile", "(", "force", "bool", ")", "(", "*", "ble", ".", "Profile", ",", "error", ")", "{", "if", "p", ".", "profile", "!=", "nil", "&&", "!", "force", "{", "return", "p", ".", "profile", ",", "nil...
// DiscoverProfile discovers the whole hierachy of a server.
[ "DiscoverProfile", "discovers", "the", "whole", "hierachy", "of", "a", "server", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L63-L85
132,176
currantlabs/ble
linux/gatt/client.go
Disconnected
func (p *Client) Disconnected() <-chan struct{} { p.Lock() defer p.Unlock() return p.conn.Disconnected() }
go
func (p *Client) Disconnected() <-chan struct{} { p.Lock() defer p.Unlock() return p.conn.Disconnected() }
[ "func", "(", "p", "*", "Client", ")", "Disconnected", "(", ")", "<-", "chan", "struct", "{", "}", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "conn", ".", "Disconnected", "(", ")", "\n...
// Disconnected returns a receiving channel, which is closed when the client disconnects.
[ "Disconnected", "returns", "a", "receiving", "channel", "which", "is", "closed", "when", "the", "client", "disconnects", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/gatt/client.go#L354-L358
132,177
currantlabs/ble
linux/att/client.go
NewClient
func NewClient(l2c ble.Conn, h NotificationHandler) *Client { c := &Client{ l2c: l2c, rspc: make(chan []byte), chTxBuf: make(chan []byte, 1), rxBuf: make([]byte, ble.MaxMTU), chErr: make(chan error, 1), handler: h, } c.chTxBuf <- make([]byte, l2c.TxMTU(), l2c.TxMTU()) return c }
go
func NewClient(l2c ble.Conn, h NotificationHandler) *Client { c := &Client{ l2c: l2c, rspc: make(chan []byte), chTxBuf: make(chan []byte, 1), rxBuf: make([]byte, ble.MaxMTU), chErr: make(chan error, 1), handler: h, } c.chTxBuf <- make([]byte, l2c.TxMTU(), l2c.TxMTU()) return c }
[ "func", "NewClient", "(", "l2c", "ble", ".", "Conn", ",", "h", "NotificationHandler", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "l2c", ":", "l2c", ",", "rspc", ":", "make", "(", "chan", "[", "]", "byte", ")", ",", "chTxBuf", ":", "m...
// NewClient returns an Attribute Protocol Client.
[ "NewClient", "returns", "an", "Attribute", "Protocol", "Client", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/att/client.go#L29-L40
132,178
currantlabs/ble
linux/hci/conn.go
Read
func (c *Conn) Read(sdu []byte) (n int, err error) { p, ok := <-c.chInPDU if !ok { return 0, errors.Wrap(io.ErrClosedPipe, "input channel closed") } if len(p) == 0 { return 0, errors.Wrap(io.ErrUnexpectedEOF, "recieved empty packet") } // Assume it's a B-Frame. slen := p.dlen() data := p.payload() if c.le...
go
func (c *Conn) Read(sdu []byte) (n int, err error) { p, ok := <-c.chInPDU if !ok { return 0, errors.Wrap(io.ErrClosedPipe, "input channel closed") } if len(p) == 0 { return 0, errors.Wrap(io.ErrUnexpectedEOF, "recieved empty packet") } // Assume it's a B-Frame. slen := p.dlen() data := p.payload() if c.le...
[ "func", "(", "c", "*", "Conn", ")", "Read", "(", "sdu", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "p", ",", "ok", ":=", "<-", "c", ".", "chInPDU", "\n", "if", "!", "ok", "{", "return", "0", ",", "errors", ".", ...
// Read copies re-assembled L2CAP PDUs into sdu.
[ "Read", "copies", "re", "-", "assembled", "L2CAP", "PDUs", "into", "sdu", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/conn.go#L119-L147
132,179
currantlabs/ble
linux/hci/conn.go
Close
func (c *Conn) Close() error { select { case <-c.chDone: // Return if it's already closed. return nil default: c.hci.Send(&cmd.Disconnect{ ConnectionHandle: c.param.ConnectionHandle(), Reason: 0x13, }, nil) return nil } }
go
func (c *Conn) Close() error { select { case <-c.chDone: // Return if it's already closed. return nil default: c.hci.Send(&cmd.Disconnect{ ConnectionHandle: c.param.ConnectionHandle(), Reason: 0x13, }, nil) return nil } }
[ "func", "(", "c", "*", "Conn", ")", "Close", "(", ")", "error", "{", "select", "{", "case", "<-", "c", ".", "chDone", ":", "// Return if it's already closed.", "return", "nil", "\n", "default", ":", "c", ".", "hci", ".", "Send", "(", "&", "cmd", ".",...
// Close disconnects the connection by sending hci disconnect command to the device.
[ "Close", "disconnects", "the", "connection", "by", "sending", "hci", "disconnect", "command", "to", "the", "device", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/conn.go#L281-L293
132,180
currantlabs/ble
linux/hci/conn.go
RemoteAddr
func (c *Conn) RemoteAddr() ble.Addr { a := c.param.PeerAddress() return net.HardwareAddr([]byte{a[5], a[4], a[3], a[2], a[1], a[0]}) }
go
func (c *Conn) RemoteAddr() ble.Addr { a := c.param.PeerAddress() return net.HardwareAddr([]byte{a[5], a[4], a[3], a[2], a[1], a[0]}) }
[ "func", "(", "c", "*", "Conn", ")", "RemoteAddr", "(", ")", "ble", ".", "Addr", "{", "a", ":=", "c", ".", "param", ".", "PeerAddress", "(", ")", "\n", "return", "net", ".", "HardwareAddr", "(", "[", "]", "byte", "{", "a", "[", "5", "]", ",", ...
// RemoteAddr returns remote device's MAC address.
[ "RemoteAddr", "returns", "remote", "device", "s", "MAC", "address", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/conn.go#L299-L302
132,181
currantlabs/ble
handler.go
NewRequest
func NewRequest(conn Conn, data []byte, offset int) Request { return &request{conn: conn, data: data, offset: offset} }
go
func NewRequest(conn Conn, data []byte, offset int) Request { return &request{conn: conn, data: data, offset: offset} }
[ "func", "NewRequest", "(", "conn", "Conn", ",", "data", "[", "]", "byte", ",", "offset", "int", ")", "Request", "{", "return", "&", "request", "{", "conn", ":", "conn", ",", "data", ":", "data", ",", "offset", ":", "offset", "}", "\n", "}" ]
// NewRequest returns a default implementation of Request.
[ "NewRequest", "returns", "a", "default", "implementation", "of", "Request", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/handler.go#L57-L59
132,182
currantlabs/ble
handler.go
Len
func (r *responseWriter) Len() int { if r.buf == nil { return 0 } return r.buf.Len() }
go
func (r *responseWriter) Len() int { if r.buf == nil { return 0 } return r.buf.Len() }
[ "func", "(", "r", "*", "responseWriter", ")", "Len", "(", ")", "int", "{", "if", "r", ".", "buf", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "r", ".", "buf", ".", "Len", "(", ")", "\n", "}" ]
// Len returns length of the buffer. // Len returns 0 if it is a dummy write response for WriteCommand.
[ "Len", "returns", "length", "of", "the", "buffer", ".", "Len", "returns", "0", "if", "it", "is", "a", "dummy", "write", "response", "for", "WriteCommand", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/handler.go#L113-L118
132,183
currantlabs/ble
handler.go
Cap
func (r *responseWriter) Cap() int { if r.buf == nil { return 0 } return r.buf.Cap() }
go
func (r *responseWriter) Cap() int { if r.buf == nil { return 0 } return r.buf.Cap() }
[ "func", "(", "r", "*", "responseWriter", ")", "Cap", "(", ")", "int", "{", "if", "r", ".", "buf", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "r", ".", "buf", ".", "Cap", "(", ")", "\n", "}" ]
// Cap returns capacity of the buffer. // Cap returns 0 if it is a dummy write response for WriteCommand.
[ "Cap", "returns", "capacity", "of", "the", "buffer", ".", "Cap", "returns", "0", "if", "it", "is", "a", "dummy", "write", "response", "for", "WriteCommand", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/handler.go#L122-L127
132,184
currantlabs/ble
handler.go
Write
func (r *responseWriter) Write(b []byte) (int, error) { if r.buf == nil { return 0, ErrReqNotSupp } if len(b) > r.buf.Cap()-r.buf.Len() { return 0, io.ErrShortWrite } return r.buf.Write(b) }
go
func (r *responseWriter) Write(b []byte) (int, error) { if r.buf == nil { return 0, ErrReqNotSupp } if len(b) > r.buf.Cap()-r.buf.Len() { return 0, io.ErrShortWrite } return r.buf.Write(b) }
[ "func", "(", "r", "*", "responseWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "r", ".", "buf", "==", "nil", "{", "return", "0", ",", "ErrReqNotSupp", "\n", "}", "\n", "if", "len", "(", "b", ...
// Write writes data to return as the characteristic value. // Cap returns 0 with error set to ErrReqNotSupp if it is a dummy write response for WriteCommand.
[ "Write", "writes", "data", "to", "return", "as", "the", "characteristic", "value", ".", "Cap", "returns", "0", "with", "error", "set", "to", "ErrReqNotSupp", "if", "it", "is", "a", "dummy", "write", "response", "for", "WriteCommand", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/handler.go#L131-L140
132,185
currantlabs/ble
gatt.go
AdvertiseNameAndServices
func AdvertiseNameAndServices(ctx context.Context, name string, uuids ...UUID) error { if defaultDevice == nil { return ErrDefaultDevice } defer untrap(trap(ctx)) return defaultDevice.AdvertiseNameAndServices(ctx, name, uuids...) }
go
func AdvertiseNameAndServices(ctx context.Context, name string, uuids ...UUID) error { if defaultDevice == nil { return ErrDefaultDevice } defer untrap(trap(ctx)) return defaultDevice.AdvertiseNameAndServices(ctx, name, uuids...) }
[ "func", "AdvertiseNameAndServices", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "uuids", "...", "UUID", ")", "error", "{", "if", "defaultDevice", "==", "nil", "{", "return", "ErrDefaultDevice", "\n", "}", "\n", "defer", "untrap", "(", ...
// AdvertiseNameAndServices advertises device name, and specified service UUIDs. // It tres to fit the UUIDs in the advertising packet as much as possi // If name doesn't fit in the advertising packet, it will be put in scan response.
[ "AdvertiseNameAndServices", "advertises", "device", "name", "and", "specified", "service", "UUIDs", ".", "It", "tres", "to", "fit", "the", "UUIDs", "in", "the", "advertising", "packet", "as", "much", "as", "possi", "If", "name", "doesn", "t", "fit", "in", "t...
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/gatt.go#L59-L65
132,186
currantlabs/ble
gatt.go
Connect
func Connect(ctx context.Context, f AdvFilter) (Client, error) { ctx2, cancel := context.WithCancel(ctx) go func() { select { case <-ctx.Done(): cancel() case <-ctx2.Done(): } }() ch := make(chan Advertisement) fn := func(a Advertisement) { cancel() ch <- a } if err := Scan(ctx2, false, fn, f); e...
go
func Connect(ctx context.Context, f AdvFilter) (Client, error) { ctx2, cancel := context.WithCancel(ctx) go func() { select { case <-ctx.Done(): cancel() case <-ctx2.Done(): } }() ch := make(chan Advertisement) fn := func(a Advertisement) { cancel() ch <- a } if err := Scan(ctx2, false, fn, f); e...
[ "func", "Connect", "(", "ctx", "context", ".", "Context", ",", "f", "AdvFilter", ")", "(", "Client", ",", "error", ")", "{", "ctx2", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "go", "func", "(", ")", "{", "select", "{...
// Connect searches for and connects to a Peripheral which matches specified condition.
[ "Connect", "searches", "for", "and", "connects", "to", "a", "Peripheral", "which", "matches", "specified", "condition", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/gatt.go#L127-L150
132,187
currantlabs/ble
gatt.go
trap
func trap(ctx context.Context) chan<- os.Signal { v := ctx.Value("sig") if v == nil { return nil } cancel, ok := v.(func()) if cancel == nil || !ok { return nil } sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { select { case <-sigs: cancel() case <...
go
func trap(ctx context.Context) chan<- os.Signal { v := ctx.Value("sig") if v == nil { return nil } cancel, ok := v.(func()) if cancel == nil || !ok { return nil } sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { select { case <-sigs: cancel() case <...
[ "func", "trap", "(", "ctx", "context", ".", "Context", ")", "chan", "<-", "os", ".", "Signal", "{", "v", ":=", "ctx", ".", "Value", "(", "\"", "\"", ")", "\n", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "cancel", ",", "ok", ...
// Cleanup for the interrupted case.
[ "Cleanup", "for", "the", "interrupted", "case", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/gatt.go#L161-L181
132,188
currantlabs/ble
linux/hci/adv.go
setScanResponse
func (a *Advertisement) setScanResponse(sr *Advertisement) { a.sr = sr a.p = nil // clear the cached. }
go
func (a *Advertisement) setScanResponse(sr *Advertisement) { a.sr = sr a.p = nil // clear the cached. }
[ "func", "(", "a", "*", "Advertisement", ")", "setScanResponse", "(", "sr", "*", "Advertisement", ")", "{", "a", ".", "sr", "=", "sr", "\n", "a", ".", "p", "=", "nil", "// clear the cached.", "\n", "}" ]
// setScanResponse ssociate sca response to the existing advertisement.
[ "setScanResponse", "ssociate", "sca", "response", "to", "the", "existing", "advertisement", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L41-L44
132,189
currantlabs/ble
linux/hci/adv.go
TxPowerLevel
func (a *Advertisement) TxPowerLevel() int { pwr, _ := a.packets().TxPower() return pwr }
go
func (a *Advertisement) TxPowerLevel() int { pwr, _ := a.packets().TxPower() return pwr }
[ "func", "(", "a", "*", "Advertisement", ")", "TxPowerLevel", "(", ")", "int", "{", "pwr", ",", "_", ":=", "a", ".", "packets", "(", ")", ".", "TxPower", "(", ")", "\n", "return", "pwr", "\n", "}" ]
// TxPowerLevel returns the tx power level of the remote peripheral.
[ "TxPowerLevel", "returns", "the", "tx", "power", "level", "of", "the", "remote", "peripheral", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L80-L83
132,190
currantlabs/ble
linux/hci/adv.go
Connectable
func (a *Advertisement) Connectable() bool { return a.EventType() == evtTypAdvDirectInd || a.EventType() == evtTypAdvInd }
go
func (a *Advertisement) Connectable() bool { return a.EventType() == evtTypAdvDirectInd || a.EventType() == evtTypAdvInd }
[ "func", "(", "a", "*", "Advertisement", ")", "Connectable", "(", ")", "bool", "{", "return", "a", ".", "EventType", "(", ")", "==", "evtTypAdvDirectInd", "||", "a", ".", "EventType", "(", ")", "==", "evtTypAdvInd", "\n", "}" ]
// Connectable indicates weather the remote peripheral is connectable.
[ "Connectable", "indicates", "weather", "the", "remote", "peripheral", "is", "connectable", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L91-L93
132,191
currantlabs/ble
linux/hci/adv.go
RSSI
func (a *Advertisement) RSSI() int { return int(a.e.RSSI(a.i)) }
go
func (a *Advertisement) RSSI() int { return int(a.e.RSSI(a.i)) }
[ "func", "(", "a", "*", "Advertisement", ")", "RSSI", "(", ")", "int", "{", "return", "int", "(", "a", ".", "e", ".", "RSSI", "(", "a", ".", "i", ")", ")", "\n", "}" ]
// RSSI returns RSSI signal strength.
[ "RSSI", "returns", "RSSI", "signal", "strength", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L96-L98
132,192
currantlabs/ble
linux/hci/adv.go
Address
func (a *Advertisement) Address() ble.Addr { b := a.e.Address(a.i) addr := net.HardwareAddr([]byte{b[5], b[4], b[3], b[2], b[1], b[0]}) if a.e.AddressType(a.i) == 1 { return RandomAddress{addr} } return addr }
go
func (a *Advertisement) Address() ble.Addr { b := a.e.Address(a.i) addr := net.HardwareAddr([]byte{b[5], b[4], b[3], b[2], b[1], b[0]}) if a.e.AddressType(a.i) == 1 { return RandomAddress{addr} } return addr }
[ "func", "(", "a", "*", "Advertisement", ")", "Address", "(", ")", "ble", ".", "Addr", "{", "b", ":=", "a", ".", "e", ".", "Address", "(", "a", ".", "i", ")", "\n", "addr", ":=", "net", ".", "HardwareAddr", "(", "[", "]", "byte", "{", "b", "["...
// Address returns the address of the remote peripheral.
[ "Address", "returns", "the", "address", "of", "the", "remote", "peripheral", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L101-L108
132,193
currantlabs/ble
linux/hci/adv.go
ScanResponse
func (a *Advertisement) ScanResponse() []byte { if a.sr == nil { return nil } return a.sr.Data() }
go
func (a *Advertisement) ScanResponse() []byte { if a.sr == nil { return nil } return a.sr.Data() }
[ "func", "(", "a", "*", "Advertisement", ")", "ScanResponse", "(", ")", "[", "]", "byte", "{", "if", "a", ".", "sr", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "a", ".", "sr", ".", "Data", "(", ")", "\n", "}" ]
// ScanResponse returns the scan response of the packet, if it presents. // This is linux sepcific.
[ "ScanResponse", "returns", "the", "scan", "response", "of", "the", "packet", "if", "it", "presents", ".", "This", "is", "linux", "sepcific", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/adv.go#L130-L135
132,194
currantlabs/ble
darwin/device.go
NewDevice
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",...
go
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",...
[ "func", "NewDevice", "(", "opts", "...", "Option", ")", "(", "*", "Device", ",", "error", ")", "{", "d", ":=", "&", "Device", "{", "rspc", ":", "make", "(", "chan", "msg", ")", ",", "conns", ":", "make", "(", "map", "[", "string", "]", "*", "co...
// NewDevice returns a BLE device.
[ "NewDevice", "returns", "a", "BLE", "device", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/darwin/device.go#L68-L84
132,195
currantlabs/ble
darwin/device.go
AdvertiseNameAndServices
func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, ss ...ble.UUID) error { if err := d.sendReq(d.pm, 8, xpc.Dict{ "kCBAdvDataLocalName": name, "kCBAdvDataServiceUUIDs": uuidSlice(ss)}, ).err(); err != nil { return err } <-ctx.Done() d.stopAdvertising() return ctx.Err() }
go
func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, ss ...ble.UUID) error { if err := d.sendReq(d.pm, 8, xpc.Dict{ "kCBAdvDataLocalName": name, "kCBAdvDataServiceUUIDs": uuidSlice(ss)}, ).err(); err != nil { return err } <-ctx.Done() d.stopAdvertising() return ctx.Err() }
[ "func", "(", "d", "*", "Device", ")", "AdvertiseNameAndServices", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "ss", "...", "ble", ".", "UUID", ")", "error", "{", "if", "err", ":=", "d", ".", "sendReq", "(", "d", ".", "pm", ",...
// AdvertiseNameAndServices advertises name and specifid service UUIDs.
[ "AdvertiseNameAndServices", "advertises", "name", "and", "specifid", "service", "UUIDs", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/darwin/device.go#L153-L163
132,196
currantlabs/ble
darwin/device.go
AdvertiseIBeaconData
func (d *Device) AdvertiseIBeaconData(ctx context.Context, md []byte) error { var utsname xpc.Utsname xpc.Uname(&utsname) if utsname.Release >= "14." { ibeaconCode := []byte{0x02, 0x15} return d.AdvertiseMfgData(ctx, 0x004C, append(ibeaconCode, md...)) } if err := d.sendReq(d.pm, 8, xpc.Dict{"kCBAdvDataAppleB...
go
func (d *Device) AdvertiseIBeaconData(ctx context.Context, md []byte) error { var utsname xpc.Utsname xpc.Uname(&utsname) if utsname.Release >= "14." { ibeaconCode := []byte{0x02, 0x15} return d.AdvertiseMfgData(ctx, 0x004C, append(ibeaconCode, md...)) } if err := d.sendReq(d.pm, 8, xpc.Dict{"kCBAdvDataAppleB...
[ "func", "(", "d", "*", "Device", ")", "AdvertiseIBeaconData", "(", "ctx", "context", ".", "Context", ",", "md", "[", "]", "byte", ")", "error", "{", "var", "utsname", "xpc", ".", "Utsname", "\n", "xpc", ".", "Uname", "(", "&", "utsname", ")", "\n\n",...
// AdvertiseIBeaconData advertises iBeacon packet with specified manufacturer data.
[ "AdvertiseIBeaconData", "advertises", "iBeacon", "packet", "with", "specified", "manufacturer", "data", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/darwin/device.go#L166-L179
132,197
currantlabs/ble
darwin/device.go
AdvertiseIBeacon
func (d *Device) AdvertiseIBeacon(ctx context.Context, u ble.UUID, major, minor uint16, pwr int8) error { b := make([]byte, 21) copy(b, ble.Reverse(u)) // Big endian binary.BigEndian.PutUint16(b[16:], major) // Big endian binary.BigEndian.PutUint16(b[18:], minor) // Big endian b[20] = uint8(pwr) ...
go
func (d *Device) AdvertiseIBeacon(ctx context.Context, u ble.UUID, major, minor uint16, pwr int8) error { b := make([]byte, 21) copy(b, ble.Reverse(u)) // Big endian binary.BigEndian.PutUint16(b[16:], major) // Big endian binary.BigEndian.PutUint16(b[18:], minor) // Big endian b[20] = uint8(pwr) ...
[ "func", "(", "d", "*", "Device", ")", "AdvertiseIBeacon", "(", "ctx", "context", ".", "Context", ",", "u", "ble", ".", "UUID", ",", "major", ",", "minor", "uint16", ",", "pwr", "int8", ")", "error", "{", "b", ":=", "make", "(", "[", "]", "byte", ...
// AdvertiseIBeacon advertises iBeacon packet.
[ "AdvertiseIBeacon", "advertises", "iBeacon", "packet", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/darwin/device.go#L182-L189
132,198
currantlabs/ble
darwin/device.go
sendReq
func (d *Device) sendReq(x xpc.XPC, id int, args xpc.Dict) msg { d.sendCmd(x, id, args) return <-d.rspc }
go
func (d *Device) sendReq(x xpc.XPC, id int, args xpc.Dict) msg { d.sendCmd(x, id, args) return <-d.rspc }
[ "func", "(", "d", "*", "Device", ")", "sendReq", "(", "x", "xpc", ".", "XPC", ",", "id", "int", ",", "args", "xpc", ".", "Dict", ")", "msg", "{", "d", ".", "sendCmd", "(", "x", ",", "id", ",", "args", ")", "\n", "return", "<-", "d", ".", "r...
// sendReq sends a message and waits for its reply.
[ "sendReq", "sends", "a", "message", "and", "waits", "for", "its", "reply", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/darwin/device.go#L512-L515
132,199
currantlabs/ble
linux/hci/gap.go
Scan
func (h *HCI) Scan(allowDup bool) error { h.params.scanEnable.FilterDuplicates = 1 if allowDup { h.params.scanEnable.FilterDuplicates = 0 } h.params.scanEnable.LEScanEnable = 1 h.adHist = make([]*Advertisement, 128) h.adLast = 0 return h.Send(&h.params.scanEnable, nil) }
go
func (h *HCI) Scan(allowDup bool) error { h.params.scanEnable.FilterDuplicates = 1 if allowDup { h.params.scanEnable.FilterDuplicates = 0 } h.params.scanEnable.LEScanEnable = 1 h.adHist = make([]*Advertisement, 128) h.adLast = 0 return h.Send(&h.params.scanEnable, nil) }
[ "func", "(", "h", "*", "HCI", ")", "Scan", "(", "allowDup", "bool", ")", "error", "{", "h", ".", "params", ".", "scanEnable", ".", "FilterDuplicates", "=", "1", "\n", "if", "allowDup", "{", "h", ".", "params", ".", "scanEnable", ".", "FilterDuplicates"...
// Scan starts scanning.
[ "Scan", "starts", "scanning", "." ]
c1d21c164cf83d3360fd5abd73a3405cb588c06c
https://github.com/currantlabs/ble/blob/c1d21c164cf83d3360fd5abd73a3405cb588c06c/linux/hci/gap.go#L26-L35