Skip to content

Commit

Permalink
Update AnyShake Explorer mainline data protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Aug 31, 2024
1 parent 59b9250 commit 540f148
Show file tree
Hide file tree
Showing 22 changed files with 380 additions and 292 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,26 @@ jobs:
mkdir -p ./build/release
for i in ./build/dist/*; do
arch=$(basename $i)
if [ "x$arch" != "xwin32" ] && [ "x$arch" != "xwin64" ]; then
echo "Packaging Linux $arch ..."
filename=./build/release/linux_$arch.zip
zip -rj $filename $i
elif [ "x$arch" == "xwin32" ]; then
if [ "x$arch" == "xwin32" ]; then
echo "Packaging Windows 32-bit ..."
filename=./build/release/windows_386.zip
zip -rj $filename $i
elif [ "x$arch" == "xwin64" ]; then
echo "Packaging Windows 64-bit ..."
filename=./build/release/windows_amd64.zip
zip -rj $filename $i
elif [ "x$arch" == "xwinarm" ]; then
echo "Packaging Windows arm ..."
filename=./build/release/windows_arm.zip
zip -rj $filename $i
elif [ "x$arch" == "xwinarm64" ]; then
echo "Packaging Windows arm64 ..."
filename=./build/release/windows_arm64.zip
zip -rj $filename $i
else
echo "Packaging Linux $arch ..."
filename=./build/release/linux_$arch.zip
zip -rj $filename $i
fi
done
echo "::set-output name=status::success"
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

Starting from v2.2.5, all notable changes to this project will be documented in this file.

## v3.2.1

### Breaking Changes

- **Data Protocol**: The AnyShake Explorer mainline data protocol has been updated again. **If you are using AnyShake Explorer implemented by STM32, please rebuild and burn the firmware to the latest version, if you are using AnyShake Explorer implemented by ESP8266, just ignore this message.**

### New Features

- Print log messages from AnyShake Explorer driver.
- Improved the stability of the legacy data protocol.
- Support Windows ARM32 architecture.

### Bug Fixes

- Fix SQLite "out of memory" issue on Windows release build.
- Fix release names in the GitHub Actions workflow.
- Use `time.NewTimer` instead of `time.After` to avoid memory leak.

## v3.2.0

### New Features
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ $(BUILD_ARCH):
@cp -r $(ASSETS_DIR) $(DIST_DIR)/$@

windows:
@echo "Building Windows 32-bit, 64-bit, ARM64 ..."
@mkdir -p $(DIST_DIR)/win32 $(DIST_DIR)/win64 $(DIST_DIR)/winarm
@rm -rf $(DIST_DIR)/win32/* $(DIST_DIR)/win64/* $(DIST_DIR)/winarm/*
@echo "Building Windows 32-bit, 64-bit, arm, arm64 ..."
@mkdir -p $(DIST_DIR)/win32 $(DIST_DIR)/win64 $(DIST_DIR)/winarm $(DIST_DIR)/winarm64
@rm -rf $(DIST_DIR)/win32/* $(DIST_DIR)/win64/* $(DIST_DIR)/winarm/* $(DIST_DIR)/winarm64/*
@CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/win32/$(BINARY).exe $(SRC_DIR)/*.go
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/win64/$(BINARY).exe $(SRC_DIR)/*.go
@CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags="$(BUILD_FLAGS)" \
@CGO_ENABLED=0 GOOS=windows GOARCH=arm go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/winarm/$(BINARY).exe $(SRC_DIR)/*.go
@CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/winarm64/$(BINARY).exe $(SRC_DIR)/*.go
@cp -r $(ASSETS_DIR) $(DIST_DIR)/win32
@cp -r $(ASSETS_DIR) $(DIST_DIR)/win64
@cp -r $(ASSETS_DIR) $(DIST_DIR)/winarm
@cp -r $(ASSETS_DIR) $(DIST_DIR)/winarm64

gen:
ifeq ($(shell command -v gqlgen 2> /dev/null),)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.2.0
v3.2.1
4 changes: 2 additions & 2 deletions api/v1/history/sac.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func (h *History) getSACBytes(data []explorer.ExplorerData, stationCode, network
var channelBuffer []int32
for index, record := range data {
// Make sure timestamp is continuous
if math.Abs(float64(record.Timestamp-startTimestamp-int64(index*1000))) >= explorer.EXPLORER_ALLOWED_JITTER_MS {
if math.Abs(float64(record.Timestamp-startTimestamp-int64(index*int(time.Second.Milliseconds())))) >= explorer.EXPLORER_ALLOWED_JITTER_MS {
return "", nil, fmt.Errorf(
"timestamp is not within allowed jitter %d ms, expected %d, got %d",
explorer.EXPLORER_ALLOWED_JITTER_MS,
startTimestamp+int64(index*1000),
startTimestamp+int64(index*int(time.Second.Milliseconds())),
record.Timestamp,
)
}
Expand Down
2 changes: 1 addition & 1 deletion cleaners/database/name.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package database

func (t *DatabaseCleanerTask) GetTaskName() string {
return "database"
return "cleaner_database"
}
2 changes: 1 addition & 1 deletion cleaners/explorer/name.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package explorer

func (t *ExplorerCleanerTask) GetTaskName() string {
return "explorer"
return "cleaner_explorer"
}
12 changes: 9 additions & 3 deletions drivers/dao/sqlite_windows_amd64.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dao

import (
"fmt"
"runtime"
"time"

"github.com/bclswl0827/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

type _SQLite struct{}
Expand All @@ -15,5 +15,11 @@ func (s *_SQLite) match(engine string) bool {
}

func (s *_SQLite) open(host string, port int, username, password, database string, timeout time.Duration) (*gorm.DB, error) {
return nil, fmt.Errorf("current platform %s/%s does not support SQLite", runtime.GOOS, runtime.GOARCH)
db, err := gorm.Open(sqlite.Open(database), &gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
})
sqlDB, _ := db.DB()
sqlDB.SetMaxOpenConns(1)

return db, err
}
19 changes: 19 additions & 0 deletions drivers/dao/sqlite_windows_arm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dao

import (
"fmt"
"runtime"
"time"

"gorm.io/gorm"
)

type _SQLite struct{}

func (s *_SQLite) match(engine string) bool {
return engine == "sqlite3" || engine == "sqlite"
}

func (s *_SQLite) open(host string, port int, username, password, database string, timeout time.Duration) (*gorm.DB, error) {
return nil, fmt.Errorf("current platform %s/%s does not support SQLite", runtime.GOOS, runtime.GOARCH)
}
4 changes: 1 addition & 3 deletions drivers/dao/sqlite_windows_arm64.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dao

import (
"fmt"
"time"

"github.com/bclswl0827/sqlite"
Expand All @@ -16,8 +15,7 @@ func (s *_SQLite) match(engine string) bool {
}

func (s *_SQLite) open(host string, port int, username, password, database string, timeout time.Duration) (*gorm.DB, error) {
dsn := fmt.Sprintf("file://%s?cache=shared&mode=rwc&_pragma=busy_timeout(%d)", database, int(timeout.Seconds()))
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{
db, err := gorm.Open(sqlite.Open(database), &gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
})
sqlDB, _ := db.DB()
Expand Down
Loading

0 comments on commit 540f148

Please sign in to comment.