Minor fixes for alpha2

This commit is contained in:
MaMe82 2018-12-07 00:59:54 +01:00
parent a585a39b2b
commit 74a373f895
46 changed files with 83 additions and 209 deletions

View File

@ -46,13 +46,13 @@ dep:
#go get -u github.com/gorilla/websocket
compile:
go get -u github.com/mame82/P4wnP1_go/... # partially downloads again, but we need the library packages in go path to build
go get -u github.com/mame82/P4wnP1_aloa/... # partially downloads again, but we need the library packages in go path to build
# <--- second compilation, maybe -d flag on go get above is better
env GOBIN=$(CURDIR)/build go install ./cmd/... # compile all main packages to the build folder
# compile the web app
# ToDo: (check if dependencies have been fetched by 'go get', even with the build js tags)
$(HOME)/go/bin/gopherjs get github.com/mame82/P4wnP1_go/web_client/...
$(HOME)/go/bin/gopherjs get github.com/mame82/P4wnP1_aloa/web_client/...
$(HOME)/go/bin/gopherjs build -m -o build/webapp.js web_client/*.go
installkali:

View File

@ -2,7 +2,7 @@ package cli_client
import (
"context"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_aloa/common"
"github.com/spf13/cobra"
"fmt"
"path/filepath"
@ -13,7 +13,7 @@ import (
"errors"
"log"
"strconv"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
)
var (

View File

@ -4,7 +4,7 @@ import (
"github.com/spf13/cobra"
"os"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"fmt"
"log"
)

View File

@ -2,15 +2,15 @@ package cli_client
import (
"github.com/spf13/cobra"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"net"
"errors"
"fmt"
"google.golang.org/grpc/status"
//"github.com/mame82/P4wnP1_go/service"
//"github.com/mame82/P4wnP1_aloa/service"
"strings"
"strconv"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_aloa/common_web"
)
//Empty settings used to store cobra flags

View File

@ -2,7 +2,7 @@ package cli_client
import (
"fmt"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_aloa/common_web"
"os"
"github.com/spf13/cobra"

View File

@ -2,7 +2,7 @@ package cli_client
import (
"fmt"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"os"

View File

@ -3,7 +3,7 @@ package cli_client
import (
"encoding/json"
"fmt"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/spf13/cobra"
"log"
"os"

View File

@ -2,7 +2,7 @@ package cli_client
import (
"github.com/spf13/cobra"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"fmt"
"google.golang.org/grpc/status"
"os"

View File

@ -2,7 +2,7 @@ package cli_client
import (
"fmt"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"errors"
"context"
"google.golang.org/grpc"

View File

@ -1,7 +1,7 @@
package main
import (
"github.com/mame82/P4wnP1_go/cli_client"
"github.com/mame82/P4wnP1_aloa/cli_client"
)
func main() {

View File

@ -4,8 +4,8 @@ package main
import (
"fmt"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_go/service"
"github.com/mame82/P4wnP1_aloa/common_web"
"github.com/mame82/P4wnP1_aloa/service"
"log"
"os"
"os/signal"

View File

@ -3,7 +3,7 @@
package main
import(
"github.com/mame82/P4wnP1_go/hid"
"github.com/mame82/P4wnP1_aloa/hid"
"log"
"fmt"

View File

@ -4,6 +4,6 @@ const (
MAJOR = 0
MINOR = 1
PATCH = 0
SUFFIX = "-alpha1"
SUFFIX = "-alpha2"
VERSION = "v0.1.0"+SUFFIX
)

BIN
dist/db/init.db vendored

Binary file not shown.

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/mame82/P4wnP1_go
module github.com/mame82/P4wnP1_aloa
require (
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 // indirect

View File

@ -1,7 +1,7 @@
package mgenetlink
import (
nl "github.com/mame82/P4wnP1_go/mnetlink"
nl "github.com/mame82/P4wnP1_aloa/mnetlink"
"errors"
"golang.org/x/sys/unix"
"log"

View File

@ -1,5 +1,5 @@
package mgenetlink
import "github.com/mame82/P4wnP1_go/mnetlink"
import "github.com/mame82/P4wnP1_aloa/mnetlink"
var hbo = mnetlink.Hbo()

View File

@ -3,7 +3,7 @@ package mgenetlink
import (
"errors"
"fmt"
"github.com/mame82/P4wnP1_go/mnetlink"
"github.com/mame82/P4wnP1_aloa/mnetlink"
"golang.org/x/sys/unix"
)

View File

@ -2,7 +2,7 @@ package mgenetlink
import (
"fmt"
"github.com/mame82/P4wnP1_go/mnetlink"
"github.com/mame82/P4wnP1_aloa/mnetlink"
"errors"
"golang.org/x/sys/unix"
)

View File

@ -1,7 +1,7 @@
package mgenetlink
import (
"github.com/mame82/P4wnP1_go/mnetlink"
"github.com/mame82/P4wnP1_aloa/mnetlink"
"golang.org/x/sys/unix"
"errors"
)

View File

@ -2,7 +2,7 @@ package mgenetlink
import (
"fmt"
"github.com/mame82/P4wnP1_go/mnetlink"
"github.com/mame82/P4wnP1_aloa/mnetlink"
"golang.org/x/sys/unix"
)

View File

@ -3,9 +3,9 @@ package service
import (
"context"
"fmt"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_go/hid"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_aloa/common_web"
"github.com/mame82/P4wnP1_aloa/hid"
pb "github.com/mame82/P4wnP1_aloa/proto"
"log"
"sync"
"time"

View File

@ -5,7 +5,7 @@ package service
import (
"context"
"fmt"
"github.com/mame82/P4wnP1_go/service/pgpio"
"github.com/mame82/P4wnP1_aloa/service/pgpio"
"periph.io/x/periph"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
@ -15,7 +15,7 @@ import (
"sync"
"time"
"errors"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
)
var (

View File

@ -1,7 +1,7 @@
package service
import (
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
"io/ioutil"
"log"
"os"

View File

@ -4,9 +4,9 @@ import (
"errors"
"fmt"
//"github.com/docker/libcontainer/netlink"
"github.com/mame82/P4wnP1_go/netlink"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_go/service/util"
"github.com/mame82/P4wnP1_aloa/netlink"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/mame82/P4wnP1_aloa/service/util"
"io/ioutil"
"log"
"net"

View File

@ -6,10 +6,10 @@ import (
"context"
"errors"
"fmt"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_go/service/util"
"github.com/mame82/P4wnP1_aloa/common"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/mame82/P4wnP1_aloa/service/util"
"io/ioutil"
"sync"
)

View File

@ -6,9 +6,9 @@ import (
"context"
"errors"
"fmt"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/hid"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_aloa/common"
"github.com/mame82/P4wnP1_aloa/hid"
pb "github.com/mame82/P4wnP1_aloa/proto"
"io/ioutil"
"log"
"net"

View File

@ -5,10 +5,12 @@ package service
import (
"errors"
"fmt"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_go/service/bluetooth"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/mame82/P4wnP1_aloa/service/bluetooth"
"github.com/mame82/mblue-toolz/toolz"
"io/ioutil"
"log"
"os"
"os/exec"
"regexp"
"strconv"
@ -493,6 +495,10 @@ func (bt *BtService) EnableBridge() (err error) {
log.Println("... reconfigure ethernet settings for interface", bt.BrName)
if mi, err := bt.RootSvc.SubSysNetwork.GetManagedInterface(bt.BrName); err == nil {
mi.ReDeploy()
// disable IPv6 for bridge interface
//ioutil.WriteFile("/proc/sys/net/ipv6/conf/" + bt.BrName + "/disable_ipv6", []byte("1"), os.ModePerm)
// disable IPv6 for all interfaces
ioutil.WriteFile("/proc/sys/net/ipv6/conf/all/disable_ipv6", []byte("1"), os.ModePerm)
}

View File

@ -9,12 +9,12 @@ import (
"sync"
"time"
//"github.com/mame82/P4wnP1_go/service"
//"github.com/mame82/P4wnP1_aloa/service"
"github.com/mame82/mblue-toolz/btmgmt"
"github.com/mame82/mblue-toolz/dbusHelper"
"github.com/mame82/mblue-toolz/toolz"
"errors"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
)

View File

@ -1,7 +1,7 @@
package service
import (
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
)
const (

View File

@ -7,8 +7,8 @@ import (
"bytes"
"errors"
"fmt"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto"
"io/ioutil"
"log"
"net"

View File

@ -5,10 +5,10 @@ package service
import (
"fmt"
"errors"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_aloa/common_web"
genl "github.com/mame82/P4wnP1_go/mgenetlink"
nl "github.com/mame82/P4wnP1_go/mnetlink"
genl "github.com/mame82/P4wnP1_aloa/mgenetlink"
nl "github.com/mame82/P4wnP1_aloa/mnetlink"
)
/*

View File

@ -7,7 +7,7 @@ import(
"time"
"sync/atomic"
pb "github.com/mame82/P4wnP1_go/proto"
pb "github.com/mame82/P4wnP1_aloa/proto"
)
const (

View File

@ -1,132 +0,0 @@
package peripheral
import (
"fmt"
"github.com/warthog618/gpio"
"time"
)
/*
// https://www.waveshare.com/1.3inch-oled-hat.htm
KEY1 P21 Button 1/GPIO
KEY2 P20 Button 2/GPIO
KEY3 P16 Button 3/GPIO
Joystick Up P6 Joystick Up
Joystick Down P19 Joystick Down
Joystick Left P5 Joystick Left
Joystick Right P26 Joystick Right
Joystick Press P13 Joystick Press
SCLK P11/SCLK SPI clock input
MOSI P10/MOSI SPI data input
DC P24 Data/Command selection (high for data, low for command)
CS P8/CE0 Chip selection, low active
RST P25 Reset, low active
*/
var timeLastEvent time.Time
const (
WAVESHARE_OLED_GPIO_KEY_1 = gpio.GPIO21
WAVESHARE_OLED_GPIO_KEY_2 = gpio.GPIO20
WAVESHARE_OLED_GPIO_KEY_3 = gpio.GPIO16
WAVESHARE_OLED_GPIO_JOY_UP = gpio.GPIO6
WAVESHARE_OLED_GPIO_JOY_DOWN = gpio.GPIO19
WAVESHARE_OLED_GPIO_JOY_LEFT = gpio.GPIO5
WAVESHARE_OLED_GPIO_JOY_RIGHT = gpio.GPIO26
WAVESHARE_OLED_GPIO_JOY_PRESS = gpio.GPIO13
)
var waveshareRelevantEvents = []uint8{
WAVESHARE_OLED_GPIO_JOY_DOWN,
WAVESHARE_OLED_GPIO_JOY_LEFT,
WAVESHARE_OLED_GPIO_JOY_RIGHT,
WAVESHARE_OLED_GPIO_JOY_UP,
WAVESHARE_OLED_GPIO_JOY_PRESS,
WAVESHARE_OLED_GPIO_KEY_1,
WAVESHARE_OLED_GPIO_KEY_2,
WAVESHARE_OLED_GPIO_KEY_3,
}
type WaveshareOledEvent int
const (
PRESSED_UP WaveshareOledEvent = iota
PRESSED_DOWN
PRESSED_LEFT
PRESSED_RIGHT
PRESSED_STICK
PRESSED_KEY1
PRESSED_KEY2
PRESSED_KEY3
)
var pin2function = map[uint8]WaveshareOledEvent{
WAVESHARE_OLED_GPIO_KEY_1: PRESSED_KEY1,
WAVESHARE_OLED_GPIO_KEY_2: PRESSED_KEY2,
WAVESHARE_OLED_GPIO_KEY_3: PRESSED_KEY3,
WAVESHARE_OLED_GPIO_JOY_UP: PRESSED_UP,
WAVESHARE_OLED_GPIO_JOY_DOWN: PRESSED_DOWN,
WAVESHARE_OLED_GPIO_JOY_LEFT: PRESSED_LEFT,
WAVESHARE_OLED_GPIO_JOY_RIGHT: PRESSED_RIGHT,
WAVESHARE_OLED_GPIO_JOY_PRESS: PRESSED_STICK,
}
var function2string = map[WaveshareOledEvent]string{
PRESSED_KEY1: "KEY 1",
PRESSED_KEY2: "KEY 2",
PRESSED_KEY3: "KEY 3",
PRESSED_UP: "UP",
PRESSED_DOWN: "DOWN",
PRESSED_LEFT: "LEFT",
PRESSED_RIGHT: "RIGHT",
PRESSED_STICK: "STICK",
}
type WaveshareOled struct {
pins []*gpio.Pin
gpioOpened bool
}
func (w *WaveshareOled) GetHandler(event WaveshareOledEvent) (func(*gpio.Pin)) {
timeLastEvent = time.Now()
return func(pin *gpio.Pin) {
if str,okay := function2string[event]; okay {
if time.Since(timeLastEvent) > 200*time.Millisecond {
fmt.Printf("%s pressed\n", str)
timeLastEvent = time.Now()
// send to output channel if needed here
}
//fmt.Printf("%+v\n", pin)
} else {
fmt.Println("Unknown GPIO input")
}
}
}
func (w *WaveshareOled) Start() (err error) {
err = gpio.Open()
if err != nil {
return
}
w.pins = make([]*gpio.Pin, len(waveshareRelevantEvents))
for idx, evtPinNum := range waveshareRelevantEvents {
pin := gpio.NewPin(evtPinNum)
w.pins[idx] = pin
pin.Input()
pin.PullUp()
pin.Watch(gpio.EdgeFalling, w.GetHandler(pin2function[evtPinNum]))
}
return nil
}
func (w *WaveshareOled) Stop() {
for _, p := range w.pins {
p.Unwatch()
p.PullNone()
}
gpio.Close()
}

