config

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//GENERIC
	PROJECT_PATH    = "/opt/alkalarm/"
	PYGPIO          = "_433.py"
	SERVER_API_PORT = ":8080"

	//CONTROL
	STATE_FULL = "full"
	STATE_PART = "partial"
	STATE_INAC = "inactive"
	STATE_SOS  = "sos"
)
View Source
const (
	//// INSERTS ////
	SENSOR_INSERT       = "INSERT INTO sensors(code,typeOf,zone) values(?,?,?)"
	MAIL_INSERT         = "INSERT INTO mailer(receptor) values (?)"
	ALARM_INSERT        = "INSERT INTO alarms(date,sensor) values(?,?)"
	CONTROL_INSERT      = "INSERT INTO control(code,description,typeOf) values(?,?,?)"
	GLOBAL_STATE_INSERT = "INSERT INTO global_state(id,gstate) values(1,?)"
	ADMIN_INSERT        = "INSERT INTO admin(pass) values(?)"

	//// DELETES ////
	SENSOR_DELETE  = "DELETE FROM sensors WHERE code=?"
	MAIL_DELETE    = "DELETE FROM mailer WHERE receptor=?"
	ALARM_DELETE   = "DELETE FROM alarms" //just to clear alarm historic
	CONTROL_DELETE = "DELETE FROM control WHERE code=?"

	//// UPDATES ////
	GLOBAL_STATE_UPDATE = "UPDATE global_state SET gstate=? WHERE id=1"

	//// QUERIES ////
	SENSOR_QUERY_ALL    = "SELECT * FROM sensors"
	SENSOR_QUERY_CODE   = "SELECT * FROM sensors WHERE code=?"
	MAIL_QUERY_ALL      = "SELECT * FROM mailer"
	MAIL_QUERY_RECEPTOR = "SELECT * FROM mailer WHERE receptor=?"
	CONTROL_QUERY_ALL   = "SELECT * FROM control"
	CONTROL_QUERY_CODE  = "SELECT * FROM control WHERE code=?"
	ALARM_QUERY_ALL     = "SELECT * FROM alarms"
	GLOBAL_STATE_QUERY  = "SELECT * FROM global_state WHERE id=1"
)
View Source
const (
	//// TABLES ////
	SENSORS_TABLE = "CREATE TABLE IF NOT EXISTS sensors (" +
		"code TEXT PRIMARY KEY," +
		"typeOf TEXT CHECK( typeOf IN ('presence','aperture','other') )," +
		"zone TEXT);"
	ALARM_HISTORY_TABLE = "CREATE TABLE IF NOT EXISTS alarms (" +
		"date TEXT PRIMARY KEY," +
		"sensor TEXT);"
	MAIL_TABLE = "CREATE TABLE IF NOT EXISTS mailer (" +
		"receptor TEXT PRIMARY KEY)"
	CONTROL_CODES_TABLE = "CREATE TABLE IF NOT EXISTS control (" +
		"code TEXT PRIMARY KEY," +
		"description TEXT," +
		"typeOf TEXT CHECK( typeOf IN ('" + STATE_INAC + "','" + STATE_FULL + "','" + STATE_PART + "','" + STATE_SOS + "') ) NOT NULL DEFAULT '');"
	GLOBAL_STATE_TABLE = "CREATE TABLE IF NOT EXISTS global_state (" +
		"id TEXT PRIMARY KEY," +
		"gstate TEXT CHECK( gstate IN ('" + STATE_FULL + "','" + STATE_PART + "','" + STATE_INAC + "') ) NOT NULL DEFAULT '');"
	ADMIN_TABLE = "CREATE TABLE IF NOT EXISTS admin (" +
		"pass TEXT PRIMARY KEY;"
)

Variables

View Source
var (
	DB_NAME = PROJECT_PATH + "data.db"
	DB_TYPE = "sqlite3"

	FROM        = readFromFile(".userSMTP")
	SMTP_SERVER = "smtp.gmail.com"
	SMTP_PORT   = "587"
	SMTP_PASS   = readFromFile(".passSMTP")
	LIST_ACCESS = readFromFile(".listACCESS")
	Cred        = GetOauthCred()
	GConfAuth   = &oauth2.Config{
		ClientID:     Cred.Cid,
		ClientSecret: Cred.Csecret,
		RedirectURL:  "http://alknopfler.ddns.net/callback",
		Scopes: []string{
			"https://www.googleapis.com/auth/userinfo.profile",
			"https://www.googleapis.com/auth/userinfo.email",
		},
		Endpoint: google.Endpoint,
	}
)

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	Date   string `json:"Date"`
	Sensor string `json:"Sensor"`
}

type ArrayControl

type ArrayControl struct {
	Data []Control `json:"Data"`
}

type ArraySensor

type ArraySensor struct {
	Data []Sensor `json:"Data"`
}

type Control

type Control struct {
	Code        string `json:"Code"`
	Description string `json:"Description"`
	TypeOf      string `json:"TypeOf"`
}

Control struct to define the object

type Credentials

type Credentials struct {
	Cid     string `json:"cid"`
	Csecret string `json:"csecret"`
}

func GetOauthCred

func GetOauthCred() Credentials

type GlobalState

type GlobalState struct {
	Id     string `json:"Id"`
	GState string `json:"State"`
}

type GoogleUser

type GoogleUser struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Link          string `json:"link"`
	Picture       string `json:"picture"`
	Gender        string `json:"gender"`
	Locale        string `json:"locale"`
}

type Mailer

type Mailer struct {
	Receptor string `json:"Receptor"`
}

Mailer struct to define the object

type Sensor

type Sensor struct {
	Code   string `json:"Code"`
	TypeOf string `json:"TypeOf"`
	Zone   string `json:"Zone"`
}

Sensor struct to define the object

Jump to

Keyboard shortcuts

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