Compare commits

..

No commits in common. "main" and "v1.0.6" have entirely different histories.
main ... v1.0.6

1 changed files with 21 additions and 12 deletions

View File

@ -28,6 +28,7 @@ package messages
import ( import (
"encoding/json" "encoding/json"
"log"
"math" "math"
"math/rand" "math/rand"
"os" "os"
@ -965,38 +966,46 @@ type StatusMessage struct {
States map[string]bool `json:"states,omitempty"` States map[string]bool `json:"states,omitempty"`
} }
type BleServiceData struct {
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
Data []byte `json:"data,omitempty"`
}
type BleManufacturerData struct { type BleManufacturerData struct {
CompanyId uint16 `json:"company_id,omitempty"` CompanyId uint16 `json:"company_id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Data []byte `json:"data,omitempty"` Data []byte `json:"data,omitempty"`
} }
type BleAdvertisementPayload struct {
LocalName string `json:"localName,omitempty"`
Bytes []byte `json:"bytes,omitempty"`
ManufacturerData []BleManufacturerData `json:"companies,omitempty"`
}
type BleDevice struct { type BleDevice struct {
Address string `json:"address,omitempty"` Address string `json:"address,omitempty"`
RSSI int16 `json:"rssi,omitempty"` RSSI int16 `json:"rssi,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
ManufacturerData []BleManufacturerData `json:"companies,omitempty"` Advertisement BleAdvertisementPayload `json:"advertisement,omitempty"`
} }
type BleDevicesMap map[string]BleDevice
type BleDevices []BleDevice
type BleAdvertisementMessage struct { type BleAdvertisementMessage struct {
Header MessageHeader `json:"header,omitempty"` Header MessageHeader `json:"header,omitempty"`
Device BleDevice `json:"device,omitempty"` Devices BleDevices `json:"devices,omitempty"`
} }
// noinspection GoUnusedExportedFunction // noinspection GoUnusedExportedFunction
func CreateHeader(status int, location string) MessageHeader { func CreateHeader(status int, location string) MessageHeader {
// Do we have a build version? // Do we have a build version?
// //
var build BuildVersion var build BuildVersion
buildBytes, err := os.ReadFile("/opt/build_version.json") buildBytes, err := os.ReadFile("/opt/build_version.json")
if err == nil { if err == nil {
err = json.Unmarshal(buildBytes, &build) err = json.Unmarshal(buildBytes, &build)
log.Println("[INFO] Reading version: ", string(buildBytes))
} else {
log.Println("[ERROR] Unable to read /opt/build_version.json file:", err)
} }
// Build Message Header // Build Message Header