internal

package
v0.0.0-...-7c0d231 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 Don P. McGarry

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var ISOTimeLayout string = "2006-01-02T15:04:05.000Z"

Functions

func CubicMetersPerSecondToGallonsPerHour

func CubicMetersPerSecondToGallonsPerHour(cumps float64) float64

func CubicMetersPerSecondToGallonsPerMinute

func CubicMetersPerSecondToGallonsPerMinute(cumps float64) float64

func CubicMetersPerSecondToGallonsPerSecond

func CubicMetersPerSecondToGallonsPerSecond(cumps float64) float64

func HandleSubscriptions

func HandleSubscriptions(subscribeconf SubscriptionConfig)

func KelvinToFarenheit

func KelvinToFarenheit(tempk float64) float64

func MetersPerSecondToKnots

func MetersPerSecondToKnots(mps float64) float64

func MetersToFeet

func MetersToFeet(m float64) float64

func MillibarToInHg

func MillibarToInHg(mb float64) float64

func OnBLETemperatureMessage

func OnBLETemperatureMessage(client MQTT.Client, message MQTT.Message)

func OnESPStatusMessage

func OnESPStatusMessage(client MQTT.Client, message MQTT.Message)

func OnGNSSMessage

func OnGNSSMessage(client MQTT.Client, message MQTT.Message)

func OnNavigationMessage

func OnNavigationMessage(client MQTT.Client, message MQTT.Message)

func OnOutsideMessage

func OnOutsideMessage(client MQTT.Client, message MQTT.Message)

func OnPHYTemperatureMessage

func OnPHYTemperatureMessage(client MQTT.Client, message MQTT.Message)

func OnPropulsionMessage

func OnPropulsionMessage(client MQTT.Client, message MQTT.Message)

func OnSteeringMessage

func OnSteeringMessage(client MQTT.Client, message MQTT.Message)

func OnWaterMessage

func OnWaterMessage(client MQTT.Client, message MQTT.Message)

func OnWindMessage

func OnWindMessage(client MQTT.Client, message MQTT.Message)

func PascalToPSI

func PascalToPSI(pascal float64) float64

func PublishClientMessage

func PublishClientMessage(client MQTT.Client, topic string, messagedata string)

func PublishMessage

func PublishMessage(publishConf PublishConfig, serverConf MQTTDestination)

It isn't super efficient to be creating / tearing down connection each time But that said the complexity of reusing connections isn't worth it at this point

func RadiansToDegrees

func RadiansToDegrees(rad float64) float64

Types

type BLETemperature

type BLETemperature struct {
	MAC            string    `json:"MAC,omitempty"`
	Location       string    `json:"Location,omitempty"`
	TempF          float64   `json:"TempF,omitempty"`
	BatteryPercent float64   `json:"BatteryPct,omitempty"`
	Humidity       float64   `json:"Humidity,omitempty"`
	RSSI           int64     `json:"RSSI,omitempty"`
	Timestamp      time.Time `json:"Timestamp,omitempty"`
}

func (BLETemperature) GetInfluxFields

func (meas BLETemperature) GetInfluxFields() map[string]interface{}

func (BLETemperature) GetInfluxTags

func (meas BLETemperature) GetInfluxTags() map[string]string

func (BLETemperature) LogJSON

func (meas BLETemperature) LogJSON()

func (BLETemperature) ToInfluxPoint

func (meas BLETemperature) ToInfluxPoint() *write.Point

func (BLETemperature) ToJSON

func (meas BLETemperature) ToJSON() string

type ESPStatus

