From 81916983ac211ba6fec2a69dc5067edfb61fd88e Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Wed, 15 May 2024 14:42:27 +0100 Subject: [PATCH] Update to ChirpStack v4.8.1 db scheme. --- README.md | 2 +- main.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bcbd796..63fb402 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.go b/main.go index 313fd32..f7240bd 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "fmt" "io/ioutil" "log" + "math" "os" "strconv" "strings" @@ -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 { @@ -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), @@ -773,7 +779,7 @@ func migrateMulticastGroupsFn() { nsMCGroup.GroupType, nsMCGroup.DR, nsMCGroup.Frequency, - nsMCGroup.PingSlotPeriod, + pingSlotNbK, "DELAY", ) if err != nil { @@ -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) @@ -1625,6 +1632,7 @@ function encodeDownlink(input) { 0, 0, true, + 0, ) if err != nil { log.Fatal("Exec device-profile statement error", err)