-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.js
More file actions
75 lines (61 loc) · 2.84 KB
/
Copy pathConfiguration.js
File metadata and controls
75 lines (61 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function getConfiguration(config)
{
// This function allows you to indicate general configuration values
// for all devices of this model.
// Depending on the meaning of the "device address" in this device,
// you may want to change the label that is used to refer to the
// address in the user interface.
// For instance, if the address of the device is actually a MAC
// address, you may want to use the code below.
// config.addressLabel = {en: "MAC address", es: "Dirección MAC"};
}
function getEndpoints(deviceAddress, endpoints)
{
// This function allows you to indicate the initial endpoint configuration
// when a device is created using this model. This improves end-user
// experience significantly, because it allows the platform to create
// all endpoints included in the device automatically when the device
// is created.
// In the code below, two endpoints are created. The first is a
// temperature sensor, while the second one is a carbon dioxide sensor.
// endpoints.addEndpoint("1", "Temperature sensor", endpointType.temperatureSensor);
// endpoints.addEndpoint("2", "CO2 sensor", endpointType.ppmConcentrationSensor, ppmConcentrationSensorSubType.carbonDioxide);
}
function validateDeviceAddress(address, result)
{
// This function allows you to validate the address of a device, when
// the user is creating it. If your device has special validation rules
// for the address, you can check them here, and return an error message
// in case the address format is incorrect.
// In the code below, a validation is made to ensure that the address
// is exactly 10 characters long.
// if (address.length != 10) {
// result.ok = false;
// result.errorMessage = {
// en: "The address must be 10 characters long",
// es: "La dirección debe tener exactamente 10 caracteres"
// };
// }
}
function updateDeviceUIRules(device, rules)
{
// This function allows you to specify UI rules at the device level.
// For instance, you can make it possible to enable or disable adding
// endpoints manually to the device after it was created.
// In the code below, adding endpoints manually is disabled in the
// user interface. This means that the device will be limited to the
// endpoints defined by function getEndpoints() above.
rules.canCreateEndpoints = true;
}
function updateEndpointUIRules(endpoint, rules)
{
// This function allows you to specify UI rules at the endpoint level.
// For instance, you can make it possible to delete certain endpoints,
// or edit their endpoint subtype, if applicable.
// In the code below, the following rules are defined:
// - Endpoints cannot be deleted.
// - The endpoint subtype can be changed, but only for the second
// endpoint.
// rules.canDelete = false;
// rules.canEditSubType = (endpoint.address == "2");
}