diff --git a/api/mdns.go b/api/mdns.go index 427eef4..d67d5c8 100644 --- a/api/mdns.go +++ b/api/mdns.go @@ -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 diff --git a/api/types.go b/api/types.go index 7f01e92..91415f9 100644 --- a/api/types.go +++ b/api/types.go @@ -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 + DeviceCategoryGridConnectionHub DeviceCategoryType = 1 // Energy Management System (EMS) (device managing the electrical energy consumption/production of connected devices in the building) - DeviceCategoryEnergyManagementSystem DeviceCategory = 2 + DeviceCategoryEnergyManagementSystem DeviceCategoryType = 2 // E-mobility related device (e.g., charging station) - DeviceCategoryEMobility DeviceCategory = 3 + DeviceCategoryEMobility DeviceCategoryType = 3 // HVAC related device/system (e.g., heat pump) - DeviceCategoryHVAC DeviceCategory = 4 + DeviceCategoryHVAC DeviceCategoryType = 4 // Inverter (PV/battery/hybrid inverter) - DeviceCategoryInverter DeviceCategory = 5 + DeviceCategoryInverter DeviceCategoryType = 5 // Domestic appliance (e.g., washing machine, dryer, fridge, etc.) - DeviceCategoryDomesticAppliance DeviceCategory = 6 + DeviceCategoryDomesticAppliance DeviceCategoryType = 6 // Metering device (e.g., smart meter or sub-meter with its own communications technology) - DeviceCategoryMetering DeviceCategory = 7 + DeviceCategoryMetering DeviceCategoryType = 7 ) diff --git a/mdns/mdns.go b/mdns/mdns.go index 11f3bc4..2de8e6c 100644 --- a/mdns/mdns.go +++ b/mdns/mdns.go @@ -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 @@ -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, @@ -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 @@ -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)) } } diff --git a/mdns/mdns_test.go b/mdns/mdns_test.go index ecbee83..6499e26 100644 --- a/mdns/mdns_test.go +++ b/mdns/mdns_test.go @@ -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.DeviceCategoryEnergyManagementSystem}, "shipid", "serviceName", 4729, nil, MdnsProviderSelectionAll) s.sut.mdnsProvider = s.mdnsProvider @@ -57,7 +57,7 @@ func (s *MdnsSuite) Test_LongStrings() { "modelmodelmodelmodelmodelmodelmodel", "EnergyManagementSystemMoreLongerString", "1234567890123456789012345678901234567890", - []api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem}, + []api.DeviceCategoryType{api.DeviceCategoryEnergyManagementSystem}, "shipid", "serviceName", 4729, nil, MdnsProviderSelectionAvahiOnly) s.sut.mdnsProvider = s.mdnsProvider @@ -71,7 +71,7 @@ func (s *MdnsSuite) Test_AvahiOnly() { s.sut = NewMDNS("test", "brand", "model", "EnergyManagementSystem", "12345", - []api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem}, + []api.DeviceCategoryType{api.DeviceCategoryEnergyManagementSystem}, "shipid", "serviceName", 4729, nil, MdnsProviderSelectionAvahiOnly) s.sut.mdnsProvider = s.mdnsProvider @@ -86,7 +86,7 @@ func (s *MdnsSuite) Test_GoZeroConfOnly() { s.sut = NewMDNS("test", "brand", "model", "EnergyManagementSystem", "12345", - []api.DeviceCategory{api.DeviceCategoryEnergyManagementSystem}, + []api.DeviceCategoryType{api.DeviceCategoryEnergyManagementSystem}, "shipid", "serviceName", 4729, nil, MdnsProviderSelectionGoZeroConfOnly) s.sut.mdnsProvider = s.mdnsProvider