Skip to content

Commit

Permalink
Update to ChirpStack v4.8.1 db scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed May 15, 2024
1 parent 129c86e commit 8191698
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ database will be removed!

## Notes

* This utility is compatible with the ChirpStack v4.7.0 database schema.
* This utility is compatible with the ChirpStack v4.8.1 database schema.
* This utility does not support [environment variables](https://www.chirpstack.io/docs/chirpstack/configuration.html#environment-variables) in configuration files, like ChirpStack does.

## Building from source
Expand Down
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"io/ioutil"
"log"
"math"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -742,7 +743,7 @@ func migrateMulticastGroupsFn() {
"group_type",
"dr",
"frequency",
"class_b_ping_slot_period",
"class_b_ping_slot_nb_k",
"class_c_scheduling_type",
))
if err != nil {
Expand All @@ -759,6 +760,11 @@ func migrateMulticastGroupsFn() {

found = true

pingSlotNbK := nsMCGroup.PingSlotPeriod
if pingSlotNbK != 0 {
pingSlotNbK = uint32(math.Log2(float64(pingSlotNbK) / 32.0))
}

_, err = stmt.Exec(
nsMCGroup.ID,
intToUUID(asMCGroup.ApplicationID),
Expand All @@ -773,7 +779,7 @@ func migrateMulticastGroupsFn() {
nsMCGroup.GroupType,
nsMCGroup.DR,
nsMCGroup.Frequency,
nsMCGroup.PingSlotPeriod,
pingSlotNbK,
"DELAY",
)
if err != nil {
Expand Down Expand Up @@ -1532,6 +1538,7 @@ func migrateDeviceProfilesFn() {
"relay_global_uplink_limit_bucket_size",
"relay_overall_limit_bucket_size",
"allow_roaming",
"rx1_delay",
))
if err != nil {
log.Fatal("Prepare device-profile statement error", err)
Expand Down Expand Up @@ -1625,6 +1632,7 @@ function encodeDownlink(input) {
0,
0,
true,
0,
)
if err != nil {
log.Fatal("Exec device-profile statement error", err)
Expand Down

0 comments on commit 8191698

Please sign in to comment.