type ESPStatus struct {
	MAC                string    `json:"MAC,omitempty"`
	Location           string    `json:"Location,omitempty"`
	IPAddress          string    `json:"IPAddress,omitempty"`
	MSHVersion         string    `json:"MSHVersion,omitempty"`
	FreeSRAM           int64     `json:"FreeSRAM,omitempty"`
	FreeHeap           int64     `json:"FreeHeap,omitempty"`
	FreePSRAM          int64     `json:"FreePSRAM,omitempty"`
	WiFiReconnectCount int64     `json:"WiFiReconnectCount,omitempty"`
	MQTTReconnectCount int64     `json:"MQTTReconnectCount,omitempty"`
	BLEEnabled         bool      `json:"BLEEnabled,omitempty"`
	RTDEnabled         bool      `json:"RTDEnabled,omitempty"`
	WiFiRSSI           int64     `json:"WiFiRSSI,omitempty"`
	HasTime            bool      `json:"HasTime,omitempty"`
	HasResetMQTT       bool      `json:"HasResetMQTT,omitempty"`
	Timestamp          time.Time `json:"Timestamp,omitempty"`
}

func (ESPStatus) GetInfluxFields

func (meas ESPStatus) GetInfluxFields() map[string]interface{}

func (ESPStatus) GetInfluxTags

func (meas ESPStatus) GetInfluxTags() map[string]string

func (ESPStatus) LogJSON

func (meas ESPStatus) LogJSON()

func (ESPStatus) ToInfluxPoint

func (meas ESPStatus) ToInfluxPoint() *write.Point

func (ESPStatus) ToJSON

func (meas ESPStatus) ToJSON() string

type GNSS

type GNSS struct {
	Source        string    `json:"Source,omitempty"`
	AntennaAlt    float64   `json:"AntennaAlt,omitempty"`
	Satellites    int64     `json:"Satellites,omitempty"`
	HozDilution   float64   `json:"HozDilution,omitempty"`
	PosDilution   float64   `json:"PosDilution,omitempty"`
	GeoidalSep    float64   `json:"GeoidalSep,omitempty"`
	Type          string    `json:"Type,omitempty"`
	MethodQuality string    `json:"MethodQuality,omitempty"`
	Timestamp     time.Time `json:"Timestamp,omitempty"`
}

func (GNSS) GetInfluxFields

func (meas GNSS) GetInfluxFields() map[string]interface{}

func (GNSS) GetInfluxTags

func (meas GNSS) GetInfluxTags() map[string]string

func (GNSS) IsEmpty

func (meas GNSS) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (GNSS) LogJSON

func (meas GNSS) LogJSON()

func (GNSS) ToInfluxPoint

func (meas GNSS) ToInfluxPoint() *write.Point

func (GNSS) ToJSON

func (meas GNSS) ToJSON() string

type MQTTDestination

type MQTTDestination struct {
	Host     string
	Topics   []string
	Username string
	Password string
	CACert   []byte
}

func LoadPublishServerConfig

func LoadPublishServerConfig() ([]MQTTDestination, error)
type Navigation struct {
	Source       string    `json:"Source,omitempty"`
	Lat          float64   `json:"Latitude,omitempty"`
	Lon          float64   `json:"Longitude,omitempty"`
	Alt          float64   `json:"Altitude,omitempty"`
	SOG          float64   `json:"SpeedOverGround,omitempty"`
	ROT          float64   `json:"RateOfTurn,omitempty"`
	COGTrue      float64   `json:"CourseOverGroundTrue,omitempty"`
	HeadingMag   float64   `json:"HeadingMagnetic,omitempty"`
	MagVariation float64   `json:"MagneticVariation,omitempty"`
	MagDeviation float64   `json:"MagneticDeviation,omitempty"`
	Yaw          float64   `json:"Yaw,omitempty"`
	Pitch        float64   `json:"Pitch,omitempty"`
	Roll         float64   `json:"Roll,omitempty"`
	HeadingTrue  float64   `json:"HeadingTrue,omitempty"`
	STW          float64   `json:"SpeedThroughWater,omitempty"`
	Timestamp    time.Time `json:"Timestamp,omitempty"`
}
func (meas Navigation) GetInfluxFields() map[string]interface{}
func (meas Navigation) GetInfluxTags() map[string]string
func (meas Navigation) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (meas Navigation) LogJSON()
func (meas Navigation) ToInfluxPoint() *write.Point
func (meas Navigation) ToJSON() string