View File

@ -7,10 +7,10 @@ import (
"errors"
"fmt"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_go/service/bluetooth"
"github.com/mame82/P4wnP1_aloa/common"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/mame82/P4wnP1_aloa/service/bluetooth"
"golang.org/x/net/context"
"google.golang.org/grpc"
"io"

View File

@ -5,10 +5,10 @@ package service
import (
"context"
"fmt"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_go/service/datastore"
"github.com/mame82/P4wnP1_aloa/common"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto"
"github.com/mame82/P4wnP1_aloa/service/datastore"
"log"
"syscall"
"time"

View File

@ -3,12 +3,12 @@
package service
import (
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_go/netlink"
pb "github.com/mame82/P4wnP1_go/proto"
"github.com/mame82/P4wnP1_aloa/common_web"
"github.com/mame82/P4wnP1_aloa/netlink"
pb "github.com/mame82/P4wnP1_aloa/proto"
"sync"
"os/exec"
"github.com/mame82/P4wnP1_go/service/util"
"github.com/mame82/P4wnP1_aloa/service/util"
"errors"
"fmt"
"strings"

View File

@ -4,7 +4,7 @@ package main
import (
"github.com/mame82/hvue"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_aloa/common_web"
"github.com/gopherjs/gopherjs/js"
)

View File

@ -4,7 +4,7 @@ package main
import (
"github.com/gopherjs/gopherjs/js"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"github.com/mame82/hvue"
)

View File

@ -5,7 +5,7 @@ package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/mame82/hvue"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
)
type jsBluetoothRequestSettingsStorage struct {

View File

@ -5,7 +5,7 @@ package main
import (
//"github.com/mame82/hvue"
"github.com/gopherjs/gopherjs/js"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"github.com/mame82/hvue"
)

View File

@ -5,8 +5,8 @@ package main
import (
"errors"
"github.com/gopherjs/gopherjs/js"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"github.com/mame82/hvue"
"strconv"
)

View File

@ -4,7 +4,7 @@ package main
import (
"github.com/gopherjs/gopherjs/js"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"github.com/mame82/hvue"
"strconv"
)

View File

@ -5,7 +5,7 @@ package main
import (
// "honnef.co/go/js/dom"
"github.com/gopherjs/gopherjs/js"
"github.com/mame82/P4wnP1_go/common_web"
"github.com/mame82/P4wnP1_aloa/common_web"
"github.com/mame82/hvue"
"github.com/mame82/mvuex"
)
@ -126,7 +126,7 @@ const templateMainApp = `
<q-layout-footer class="desktop-only">
<q-toolbar>
<q-toolbar-title>
<div slot="subtitle">by MaMe82 ` + common_web.VERSION + ` by MaMe82</div>
<div slot="subtitle">` + common_web.VERSION + ` by MaMe82</div>
</q-toolbar-title>
</q-toolbar>
</q-layout-footer>

View File

@ -5,8 +5,8 @@ package main
import (
"context"
"github.com/gopherjs/gopherjs/js"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"github.com/mame82/hvue"
"github.com/mame82/mvuex"
"errors"

View File

@ -6,8 +6,8 @@ import (
"context"
"errors"
"github.com/johanbrandhorst/protobuf/grpcweb"
"github.com/mame82/P4wnP1_go/common_web"
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
"github.com/mame82/P4wnP1_aloa/common_web"
pb "github.com/mame82/P4wnP1_aloa/proto/gopherjs"
"sync"
"time"
)