-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (49 loc) · 1.17 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"os"
"time"
"github.com/motoboxcn/audio-communication/pkg/audio"
"github.com/motoboxcn/audio-communication/pkg/bluetooth"
"github.com/patsnapops/noop/log"
)
const (
VIMOTOV9S string = "1C:05:B7:11:D8:EE"
BTS_06 string = "41:42:2C:8D:52:A3"
mikasiPhone string = "5C:87:30:3C:29:6B"
mk string = "48:74:6E:85:84:D0"
XiaoMi string = "00:42:79:2C:3D:D7"
BT_12 string = "EB:06:EF:6B:09:72"
)
func init() {
log.Default().WithLevel(log.DebugLevel).WithHumanTime(time.Local).Init()
}
func main() {
args := os.Args
bluetoothClient := bluetooth.NewBluetoothClient(BT_12)
if len(args) < 2 {
audioStart()
} else {
switch args[1] {
case "con":
err := bluetoothClient.Connect()
if err != nil {
log.Errorf("bluetoothClient.Connect() failed: %v", err)
}
case "dis":
err := bluetoothClient.Disconnect()
if err != nil {
log.Errorf("bluetoothClient.Disconnect() failed: %v", err)
}
case "audio":
audioStart()
default:
log.Infof("not support args[1]: %v", args[1])
}
}
}
func audioStart() {
audioClient := audio.NewAudioClient()
audioClient.Start()
time.Sleep(10 * time.Second)
audioClient.Stop()
}