add bluetooth basic pairing and spanish

This commit is contained in:
cuu
2019-02-07 18:59:02 +08:00
parent 4478ad237a
commit cbb49f5f78
5 changed files with 453 additions and 11 deletions

View File

@@ -8,7 +8,7 @@ import (
"github.com/muka/go-bluetooth/api"
"github.com/muka/go-bluetooth/emitter"
"github.com/muka/go-bluetooth/linux"
"github.com/muka/go-bluetooth/bluez/profile"
/*
"github.com/veandco/go-sdl2/ttf"
@@ -27,13 +27,27 @@ import (
type BluetoothPlugin struct {
UI.Plugin
BluetoothPage *BluetoothPage
PairPage *BleAgentPairPage
}
const (
adapterID = "hci0"
BUS_NAME = "org.bluez"
AGENT_INTERFACE = "org.bluez.Agent1"
AGENT_PATH = "/gameshell/bleagentgo"
)
func (self *BluetoothPlugin) InitAgent() {
agent := &Agent{}
agent.BusName = BUS_NAME
agent.AgentInterface = AGENT_INTERFACE
agent.AgentPath = AGENT_PATH
agent.Leader = self
RegisterAgent(agent, profile.AGENT_CAP_KEYBOARD_DISPLAY)
}
func (self *BluetoothPlugin) Init( main_screen *UI.MainScreen ) {
log.Println("Reset bluetooth device")
@@ -45,14 +59,20 @@ func (self *BluetoothPlugin) Init( main_screen *UI.MainScreen ) {
os.Exit(1)
}
self.BluetoothPage = NewBluetoothPage()
self.BluetoothPage.SetScreen( main_screen)
self.BluetoothPage.SetName("Bluetooth")
self.BluetoothPage.Leader = self
self.BluetoothPage.Init()
self.PairPage = NewBleAgentPairPage()
self.PairPage.SetScreen( main_screen)
self.PairPage.SetName("Bluetooth pair")
self.PairPage.Leader = self
self.PairPage.Init()
self.InitAgent()
err = api.On("discovery", emitter.NewCallback(func(ev emitter.Event) {
//discoveryEvent := ev.GetData().(api.DiscoveredDeviceEvent)
//dev := discoveryEvent.Device