Skip to content

Commit

Permalink
Fix type naming
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Oct 6, 2024
1 parent 5b07853 commit ec6c987
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
26 changes: 13 additions & 13 deletions api/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import "net"
/* Mdns */

type MdnsEntry struct {
Name string // the mDNS service name
Ski string // mandatory the certificates SKI
Identifier string // mandatory, the identifier used for SHIP ID
Path string // mandatory, the websocket path
Register bool // mandatory, wether auto accept is enabled
Brand string // optional, the brand of the device
Type string // optional, the type of the device
Model string // optional, the model of the device
Serial string // recommended, the serial number of the device
Categories []DeviceCategory // mandatory, the device categories of the device. Can be empty when the device does not conform to SHIP Requirements for Installation Process
Host string // mandatory, the host name
Port int // mandatory, the port for the websocket service
Addresses []net.IP // mandatory, the IP addresses used by the service
Name string // the mDNS service name
Ski string // mandatory the certificates SKI
Identifier string // mandatory, the identifier used for SHIP ID
Path string // mandatory, the websocket path
Register bool // mandatory, wether auto accept is enabled
Brand string // optional, the brand of the device
Type string // optional, the type of the device
Model string // optional, the model of the device
Serial string // recommended, the serial number of the device
Categories []DeviceCategoryType // mandatory, the device categories of the device. Can be empty when the device does not conform to SHIP Requirements for Installation Process
Host string // mandatory, the host name
Port int // mandatory, the port for the websocket service
Addresses []net.IP // mandatory, the IP addresses used by the service
}

// implemented by Hub, used by mdns
Expand Down
16 changes: 8 additions & 8 deletions api/types.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package api

type DeviceCategory uint
type DeviceCategoryType uint

const (
// Grid Connection Point Hub (GCPH) (e.g. a control unit from the public grid operator)
DeviceCategoryGridConnectionHub DeviceCategory = 1
DeviceCategoryTypeGridConnectionHub DeviceCategoryType = 1
// Energy Management System (EMS) (device managing the electrical energy consumption/production of connected devices in the building)
DeviceCategoryEnergyManagementSystem DeviceCategory = 2
DeviceCategoryTypeEnergyManagementSystem DeviceCategoryType = 2
// E-mobility related device (e.g., charging station)
DeviceCategoryEMobility DeviceCategory = 3
DeviceCategoryTypeEMobility DeviceCategoryType = 3
// HVAC related device/system (e.g., heat pump)
DeviceCategoryHVAC DeviceCategory = 4
DeviceCategoryTypeHVAC DeviceCategoryType = 4
// Inverter (PV/battery/hybrid inverter)
DeviceCategoryInverter DeviceCategory = 5
DeviceCategoryTypeInverter DeviceCategoryType = 5
// Domestic appliance (e.g., washing machine, dryer, fridge, etc.)
DeviceCategoryDomesticAppliance DeviceCategory = 6
DeviceCategoryTypeDomesticAppliance DeviceCategoryType = 6
// Metering device (e.g., smart meter or sub-meter with its own communications technology)
DeviceCategoryMetering DeviceCategory = 7
DeviceCategoryTypeMetering DeviceCategoryType = 7
)
8 changes: 4 additions & 4 deletions mdns/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type MdnsManager struct {
deviceType string

// the device categories
deviceCategories []api.DeviceCategory
deviceCategories []api.DeviceCategoryType

// the identifier to be used for mDNS and SHIP ID
identifier string
Expand Down Expand Up @@ -103,7 +103,7 @@ func shortenString(s string, maxLen int) string {
// - providerSelection: the mDNS provider selection
func NewMDNS(
ski, deviceBrand, deviceModel, deviceType, deviceSerial string,
deviceCategories []api.DeviceCategory,
deviceCategories []api.DeviceCategoryType,
shipIdentifier, serviceName string,
port int,
ifaces []string,
Expand Down Expand Up @@ -416,7 +416,7 @@ func (m *MdnsManager) processMdnsEntry(elements map[string]string, name, host st
serial = value
}

var categories []api.DeviceCategory
var categories []api.DeviceCategoryType
var categoriesStr string
if value, ok := elements["cat"]; ok {
categoriesStr = value
Expand All @@ -427,7 +427,7 @@ func (m *MdnsManager) processMdnsEntry(elements map[string]string, name, host st
logging.Log().Debug("mdns: txt - invalid category", item)
continue
}
categories = append(categories, api.DeviceCategory(category))
categories = append(categories, api.DeviceCategoryType(category))
}
}

Expand Down
8 changes: 4 additions & 4 deletions mdns/mdns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *MdnsSuite) BeforeTest(suiteName, testName string) {

s.sut = NewMDNS("test", "brand", "model", "EnergyManagementSystem",
"12345",
[]api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem},
[]api.DeviceCategoryType{api.DeviceCategoryTypeEnergyManagementSystem},
"shipid", "serviceName",
4729, nil, MdnsProviderSelectionAll)
s.sut.mdnsProvider = s.mdnsProvider
Expand All @@ -57,7 +57,7 @@ func (s *MdnsSuite) Test_LongStrings() {
"modelmodelmodelmodelmodelmodelmodel",
"EnergyManagementSystemMoreLongerString",
"1234567890123456789012345678901234567890",
[]api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem},
[]api.DeviceCategoryType{api.DeviceCategoryTypeEnergyManagementSystem},
"shipid", "serviceName",
4729, nil, MdnsProviderSelectionAvahiOnly)
s.sut.mdnsProvider = s.mdnsProvider
Expand All @@ -71,7 +71,7 @@ func (s *MdnsSuite) Test_AvahiOnly() {

s.sut = NewMDNS("test", "brand", "model", "EnergyManagementSystem",
"12345",
[]api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem},
[]api.DeviceCategoryType{api.DeviceCategoryTypeEnergyManagementSystem},
"shipid", "serviceName",
4729, nil, MdnsProviderSelectionAvahiOnly)
s.sut.mdnsProvider = s.mdnsProvider
Expand All @@ -86,7 +86,7 @@ func (s *MdnsSuite) Test_GoZeroConfOnly() {

s.sut = NewMDNS("test", "brand", "model", "EnergyManagementSystem",
"12345",
[]api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem},
[]api.DeviceCategoryType{api.DeviceCategoryTypeEnergyManagementSystem},
"shipid", "serviceName",
4729, nil, MdnsProviderSelectionGoZeroConfOnly)
s.sut.mdnsProvider = s.mdnsProvider
Expand Down

0 comments on commit ec6c987

Please sign in to comment.