type Outside

type Outside struct {
	Source       string    `json:"Source,omitempty"`
	TempF        float64   `json:"TempF,omitempty"`
	Pressure     float64   `json:"Pressure,omitempty"`
	PressureInHg float64   `json:"PressureInHg,omitempty"`
	Timestamp    time.Time `json:"Timestamp,omitempty"`
}

func (Outside) GetInfluxFields

func (meas Outside) GetInfluxFields() map[string]interface{}

func (Outside) GetInfluxTags

func (meas Outside) GetInfluxTags() map[string]string

func (Outside) IsEmpty

func (meas Outside) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (Outside) LogJSON

func (meas Outside) LogJSON()

func (Outside) ToInfluxPoint

func (meas Outside) ToInfluxPoint() *write.Point

func (Outside) ToJSON

func (meas Outside) ToJSON() string

type PHYTemperature

type PHYTemperature struct {
	MAC       string    `json:"MAC,omitempty"`
	Location  string    `json:"Location,omitempty"`
	Device    string    `json:"Device,omitempty"`
	Component string    `json:"Component,omitempty"`
	TempF     float64   `json:"TempF,omitempty"`
	Timestamp time.Time `json:"Timestamp,omitempty"`
}

func (PHYTemperature) GetInfluxFields

func (meas PHYTemperature) GetInfluxFields() map[string]interface{}

func (PHYTemperature) GetInfluxTags

func (meas PHYTemperature) GetInfluxTags() map[string]string

func (PHYTemperature) LogJSON

func (meas PHYTemperature) LogJSON()

func (PHYTemperature) ToInfluxPoint

func (meas PHYTemperature) ToInfluxPoint() *write.Point

func (PHYTemperature) ToJSON

func (meas PHYTemperature) ToJSON() string

type Propulsion

type Propulsion struct {
	Device           string    `json:"Device,omitempty"`
	Source           string    `json:"Source,omitempty"`
	RPM              int64     `json:"RPM,omitempty"`
	BoostPSI         float64   `json:"BoostPSI,omitempty"`
	OilTempF         float64   `json:"OilTempF,omitempty"`
	OilPressure      float64   `json:"OilPressure,omitempty"`
	CoolantTempF     float64   `json:"CoolantTempF,omitempty"`
	RunTime          int64     `json:"RunTime,omitempty"`
	EngineLoad       float64   `json:"EngineLoad,omitempty"`
	EngineTorque     float64   `json:"EngineTorque,omitempty"`
	TransOilTempF    float64   `json:"TransOilTemp,omitempty"`
	TransOilPressure float64   `json:"TransOilPressure,omitempty"`
	AltVoltage       float64   `json:"AlternatorVoltage,omitempty"`
	FuelRate         float64   `json:"FuelRate,omitempty"`
	Timestamp        time.Time `json:"Timestamp,omitempty"`
}

func (Propulsion) GetInfluxFields

func (meas Propulsion) GetInfluxFields() map[string]interface{}

func (Propulsion) GetInfluxTags

func (meas Propulsion) GetInfluxTags() map[string]string

func (Propulsion) IsEmpty

func (meas Propulsion) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (Propulsion) LogJSON

func (meas Propulsion) LogJSON()

func (Propulsion) ToInfluxPoint

func (meas Propulsion) ToInfluxPoint() *write.Point

func (Propulsion) ToJSON

func (meas Propulsion) ToJSON() string

type PublishConfig

type PublishConfig struct {
	Interval          int
	PublishTimeout    int
	DisconnectTimeout int
}

func LoadPublishConfig

func LoadPublishConfig() (PublishConfig, error)

type Steering

type Steering struct {
	Source           string    `json:"Source,omitempty"`
	RudderAngle      float64   `json:"RudderAngle,omitempty"`
	AutopilotState   string    `json:"AutoPilotState,omitempty"`
	TargetHeadingMag float64   `json:"TargetHeading,omitempty"`
	Timestamp        time.Time `json:"Timestamp,omitempty"`
}

