-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeOS-Linux
Milestone
Description
Hello,
What version of Go are you using (go version)?
$ go version
go version go1.9.1 linux/386
What operating system and processor architecture are you using (go env)?
$ go env
GOARCH="386"
GOBIN=""
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mjohn/workspaces/goprojects"
GORACE=""
GOROOT="/home/mjohn/software/go"
GOTOOLDIR="/home/mjohn/software/go/pkg/tool/linux_386"
GCCGO="gccgo"
GO386="sse2"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build394932560=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
I'm trying to create an RFCOMM socket but not able to find a socket address type which works. Theres the Sockaddr... types available but none appear to support a Bluetooth RFCOMM socket. I'm assuming its possible because unix.AF_BLUETOOTH and unix.BTPROTO_RFCOMM are defined.
What am I missing?
package main
import (
"fmt"
"log"
"strconv"
"strings"
"syscall"
"golang.org/x/sys/unix"
)
// Bluetooth address string to byte array
func str2ba(addr string) [6]byte {
a := strings.Split(addr, ":")
var b [6]byte
for i, tmp := range a {
u, _ := strconv.ParseUint(tmp, 16, 8)
b[i] = byte(u)
}
return b
}
func main() {
fd, err := unix.Socket(syscall.AF_BLUETOOTH, syscall.SOCK_STREAM, unix.BTPROTO_RFCOMM)
if err != nil {
log.Fatalf("%v\n", err)
}
//addr := &unix.RawSockaddr?
//addr := &unix.Sockaddr..?
unix.Bind(fd, addr)
unix.Write(fd, []byte("Hello"))
var data []byte
unix.Read(fd, data)
fmt.Printf("Received: %v\n", string(data))
}
Thanks for your help!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeOS-Linux