mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
add Offline in bluetooth_page
This commit is contained in:
parent
fa44237a56
commit
4da846400e
0
Menu/GameShell/10_Settings/Airplane/plugin_init.go
Normal file
0
Menu/GameShell/10_Settings/Airplane/plugin_init.go
Normal file
@ -495,6 +495,8 @@ type BluetoothPage struct{
|
|||||||
|
|
||||||
LastStatusMsg string
|
LastStatusMsg string
|
||||||
ADAPTER_DEV string // == adapterID
|
ADAPTER_DEV string // == adapterID
|
||||||
|
|
||||||
|
Offline bool
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,8 +681,21 @@ func (self *BluetoothPage) Rescan() {
|
|||||||
|
|
||||||
|
|
||||||
func (self *BluetoothPage) OnLoadCb() {
|
func (self *BluetoothPage) OnLoadCb() {
|
||||||
self.RefreshDevices()
|
self.Offline = false
|
||||||
self.GenNetworkList()
|
|
||||||
|
if self.Screen.TitleBar.InAirPlaneMode == false {
|
||||||
|
out := System("hcitool dev | grep hci0 |cut -f3")
|
||||||
|
if len(out) < 17 {
|
||||||
|
self.Offline = true
|
||||||
|
fmt.Println("Bluetooth OnLoadCb ,can not find hci0 alive,try to reboot")
|
||||||
|
}else {
|
||||||
|
self.RefreshDevices()
|
||||||
|
self.GenNetworkList()
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
self.Offline = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BluetoothPage) ScrollUp() {
|
func (self *BluetoothPage) ScrollUp() {
|
||||||
@ -723,6 +738,10 @@ func (self *BluetoothPage) ScrollDown() {
|
|||||||
func (self *BluetoothPage) KeyDown(ev *event.Event) {
|
func (self *BluetoothPage) KeyDown(ev *event.Event) {
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||||
|
if self.Offline == true {
|
||||||
|
self.AbortedAndReturnToUpLevel()
|
||||||
|
return
|
||||||
|
}
|
||||||
err := bleapi.StopDiscovery()
|
err := bleapi.StopDiscovery()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -751,14 +770,18 @@ func (self *BluetoothPage) KeyDown(ev *event.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||||
self.Rescan()
|
if self.Offline == false{
|
||||||
|
self.Rescan()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["Y"] {
|
if ev.Data["Key"] == UI.CurKeys["Y"] {
|
||||||
if len(self.MyList) == 0 {
|
if len(self.MyList) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if self.Offline = true {
|
||||||
|
return
|
||||||
|
}
|
||||||
self.InfoPage.Props = self.MyList[self.PsIndex].(*NetItem).Props
|
self.InfoPage.Props = self.MyList[self.PsIndex].(*NetItem).Props
|
||||||
self.InfoPage.Path = self.MyList[self.PsIndex].(*NetItem).Path
|
self.InfoPage.Path = self.MyList[self.PsIndex].(*NetItem).Path
|
||||||
self.InfoPage.MyDevice = self.MyList[self.PsIndex].(*NetItem).Device
|
self.InfoPage.MyDevice = self.MyList[self.PsIndex].(*NetItem).Device
|
||||||
@ -769,9 +792,9 @@ func (self *BluetoothPage) KeyDown(ev *event.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||||
|
if self.Offline == false {
|
||||||
self.TryConnect()
|
self.TryConnect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user