func (Steering) GetInfluxFields

func (meas Steering) GetInfluxFields() map[string]interface{}

func (Steering) GetInfluxTags

func (meas Steering) GetInfluxTags() map[string]string

func (Steering) IsEmpty

func (meas Steering) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (Steering) LogJSON

func (meas Steering) LogJSON()

func (Steering) ToInfluxPoint

func (meas Steering) ToInfluxPoint() *write.Point

func (Steering) ToJSON

func (meas Steering) ToJSON() string

type SubscriptionConfig

type SubscriptionConfig struct {
	Host             string
	Username         string
	Password         string
	CACert           []byte
	BLETopics        []string
	PHYTopics        []string
	ESPTopics        []string
	NavTopics        []string
	GNSSTopics       []string
	SteeringTopics   []string
	WindTopics       []string
	WaterTopics      []string
	OutsideTopics    []string
	PropulsionTopics []string
	Repost           bool
	RepostRootTopic  string
	PublishTimeout   uint
	MACtoLocation    map[string]string
	N2KtoName        map[string]string
	InfluxEnabled    bool
	InfluxOrg        string
	InfluxBucket     string
	InfluxToken      string
	InfluxUrl        string
	BLESubEn         bool
	GNSSSubEn        bool
	ESPSubEn         bool
	NavSubEn         bool
	OutsideSubEn     bool
	PHYSubEn         bool
	PropSubEn        bool
	SteerSubEn       bool
	WaterSubEn       bool
	WindSubEn        bool
	BLELogEn         bool
	GNSSLogEn        bool
	ESPLogEn         bool
	NavLogEn         bool
	OutsideLogEn     bool
	PHYLogEn         bool
	PropLogEn        bool
	SteerLogEn       bool
	WaterLogEn       bool
	WindLogEn        bool
}
var SharedSubscriptionConfig *SubscriptionConfig

func LoadSubscribeServerConfig

func LoadSubscribeServerConfig() (SubscriptionConfig, error)

type Water

type Water struct {
	Source                 string    `json:"Source,omitempty"`
	TempF                  float64   `json:"TempF,omitempty"`
	DepthUnderTransducerFt float64   `json:"DepthUnderTransducerFt,omitempty"`
	Timestamp              time.Time `json:"Timestamp,omitempty"`
}

func (Water) GetInfluxFields

func (meas Water) GetInfluxFields() map[string]interface{}

func (Water) GetInfluxTags

func (meas Water) GetInfluxTags() map[string]string

func (Water) IsEmpty

func (meas Water) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (Water) LogJSON

func (meas Water) LogJSON()

func (Water) ToInfluxPoint

func (meas Water) ToInfluxPoint() *write.Point

func (Water) ToJSON

func (meas Water) ToJSON() string

type Wind

type Wind struct {
	Source        string    `json:"Source,omitempty"`
	SpeedApp      float64   `json:"SpeedApp,omitempty"`
	AngleApp      float64   `json:"AngleApp,omitempty"`
	SOG           float64   `json:"SOG,omitempty"`
	DirectionTrue float64   `json:"DirectionTrue,omitempty"`
	Timestamp     time.Time `json:"Timestamp,omitempty"`
}

func (Wind) GetInfluxFields

func (meas Wind) GetInfluxFields() map[string]interface{}

func (Wind) GetInfluxTags

func (meas Wind) GetInfluxTags() map[string]string

func (Wind) IsEmpty

func (meas Wind) IsEmpty() bool

Since we are dropping fields we can end up with messages that are just a Source and a Timestamp This allows us to drop those messages

func (Wind) LogJSON

func (meas Wind) LogJSON()

func (Wind) ToInfluxPoint

func (meas Wind) ToInfluxPoint() *write.Point

func (Wind) ToJSON

func (meas Wind) ToJSON() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL