-
Notifications
You must be signed in to change notification settings - Fork 0
/
ble_primary.go
45 lines (38 loc) · 863 Bytes
/
ble_primary.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
//go:build adv360pro_ble_primary
package main
import (
"time"
"github.com/bgould/adv360pro-firmware/adv360pro"
"github.com/bgould/adv360pro-firmware/adv360pro/ble"
"github.com/bgould/keyboard-firmware/keyboard"
)
func startBLE() {
time.Sleep(time.Second)
ble.Default.EnablePrimary(receiveNotification)
println("connected to split", ble.Default.Mode())
}
func receiveNotification(b []byte) {
if debug {
print("recv --> ")
for i, n := 0, len(b); i < n; i++ {
print(" ", b[i])
}
println()
}
if len(b) != 20 {
return
}
var overlay [adv360pro.MatrixRows]keyboard.Row
var packet ble.MatrixPacket
copy(packet[:], b)
if ok, rows, cols := packet.DecodeTo(overlay[:]); !ok {
return
} else if rows != adv360pro.MatrixRows {
return
} else if cols != adv360pro.MatrixCols {
return
}
device.SetOverlay(overlay)
}
func bleTask() {
}