Skip to content

Commit

Permalink
Merge branch 'hotfix/v0.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Jan 29, 2023
2 parents daa9991 + e548d2d commit 66b6818
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
version: latest
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=3m --issues-exit-code=0 ./...

- name: Test
run: go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
Expand Down
2 changes: 0 additions & 2 deletions features/deviceclassification.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -43,7 +42,6 @@ func (d *DeviceClassification) RequestManufacturerDetailsForEntity() (*model.Msg
// request DeviceClassificationManufacturer from a remote entity
msgCounter, err := d.requestData(model.FunctionTypeDeviceClassificationManufacturerData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
3 changes: 0 additions & 3 deletions features/deviceconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package features
import (
"time"

"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -42,7 +41,6 @@ func NewDeviceConfiguration(localRole, remoteRole model.RoleType, spineLocalDevi
func (d *DeviceConfiguration) Request() error {
// request DeviceConfigurationKeyValueDescriptionListData from a remote entity
if _, err := d.requestData(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -54,7 +52,6 @@ func (d *DeviceConfiguration) RequestKeyValueList() (*model.MsgCounterType, erro
// request FunctionTypeDeviceConfigurationKeyValueListData from a remote entity
msgCounter, err := d.requestData(model.FunctionTypeDeviceConfigurationKeyValueListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
2 changes: 0 additions & 2 deletions features/devicediagnosis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -33,7 +32,6 @@ func (d *DeviceDiagnosis) RequestStateForEntity() (*model.MsgCounterType, error)
// request FunctionTypeDeviceDiagnosisStateData from a remote entity
msgCounter, err := d.requestData(model.FunctionTypeDeviceDiagnosisStateData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
4 changes: 0 additions & 4 deletions features/electricalconnection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -44,7 +43,6 @@ func NewElectricalConnection(localRole, remoteRole model.RoleType, spineLocalDev
// request ElectricalConnectionDescriptionListDataType from a remote entity
func (e *ElectricalConnection) RequestDescription() error {
if _, err := e.requestData(model.FunctionTypeElectricalConnectionDescriptionListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -54,7 +52,6 @@ func (e *ElectricalConnection) RequestDescription() error {
// request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity
func (e *ElectricalConnection) RequestParameterDescription() error {
if _, err := e.requestData(model.FunctionTypeElectricalConnectionParameterDescriptionListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -65,7 +62,6 @@ func (e *ElectricalConnection) RequestParameterDescription() error {
func (e *ElectricalConnection) RequestPermittedValueSet() (*model.MsgCounterType, error) {
msgCounter, err := e.requestData(model.FunctionTypeElectricalConnectionPermittedValueSetListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion features/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (f *FeatureImpl) requestData(function model.FunctionType, selectors any, el

msgCounter, fErr := f.featureLocal.RequestData(function, selectors, elements, f.featureRemote)
if fErr != nil {
logging.Log.Error(fErr.String())
logging.Log.Debug(fErr.String())
return nil, errors.New(fErr.String())
}

Expand Down
2 changes: 0 additions & 2 deletions features/identification.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -32,7 +31,6 @@ func NewIdentification(localRole, remoteRole model.RoleType, spineLocalDevice *s
func (i *Identification) Request() (*model.MsgCounterType, error) {
msgCounter, err := i.requestData(model.FunctionTypeIdentificationListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
4 changes: 0 additions & 4 deletions features/incentivetable.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand All @@ -27,7 +26,6 @@ func NewIncentiveTable(localRole, remoteRole model.RoleType, spineLocalDevice *s
func (i *IncentiveTable) RequestDescription() error {
_, err := i.requestData(model.FunctionTypeIncentiveTableDescriptionData, nil, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -38,7 +36,6 @@ func (i *IncentiveTable) RequestDescription() error {
func (i *IncentiveTable) RequestConstraints() error {
_, err := i.requestData(model.FunctionTypeIncentiveTableConstraintsData, nil, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -49,7 +46,6 @@ func (i *IncentiveTable) RequestConstraints() error {
func (i *IncentiveTable) RequestValues() error {
_, err := i.requestData(model.FunctionTypeIncentiveTableData, nil, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand Down
4 changes: 0 additions & 4 deletions features/loadcontrol.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package features

import (
"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -37,7 +36,6 @@ func NewLoadControl(localRole, remoteRole model.RoleType, spineLocalDevice *spin
// request FunctionTypeLoadControlLimitDescriptionListData from a remote device
func (l *LoadControl) RequestLimitDescription() error {
if _, err := l.requestData(model.FunctionTypeLoadControlLimitDescriptionListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -47,7 +45,6 @@ func (l *LoadControl) RequestLimitDescription() error {
// request FunctionTypeLoadControlLimitConstraintsListData from a remote device
func (l *LoadControl) RequestLimitConstraints() error {
if _, err := l.requestData(model.FunctionTypeLoadControlLimitConstraintsListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -58,7 +55,6 @@ func (l *LoadControl) RequestLimitConstraints() error {
func (l *LoadControl) RequestLimits() (*model.MsgCounterType, error) {
msgCounter, err := l.requestData(model.FunctionTypeLoadControlLimitListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
4 changes: 0 additions & 4 deletions features/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package features
import (
"time"

"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -39,7 +38,6 @@ func NewMeasurement(localRole, remoteRole model.RoleType, spineLocalDevice *spin
// request FunctionTypeMeasurementDescriptionListData from a remote device
func (m *Measurement) RequestDescription() error {
if _, err := m.requestData(model.FunctionTypeMeasurementDescriptionListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -49,7 +47,6 @@ func (m *Measurement) RequestDescription() error {
// request FunctionTypeMeasurementConstraintsListData from a remote entity
func (m *Measurement) RequestConstraints() error {
if _, err := m.requestData(model.FunctionTypeMeasurementConstraintsListData, nil, nil); err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -60,7 +57,6 @@ func (m *Measurement) RequestConstraints() error {
func (m *Measurement) Request() (*model.MsgCounterType, error) {
msgCounter, err := m.requestData(model.FunctionTypeMeasurementListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
4 changes: 0 additions & 4 deletions features/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package features
import (
"time"

"github.com/enbility/eebus-go/logging"
"github.com/enbility/eebus-go/spine"
"github.com/enbility/eebus-go/spine/model"
)
Expand Down Expand Up @@ -69,7 +68,6 @@ func NewTimeSeries(localRole, remoteRole model.RoleType, spineLocalDevice *spine
func (t *TimeSeries) RequestDescription() error {
_, err := t.requestData(model.FunctionTypeTimeSeriesDescriptionListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -80,7 +78,6 @@ func (t *TimeSeries) RequestDescription() error {
func (t *TimeSeries) RequestConstraints() error {
_, err := t.requestData(model.FunctionTypeTimeSeriesConstraintsListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand All @@ -91,7 +88,6 @@ func (t *TimeSeries) RequestConstraints() error {
func (t *TimeSeries) Request() (*model.MsgCounterType, error) {
msgCounter, err := t.requestData(model.FunctionTypeTimeSeriesListData, nil, nil)
if err != nil {
logging.Log.Error(err)
return nil, err
}

Expand Down
16 changes: 8 additions & 8 deletions service/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ func (h *connectionsHub) start() {
// start mDNS
err := h.mdns.SetupMdnsService()
if err != nil {
logging.Log.Error("error during mdns setup:", err)
logging.Log.Debug("error during mdns setup:", err)
}

// start the websocket server
go func() {
if err := h.startWebsocketServer(); err != nil {
logging.Log.Error("error during websocket server starting:", err)
logging.Log.Debug("error during websocket server starting:", err)
}
}()

if err := h.mdns.AnnounceMdnsEntry(); err != nil {
logging.Log.Error("error registering mDNS Service:", err)
logging.Log.Debug("error registering mDNS Service:", err)
}
}

Expand Down Expand Up @@ -297,27 +297,27 @@ func (h *connectionsHub) ServeHTTP(w http.ResponseWriter, r *http.Request) {

conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
logging.Log.Error("error during connection upgrading:", err)
logging.Log.Debug("error during connection upgrading:", err)
return
}

// check if the client supports the ship sub protocol
if conn.Subprotocol() != shipWebsocketSubProtocol {
logging.Log.Error("client does not support the ship sub protocol")
logging.Log.Debug("client does not support the ship sub protocol")
conn.Close()
return
}

// check if the clients certificate provides a SKI
if len(r.TLS.PeerCertificates) == 0 {
logging.Log.Error("client does not provide a certificate")
logging.Log.Debug("client does not provide a certificate")
conn.Close()
return
}

ski, err := skiFromCertificate(r.TLS.PeerCertificates[0])
if err != nil {
logging.Log.Error(err)
logging.Log.Debug(err)
conn.Close()
return
}
Expand Down Expand Up @@ -374,7 +374,6 @@ func (h *connectionsHub) connectFoundService(remoteService *ServiceDetails, host
address := fmt.Sprintf("wss://%s:%s", host, port)
conn, _, err := dialer.Dial(address, nil)
if err != nil {
logging.Log.Error(err)
return err
}

Expand Down Expand Up @@ -520,6 +519,7 @@ func (h *connectionsHub) UnpairRemoteService(ski string) error {
func (h *connectionsHub) ReportMdnsEntries(entries map[string]MdnsEntry) {
h.muxMdns.Lock()
defer h.muxMdns.Unlock()

for ski, entry := range entries {
// check if this ski is already connected
if h.isSkiConnected(ski) {
Expand Down
9 changes: 6 additions & 3 deletions service/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ func (m *mdns) RegisterMdnsSearch(cb MdnsSearch) {
}

// may this is already found
go m.searchDelegate.ReportMdnsEntries(m.entries)
mdnsEntries := m.entries

go m.searchDelegate.ReportMdnsEntries(mdnsEntries)
}

// Remove a callback for found mDNS entries and stop searching if no callbacks are left
Expand Down Expand Up @@ -381,7 +383,7 @@ func (m *mdns) stopResolvingEntries() {
func (m *mdns) processAvahiService(service avahi.Service, remove bool) {
_, ifaceIndexes, err := m.interfaces()
if err != nil {
logging.Log.Error("error getting interfaces:", err)
logging.Log.Debug("error getting interfaces:", err)
return
}

Expand Down Expand Up @@ -527,6 +529,7 @@ func (m *mdns) processMdnsEntry(elements map[string]string, name, host string, a
}

if m.searchDelegate != nil {
go m.searchDelegate.ReportMdnsEntries(m.entries)
mdnsEntries := m.entries
go m.searchDelegate.ReportMdnsEntries(mdnsEntries)
}
}
2 changes: 0 additions & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ func (s *EEBUSService) Setup() error {

leaf, err := x509.ParseCertificate(sd.certificate.Certificate[0])
if err != nil {
logging.Log.Error(err)
return err
}

ski, err := skiFromCertificate(leaf)
if err != nil {
logging.Log.Error(err)
return err
}

Expand Down
6 changes: 3 additions & 3 deletions ship/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var _ spine.SpineDataConnection = (*ShipConnection)(nil)
// SpineDataConnection interface implementation
func (c *ShipConnection) WriteSpineMessage(message []byte) {
if err := c.sendSpineData(message); err != nil {
logging.Log.Error(c.RemoteSKI, "Error sending spine message: ", err)
logging.Log.Debug(c.RemoteSKI, "Error sending spine message: ", err)
return
}
}
Expand All @@ -140,13 +140,13 @@ func (c *ShipConnection) shipModelFromMessage(message []byte) (*model.ShipData,
// Get the datagram from the message
data := model.ShipData{}
if err := json.Unmarshal(jsonData, &data); err != nil {
logging.Log.Error(c.RemoteSKI, "error unmarshalling message: ", err)
logging.Log.Debug(c.RemoteSKI, "error unmarshalling message: ", err)
return nil, err
}

if data.Data.Payload == nil {
errorMsg := "received no valid payload"
logging.Log.Error(c.RemoteSKI, errorMsg)
logging.Log.Debug(c.RemoteSKI, errorMsg)
return nil, errors.New(errorMsg)
}

Expand Down
Loading

0 comments on commit 66b6818

Please sign in to comment.