mirror of
https://github.com/Telecominfraproject/ols-ucentral-schema.git
synced 2025-10-29 17:22:23 +00:00
gps: add support to the data model
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
11
renderer/templates/services/gps.uc
Normal file
11
renderer/templates/services/gps.uc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{%-
|
||||||
|
let enable = length(gps);
|
||||||
|
services.set_enabled("umdns", enable);
|
||||||
|
if (!enable)
|
||||||
|
return;
|
||||||
|
%}
|
||||||
|
|
||||||
|
# Configure GPS
|
||||||
|
set gps.@gps[-1].disabled=0
|
||||||
|
set gps.@gps[-1].adjust_time={{ b(gps.adjust_time) }}
|
||||||
|
set gps.@gps[-1].baudrate={{ s(gps.baud_rate) }}
|
||||||
18
schema/service.gps.yml
Normal file
18
schema/service.gps.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
description:
|
||||||
|
This section can be used to configure a GPS dongle
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
adjust-time:
|
||||||
|
description:
|
||||||
|
Adjust the systems clock upon a successful GPS lock.
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
baud-rate:
|
||||||
|
description:
|
||||||
|
The baudrate used by the attached GPS dongle
|
||||||
|
type: integer
|
||||||
|
enum:
|
||||||
|
- 2400
|
||||||
|
- 4800
|
||||||
|
- 9600
|
||||||
|
- 19200
|
||||||
@@ -39,3 +39,5 @@ properties:
|
|||||||
$ref: 'https://ucentral.io/schema/v1/service/wireguard-overlay/'
|
$ref: 'https://ucentral.io/schema/v1/service/wireguard-overlay/'
|
||||||
captive:
|
captive:
|
||||||
$ref: 'https://ucentral.io/schema/v1/service/captive/'
|
$ref: 'https://ucentral.io/schema/v1/service/captive/'
|
||||||
|
gps:
|
||||||
|
$ref: 'https://ucentral.io/schema/v1/service/gps/'
|
||||||
|
|||||||
@@ -8106,6 +8106,47 @@ function instantiateServiceCaptive(location, value, errors) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instantiateServiceGps(location, value, errors) {
|
||||||
|
if (type(value) == "object") {
|
||||||
|
let obj = {};
|
||||||
|
|
||||||
|
function parseAdjustTime(location, value, errors) {
|
||||||
|
if (type(value) != "bool")
|
||||||
|
push(errors, [ location, "must be of type boolean" ]);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists(value, "adjust-time")) {
|
||||||
|
obj.adjust_time = parseAdjustTime(location + "/adjust-time", value["adjust-time"], errors);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj.adjust_time = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseBaudRate(location, value, errors) {
|
||||||
|
if (type(value) != "int")
|
||||||
|
push(errors, [ location, "must be of type integer" ]);
|
||||||
|
|
||||||
|
if (!(value in [ 2400, 4800, 9600, 19200 ]))
|
||||||
|
push(errors, [ location, "must be one of 2400, 4800, 9600 or 19200" ]);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists(value, "baud-rate")) {
|
||||||
|
obj.baud_rate = parseBaudRate(location + "/baud-rate", value["baud-rate"], errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type(value) != "object")
|
||||||
|
push(errors, [ location, "must be of type object" ]);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
function instantiateService(location, value, errors) {
|
function instantiateService(location, value, errors) {
|
||||||
if (type(value) == "object") {
|
if (type(value) == "object") {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
@@ -8182,6 +8223,10 @@ function instantiateService(location, value, errors) {
|
|||||||
obj.captive = instantiateServiceCaptive(location + "/captive", value["captive"], errors);
|
obj.captive = instantiateServiceCaptive(location + "/captive", value["captive"], errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exists(value, "gps")) {
|
||||||
|
obj.gps = instantiateServiceGps(location + "/gps", value["gps"], errors);
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2892,6 +2892,24 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"service.gps": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"adjust-time": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"baud-rate": {
|
||||||
|
"type": "integer",
|
||||||
|
"enum": [
|
||||||
|
2400,
|
||||||
|
4800,
|
||||||
|
9600,
|
||||||
|
19200
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"service": {
|
"service": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2948,6 +2966,9 @@
|
|||||||
},
|
},
|
||||||
"captive": {
|
"captive": {
|
||||||
"$ref": "#/$defs/service.captive"
|
"$ref": "#/$defs/service.captive"
|
||||||
|
},
|
||||||
|
"gps": {
|
||||||
|
"$ref": "#/$defs/service.gps"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user