added new message type handling for efento
This commit is contained in:
parent
6b8cbbd3c9
commit
7d1bfa3164
@ -21,7 +21,6 @@ import lombok.Data;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.californium.core.coap.CoAP;
|
import org.eclipse.californium.core.coap.CoAP;
|
||||||
import org.eclipse.californium.core.coap.Request;
|
import org.eclipse.californium.core.coap.Request;
|
||||||
import org.eclipse.californium.core.coap.Response;
|
|
||||||
import org.eclipse.californium.core.network.Exchange;
|
import org.eclipse.californium.core.network.Exchange;
|
||||||
import org.eclipse.californium.core.server.resources.CoapExchange;
|
import org.eclipse.californium.core.server.resources.CoapExchange;
|
||||||
import org.eclipse.californium.core.server.resources.Resource;
|
import org.eclipse.californium.core.server.resources.Resource;
|
||||||
@ -34,6 +33,8 @@ import org.thingsboard.server.common.data.device.profile.EfentoCoapDeviceTypeCon
|
|||||||
import org.thingsboard.server.common.transport.adaptor.AdaptorException;
|
import org.thingsboard.server.common.transport.adaptor.AdaptorException;
|
||||||
import org.thingsboard.server.common.transport.auth.SessionInfoCreator;
|
import org.thingsboard.server.common.transport.auth.SessionInfoCreator;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
|
import org.thingsboard.server.gen.transport.coap.ConfigProtos;
|
||||||
|
import org.thingsboard.server.gen.transport.coap.DeviceInfoProtos;
|
||||||
import org.thingsboard.server.gen.transport.coap.MeasurementTypeProtos;
|
import org.thingsboard.server.gen.transport.coap.MeasurementTypeProtos;
|
||||||
import org.thingsboard.server.gen.transport.coap.MeasurementsProtos;
|
import org.thingsboard.server.gen.transport.coap.MeasurementsProtos;
|
||||||
import org.thingsboard.server.transport.coap.AbstractCoapTransportResource;
|
import org.thingsboard.server.transport.coap.AbstractCoapTransportResource;
|
||||||
@ -43,12 +44,16 @@ import org.thingsboard.server.transport.coap.callback.CoapEfentoCallback;
|
|||||||
import org.thingsboard.server.transport.coap.efento.utils.CoapEfentoUtils;
|
import org.thingsboard.server.transport.coap.efento.utils.CoapEfentoUtils;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.thingsboard.server.transport.coap.CoapTransportService.CONFIGURATION;
|
import static org.thingsboard.server.transport.coap.CoapTransportService.CONFIGURATION;
|
||||||
import static org.thingsboard.server.transport.coap.CoapTransportService.CURRENT_TIMESTAMP;
|
import static org.thingsboard.server.transport.coap.CoapTransportService.CURRENT_TIMESTAMP;
|
||||||
@ -94,14 +99,13 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
String requestType = uriPath.get(1);
|
String requestType = uriPath.get(1);
|
||||||
switch (requestType) {
|
switch (requestType) {
|
||||||
case MEASUREMENTS:
|
case MEASUREMENTS:
|
||||||
processMeasurementsRequest(exchange, request);
|
processMeasurementsRequest(exchange);
|
||||||
break;
|
break;
|
||||||
case DEVICE_INFO:
|
case DEVICE_INFO:
|
||||||
|
processDeviceInfoRequest(exchange);
|
||||||
|
break;
|
||||||
case CONFIGURATION:
|
case CONFIGURATION:
|
||||||
//We respond only to confirmed requests in order to reduce battery consumption for Efento devices.
|
processConfigurationRequest(exchange);
|
||||||
if (exchange.advanced().getRequest().isConfirmable()) {
|
|
||||||
exchange.respond(new Response(CoAP.ResponseCode.CREATED));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
|
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
|
||||||
@ -109,8 +113,8 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMeasurementsRequest(CoapExchange exchange, Request request) {
|
private void processMeasurementsRequest(CoapExchange exchange) {
|
||||||
byte[] bytes = request.getPayload();
|
byte[] bytes = exchange.advanced().getRequest().getPayload();
|
||||||
try {
|
try {
|
||||||
MeasurementsProtos.ProtoMeasurements protoMeasurements = MeasurementsProtos.ProtoMeasurements.parseFrom(bytes);
|
MeasurementsProtos.ProtoMeasurements protoMeasurements = MeasurementsProtos.ProtoMeasurements.parseFrom(bytes);
|
||||||
log.trace("Successfully parsed Efento ProtoMeasurements: [{}]", protoMeasurements.getCloudToken());
|
log.trace("Successfully parsed Efento ProtoMeasurements: [{}]", protoMeasurements.getCloudToken());
|
||||||
@ -121,7 +125,7 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
UUID sessionId = new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB());
|
UUID sessionId = new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB());
|
||||||
try {
|
try {
|
||||||
validateEfentoTransportConfiguration(deviceProfile);
|
validateEfentoTransportConfiguration(deviceProfile);
|
||||||
List<EfentoMeasurements> efentoMeasurements = getEfentoMeasurements(protoMeasurements, sessionId);
|
List<EfentoTelemetry> efentoMeasurements = getEfentoMeasurements(protoMeasurements, sessionId);
|
||||||
transportService.process(sessionInfo,
|
transportService.process(sessionInfo,
|
||||||
transportContext.getEfentoCoapAdaptor().convertToPostTelemetry(sessionId, efentoMeasurements),
|
transportContext.getEfentoCoapAdaptor().convertToPostTelemetry(sessionId, efentoMeasurements),
|
||||||
new CoapEfentoCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
|
new CoapEfentoCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
|
||||||
@ -137,6 +141,63 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processDeviceInfoRequest(CoapExchange exchange) {
|
||||||
|
byte[] bytes = exchange.advanced().getRequest().getPayload();
|
||||||
|
try {
|
||||||
|
DeviceInfoProtos.ProtoDeviceInfo protoDeviceInfo = DeviceInfoProtos.ProtoDeviceInfo.parseFrom(bytes);
|
||||||
|
String token = protoDeviceInfo.getCloudToken();
|
||||||
|
log.trace("Successfully parsed Efento ProtoDeviceInfo: [{}]", token);
|
||||||
|
transportService.process(DeviceTransportType.COAP, TransportProtos.ValidateDeviceTokenRequestMsg.newBuilder().setToken(token).build(),
|
||||||
|
new CoapDeviceAuthCallback(exchange, (msg, deviceProfile) -> {
|
||||||
|
TransportProtos.SessionInfoProto sessionInfo = SessionInfoCreator.create(msg, transportContext, UUID.randomUUID());
|
||||||
|
UUID sessionId = new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB());
|
||||||
|
try {
|
||||||
|
validateEfentoTransportConfiguration(deviceProfile);
|
||||||
|
EfentoTelemetry deviceInfo = getEfentoDeviceInfo(protoDeviceInfo);
|
||||||
|
transportService.process(sessionInfo,
|
||||||
|
transportContext.getEfentoCoapAdaptor().convertToPostTelemetry(sessionId, List.of(deviceInfo)),
|
||||||
|
new CoapEfentoCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
|
||||||
|
reportSubscriptionInfo(sessionInfo, false, false);
|
||||||
|
} catch (AdaptorException e) {
|
||||||
|
log.error("[{}] Failed to decode Efento ProtoDeviceInfo: ", sessionId, e);
|
||||||
|
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to decode Efento ProtoDeviceInfo: ", e);
|
||||||
|
exchange.respond(CoAP.ResponseCode.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processConfigurationRequest(CoapExchange exchange) {
|
||||||
|
byte[] bytes = exchange.advanced().getRequest().getPayload();
|
||||||
|
try {
|
||||||
|
|
||||||
|
ConfigProtos.ProtoConfig protoConfig = ConfigProtos.ProtoConfig.parseFrom(bytes);
|
||||||
|
String token = protoConfig.getCloudToken();
|
||||||
|
log.trace("Successfully parsed Efento ProtoConfig: [{}]", token);
|
||||||
|
transportService.process(DeviceTransportType.COAP, TransportProtos.ValidateDeviceTokenRequestMsg.newBuilder().setToken(token).build(),
|
||||||
|
new CoapDeviceAuthCallback(exchange, (msg, deviceProfile) -> {
|
||||||
|
TransportProtos.SessionInfoProto sessionInfo = SessionInfoCreator.create(msg, transportContext, UUID.randomUUID());
|
||||||
|
UUID sessionId = new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB());
|
||||||
|
try {
|
||||||
|
validateEfentoTransportConfiguration(deviceProfile);
|
||||||
|
JsonObject config = getEfentoConfiguration(protoConfig);
|
||||||
|
transportService.process(sessionInfo,
|
||||||
|
transportContext.getEfentoCoapAdaptor().convertToPostAttribute(sessionId, config),
|
||||||
|
new CoapEfentoCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
|
||||||
|
reportSubscriptionInfo(sessionInfo, false, false);
|
||||||
|
} catch (AdaptorException e) {
|
||||||
|
log.error("[{}] Failed to decode Efento ProtoConfig: ", sessionId, e);
|
||||||
|
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to decode Efento ProtoConfig: ", e);
|
||||||
|
exchange.respond(CoAP.ResponseCode.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resource getChild(String name) {
|
public Resource getChild(String name) {
|
||||||
return this;
|
return this;
|
||||||
@ -155,7 +216,7 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EfentoMeasurements> getEfentoMeasurements(MeasurementsProtos.ProtoMeasurements protoMeasurements, UUID sessionId) {
|
private List<EfentoTelemetry> getEfentoMeasurements(MeasurementsProtos.ProtoMeasurements protoMeasurements, UUID sessionId) {
|
||||||
String serialNumber = CoapEfentoUtils.convertByteArrayToString(protoMeasurements.getSerialNum().toByteArray());
|
String serialNumber = CoapEfentoUtils.convertByteArrayToString(protoMeasurements.getSerialNum().toByteArray());
|
||||||
boolean batteryStatus = protoMeasurements.getBatteryStatus();
|
boolean batteryStatus = protoMeasurements.getBatteryStatus();
|
||||||
int measurementPeriodBase = protoMeasurements.getMeasurementPeriodBase();
|
int measurementPeriodBase = protoMeasurements.getMeasurementPeriodBase();
|
||||||
@ -261,9 +322,9 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
throw new IllegalStateException("[" + sessionId + "]: Failed to get Efento measurements, reason: channels list is empty!");
|
throw new IllegalStateException("[" + sessionId + "]: Failed to get Efento measurements, reason: channels list is empty!");
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(valuesMap)) {
|
if (!CollectionUtils.isEmpty(valuesMap)) {
|
||||||
List<EfentoMeasurements> efentoMeasurements = new ArrayList<>();
|
List<EfentoTelemetry> efentoMeasurements = new ArrayList<>();
|
||||||
for (Long ts : valuesMap.keySet()) {
|
for (Long ts : valuesMap.keySet()) {
|
||||||
EfentoMeasurements measurement = new EfentoMeasurements(ts, valuesMap.get(ts));
|
EfentoTelemetry measurement = new EfentoTelemetry(ts, valuesMap.get(ts));
|
||||||
efentoMeasurements.add(measurement);
|
efentoMeasurements.add(measurement);
|
||||||
}
|
}
|
||||||
return efentoMeasurements;
|
return efentoMeasurements;
|
||||||
@ -272,9 +333,253 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EfentoTelemetry getEfentoDeviceInfo(DeviceInfoProtos.ProtoDeviceInfo protoDeviceInfo) {
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
values.addProperty("sw_version", protoDeviceInfo.getSwVersion());
|
||||||
|
values.addProperty("cloud_token", protoDeviceInfo.getCloudToken());
|
||||||
|
|
||||||
|
//memory statistics
|
||||||
|
values.addProperty("nv_storage_status", getStorageStatus(protoDeviceInfo.getMemoryStatistics(0)));
|
||||||
|
values.addProperty("timestamp_of_the_end_of_collecting_statistics", getDate(protoDeviceInfo.getMemoryStatistics(1)));
|
||||||
|
values.addProperty("capacity_of_memory_in_bytes", protoDeviceInfo.getMemoryStatistics(2));
|
||||||
|
values.addProperty("used_space_in_bytes", protoDeviceInfo.getMemoryStatistics(3));
|
||||||
|
values.addProperty("size_of_invalid_packets_in_bytes", protoDeviceInfo.getMemoryStatistics(4));
|
||||||
|
values.addProperty("size_of_corrupted_packets_in_bytes", protoDeviceInfo.getMemoryStatistics(5));
|
||||||
|
values.addProperty("number_of_valid_packets", protoDeviceInfo.getMemoryStatistics(6));
|
||||||
|
values.addProperty("number_of_invalid_packets", protoDeviceInfo.getMemoryStatistics(7));
|
||||||
|
values.addProperty("number_of_corrupted_packets", protoDeviceInfo.getMemoryStatistics(8));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_1", protoDeviceInfo.getMemoryStatistics(9));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_2", protoDeviceInfo.getMemoryStatistics(10));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_3", protoDeviceInfo.getMemoryStatistics(11));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_4", protoDeviceInfo.getMemoryStatistics(12));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_5", protoDeviceInfo.getMemoryStatistics(13));
|
||||||
|
values.addProperty("number_of_all_samples_for_channel_6", protoDeviceInfo.getMemoryStatistics(14));
|
||||||
|
values.addProperty("timestamp_of_the_first_binary_measurement", getDate(protoDeviceInfo.getMemoryStatistics(15)));
|
||||||
|
values.addProperty("timestamp_of_the_last_binary_measurement", getDate(protoDeviceInfo.getMemoryStatistics(16)));
|
||||||
|
values.addProperty("timestamp_of_the_first_binary_measurement_sent", getDate(protoDeviceInfo.getMemoryStatistics(17)));
|
||||||
|
values.addProperty("timestamp_of_the_first_continuous_measurement", getDate(protoDeviceInfo.getMemoryStatistics(18)));
|
||||||
|
values.addProperty("timestamp_of_the_last_continuous_measurement", getDate(protoDeviceInfo.getMemoryStatistics(19)));
|
||||||
|
values.addProperty("timestamp_of_the_last_continuous_measurement_sent", getDate(protoDeviceInfo.getMemoryStatistics(20)));
|
||||||
|
values.addProperty("nvm_write_counter", protoDeviceInfo.getMemoryStatistics(21));
|
||||||
|
|
||||||
|
//modem info
|
||||||
|
values.addProperty("modem_types", protoDeviceInfo.getModem().getType().toString());
|
||||||
|
values.addProperty("sc_EARNFCN_offset", protoDeviceInfo.getModem().getParameters(0));
|
||||||
|
values.addProperty("sc_EARFCN", protoDeviceInfo.getModem().getParameters(1));
|
||||||
|
values.addProperty("sc_PCI", protoDeviceInfo.getModem().getParameters(2));
|
||||||
|
values.addProperty("sc_Cell_id", protoDeviceInfo.getModem().getParameters(3));
|
||||||
|
values.addProperty("sc_RSRP", protoDeviceInfo.getModem().getParameters(4));
|
||||||
|
values.addProperty("sc_RSRQ", protoDeviceInfo.getModem().getParameters(5));
|
||||||
|
values.addProperty("sc_RSSI", protoDeviceInfo.getModem().getParameters(6));
|
||||||
|
values.addProperty("sc_SINR", protoDeviceInfo.getModem().getParameters(7));
|
||||||
|
values.addProperty("sc_Band", protoDeviceInfo.getModem().getParameters(8));
|
||||||
|
values.addProperty("sc_TAC", protoDeviceInfo.getModem().getParameters(9));
|
||||||
|
values.addProperty("sc_ECL", protoDeviceInfo.getModem().getParameters(10));
|
||||||
|
values.addProperty("sc_TX_PWR", protoDeviceInfo.getModem().getParameters(11));
|
||||||
|
values.addProperty("op_mode", protoDeviceInfo.getModem().getParameters(12));
|
||||||
|
values.addProperty("nc_EARFCN", protoDeviceInfo.getModem().getParameters(13));
|
||||||
|
values.addProperty("nc_EARNFCN_offset", protoDeviceInfo.getModem().getParameters(14));
|
||||||
|
values.addProperty("nc_PCI", protoDeviceInfo.getModem().getParameters(15));
|
||||||
|
values.addProperty("nc_RSRP", protoDeviceInfo.getModem().getParameters(16));
|
||||||
|
values.addProperty("RLC_UL_BLER", protoDeviceInfo.getModem().getParameters(17));
|
||||||
|
values.addProperty("RLC_DL_BLER", protoDeviceInfo.getModem().getParameters(18));
|
||||||
|
values.addProperty("MAC_UL_BLER", protoDeviceInfo.getModem().getParameters(19));
|
||||||
|
values.addProperty("MAC_DL_BLER", protoDeviceInfo.getModem().getParameters(20));
|
||||||
|
values.addProperty("MAC_UL_TOTAL_BYTES", protoDeviceInfo.getModem().getParameters(21));
|
||||||
|
values.addProperty("MAC_DL_TOTAL_BYTES", protoDeviceInfo.getModem().getParameters(22));
|
||||||
|
values.addProperty("MAC_UL_total_HARQ_Tx", protoDeviceInfo.getModem().getParameters(23));
|
||||||
|
values.addProperty("MAC_DL_total_HARQ_Tx", protoDeviceInfo.getModem().getParameters(24));
|
||||||
|
values.addProperty("MAC_UL_HARQ_re_Tx", protoDeviceInfo.getModem().getParameters(25));
|
||||||
|
values.addProperty("MAC_DL_HARQ_re_Tx", protoDeviceInfo.getModem().getParameters(26));
|
||||||
|
values.addProperty("RLC_UL_tput", protoDeviceInfo.getModem().getParameters(27));
|
||||||
|
values.addProperty("RLC_DL_tput", protoDeviceInfo.getModem().getParameters(28));
|
||||||
|
values.addProperty("MAC_UL_tput", protoDeviceInfo.getModem().getParameters(29));
|
||||||
|
values.addProperty("MAC_DL_tput", protoDeviceInfo.getModem().getParameters(30));
|
||||||
|
values.addProperty("sleep_duration", protoDeviceInfo.getModem().getParameters(31));
|
||||||
|
values.addProperty("rx_time", protoDeviceInfo.getModem().getParameters(32));
|
||||||
|
values.addProperty("tx_time", protoDeviceInfo.getModem().getParameters(33));
|
||||||
|
|
||||||
|
//Runtime info
|
||||||
|
DeviceInfoProtos.ProtoRuntime runtimeInfo = protoDeviceInfo.getRuntimeInfo();
|
||||||
|
values.addProperty("battery_reset_timestamp", getDate(runtimeInfo.getBatteryResetTimestamp()));
|
||||||
|
values.addProperty("max_mcu_temp", runtimeInfo.getMaxMcuTemperature());
|
||||||
|
values.addProperty("mcu_temp", runtimeInfo.getMcuTemperature());
|
||||||
|
values.addProperty("counter_of_confirmable_messages_attempts", runtimeInfo.getMessageCounters(0));
|
||||||
|
values.addProperty("counter_of_non_confirmable_messages_attempts", runtimeInfo.getMessageCounters(1));
|
||||||
|
values.addProperty("counter_of_succeeded_messages", runtimeInfo.getMessageCounters(2));
|
||||||
|
values.addProperty("min_battery_mcu_temp", runtimeInfo.getMinBatteryMcuTemperature());
|
||||||
|
values.addProperty("min_battery_voltage", runtimeInfo.getMinBatteryVoltage());
|
||||||
|
values.addProperty("min_mcu_temp", runtimeInfo.getMinMcuTemperature());
|
||||||
|
values.addProperty("runtime_errors", runtimeInfo.getRuntimeErrorsCount());
|
||||||
|
values.addProperty("up_time", runtimeInfo.getUpTime());
|
||||||
|
|
||||||
|
return new EfentoTelemetry(System.currentTimeMillis(), values);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonObject getEfentoConfiguration(ConfigProtos.ProtoConfig config) {
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
|
||||||
|
values.addProperty("hash", config.getHash());
|
||||||
|
values.addProperty("serial", CoapEfentoUtils.convertByteArrayToString(config.getSerialNumber().toByteArray()));
|
||||||
|
values.addProperty("timestamp", getDate(config.getHashTimestamp()));
|
||||||
|
values.addProperty("current_time", getDate(config.getCurrentTime()));
|
||||||
|
values.addProperty("apn", getString(config.getApn(), "\u007F", "Automatic"));
|
||||||
|
values.addProperty("cloud_token", config.getCloudToken());
|
||||||
|
values.addProperty("token_config", getTokenConfigString(config.getCloudTokenConfig()));
|
||||||
|
values.addProperty("data_server", config.getDataServerIp() + ":" + config.getDataServerPort() +
|
||||||
|
"/" + config.getDataEndpoint());
|
||||||
|
values.addProperty("update_server", config.getUpdateServerIp() + " Coap port " +
|
||||||
|
config.getUpdateServerPortCoap() + " Udp port " + config.getUpdateServerPortUdp());
|
||||||
|
values.addProperty("device_info_endpoint", config.getDeviceInfoEndpoint());
|
||||||
|
values.addProperty("configuration_endpoint", config.getConfigurationEndpoint());
|
||||||
|
values.addProperty("time_endpoint", config.getTimeEndpoint());
|
||||||
|
values.addProperty("transfer_limit", getStringValue(config.getTransferLimit(), 65535, "Disable"));
|
||||||
|
values.addProperty("plmn_selection", getPlmnSelection(config.getPlmnSelection()));
|
||||||
|
values.addProperty("supervision_period", getStringValue(config.getSupervisionPeriod(), 0xFFFFFFFF, "Functionality disabled"));
|
||||||
|
values.addProperty("modem_bands_mask", config.getModemBandsMask());
|
||||||
|
values.addProperty("ACK", getStringValue(config.getAckInterval(), 0xFFFFFFFF, "Always request ACK"));
|
||||||
|
values.addProperty("ble_tx_power_level", config.getBleTxPowerLevel());
|
||||||
|
values.addProperty("channel_types", config.getChannelTypesList().stream().map(Enum::toString).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("rules", config.getRulesList().stream().map(protoRule -> protoRule.getCondition().toString()).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("calendars", config.getCalendarsList().stream().map(protoCalendar -> protoCalendar.getType().toString()).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("cellular_config_params", config.getCellularConfigParamsList().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("dns_server_ip", config.getDnsServerIpList().stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("dns_ttl_config", getDnsTtlConfigString(config.getDnsTtlConfig()));
|
||||||
|
values.addProperty("token_coap_option", getStringValue(config.getCloudTokenCoapOption(), 65000, "Cloud token sent in the payload"));
|
||||||
|
values.addProperty("payload_signature_CoAP_option", getStringValue(config.getPayloadSignatureCoapOption(), 65000, "No payload signature in CoAP option"));
|
||||||
|
values.addProperty("payload_split_info", getPayloadSplitInfo(config.getPayloadSplitInfo()));
|
||||||
|
values.addProperty("led_config", config.getLedConfigList().stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||||
|
values.addProperty("network_troubleshooting", getNetworkTroubleShooting(config.getNetworkTroubleshooting()));
|
||||||
|
values.addProperty("encryption_key", getEncryptionKey(config.getEncryptionKey().toByteArray()));
|
||||||
|
values.addProperty("apn_username", getString(config.getApnUserName(),"\u007F", "Automatic"));
|
||||||
|
values.addProperty("apn_password", getString(config.getApnPassword(),"\u007F", "Automatic"));
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStorageStatus(int status) {
|
||||||
|
String storageStatusString;
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
storageStatusString = "No errors";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
storageStatusString = "Nv storage has some corrupted packet. Memory is read-only";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
storageStatusString = "Nv storage is corrupted. Memory is unavailable";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
storageStatusString = String.valueOf(status);
|
||||||
|
}
|
||||||
|
return storageStatusString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTokenConfigString(int tokenConfig) {
|
||||||
|
String tokenConfigString;
|
||||||
|
switch (tokenConfig) {
|
||||||
|
case 1:
|
||||||
|
tokenConfigString = "Cloud_token field value";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tokenConfigString = "IMEI of the cellular module";
|
||||||
|
break;
|
||||||
|
case 255:
|
||||||
|
tokenConfigString = "Do not send cloud_token field";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tokenConfigString = String.valueOf(tokenConfig);
|
||||||
|
}
|
||||||
|
return tokenConfigString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(String string, String marginalValue, String marginalDescription) {
|
||||||
|
String formatedString;
|
||||||
|
if (string.equals(marginalValue)) {
|
||||||
|
formatedString = marginalDescription;
|
||||||
|
} else {
|
||||||
|
formatedString = string;
|
||||||
|
}
|
||||||
|
return formatedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getEncryptionKey(byte[] bytes) {
|
||||||
|
String keyString;
|
||||||
|
if (Arrays.equals(bytes, new byte[] {0x7F})) {
|
||||||
|
keyString = "Encryption key disabled";
|
||||||
|
} else {
|
||||||
|
keyString = CoapEfentoUtils.convertByteArrayToString(bytes);
|
||||||
|
}
|
||||||
|
return keyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getNetworkTroubleShooting(int networkTroubleShooting) {
|
||||||
|
String networkTroubleShootingString;
|
||||||
|
if (networkTroubleShooting == 1) {
|
||||||
|
networkTroubleShootingString = "Network troubleshooting disabled";
|
||||||
|
} else if (networkTroubleShooting == 2) {
|
||||||
|
networkTroubleShootingString = "Network troubleshooting enabled";
|
||||||
|
} else {
|
||||||
|
networkTroubleShootingString = String.valueOf(networkTroubleShooting);
|
||||||
|
}
|
||||||
|
return networkTroubleShootingString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPayloadSplitInfo(int info) {
|
||||||
|
String infoString;
|
||||||
|
if (info < 0) {
|
||||||
|
infoString = "Payload has been split, expect another part of the payload in the next message. The absolute value indicates an index of the current message.";
|
||||||
|
} else if (info == 0) {
|
||||||
|
infoString = "Payload has not been splitted";
|
||||||
|
} else {
|
||||||
|
infoString = "Last part of the split payload, the value indicates the total number of the messages sent";
|
||||||
|
}
|
||||||
|
return infoString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getStringValue(int option, int marginalValue, String marginalDescription) {
|
||||||
|
String optionString;
|
||||||
|
if (option == marginalValue) {
|
||||||
|
optionString = marginalDescription;
|
||||||
|
} else {
|
||||||
|
optionString = String.valueOf(option);
|
||||||
|
}
|
||||||
|
return optionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDnsTtlConfigString(int config) {
|
||||||
|
String configString;
|
||||||
|
if (config == 864001) {
|
||||||
|
configString = "Accept TTL from the DNS server (additionally, the DNS request when communication has failed)";
|
||||||
|
} else if (config == 864002) {
|
||||||
|
configString = "DNS request is only after communication failed";
|
||||||
|
} else {
|
||||||
|
configString = String.valueOf(config);
|
||||||
|
}
|
||||||
|
return configString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPlmnSelection(int selection) {
|
||||||
|
String selectionString;
|
||||||
|
if (selection == 1000000 || selection == 0xFFFFFFFF) {
|
||||||
|
selectionString = "automatic selection";
|
||||||
|
} else {
|
||||||
|
selectionString = String.valueOf(selection);
|
||||||
|
}
|
||||||
|
return selectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDate(long seconds) {
|
||||||
|
if (seconds == -1L || seconds == 4294967295L) {
|
||||||
|
return "Undefined";
|
||||||
|
}
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z");
|
||||||
|
return simpleDateFormat.format(new Date(TimeUnit.SECONDS.toMillis(seconds)));
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class EfentoMeasurements {
|
public static class EfentoTelemetry {
|
||||||
|
|
||||||
private long ts;
|
private long ts;
|
||||||
private JsonObject values;
|
private JsonObject values;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
package org.thingsboard.server.transport.coap.efento.adaptor;
|
package org.thingsboard.server.transport.coap.efento.adaptor;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.common.transport.adaptor.AdaptorException;
|
import org.thingsboard.server.common.transport.adaptor.AdaptorException;
|
||||||
@ -32,7 +33,7 @@ public class EfentoCoapAdaptor {
|
|||||||
|
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
public TransportProtos.PostTelemetryMsg convertToPostTelemetry(UUID sessionId, List<CoapEfentoTransportResource.EfentoMeasurements> measurements) throws AdaptorException {
|
public TransportProtos.PostTelemetryMsg convertToPostTelemetry(UUID sessionId, List<CoapEfentoTransportResource.EfentoTelemetry> measurements) throws AdaptorException {
|
||||||
try {
|
try {
|
||||||
return JsonConverter.convertToTelemetryProto(gson.toJsonTree(measurements));
|
return JsonConverter.convertToTelemetryProto(gson.toJsonTree(measurements));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -40,4 +41,15 @@ public class EfentoCoapAdaptor {
|
|||||||
throw new AdaptorException(ex);
|
throw new AdaptorException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransportProtos.PostAttributeMsg convertToPostAttribute(UUID sessionId, JsonObject deviceInfo) throws AdaptorException {
|
||||||
|
try {
|
||||||
|
return JsonConverter.convertToAttributesProto(deviceInfo);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("[{}] Failed to convert JsonObject to PostTelemetry request!", sessionId);
|
||||||
|
throw new AdaptorException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
312
common/transport/coap/src/main/proto/proto_config.proto
Normal file
312
common/transport/coap/src/main/proto/proto_config.proto
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2023 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
import "proto_measurement_types.proto";
|
||||||
|
import "proto_rule.proto";
|
||||||
|
|
||||||
|
option java_package = "org.thingsboard.server.gen.transport.coap";
|
||||||
|
option java_outer_classname = "ConfigProtos";
|
||||||
|
|
||||||
|
/* Message containing optional channels control parameters */
|
||||||
|
message ProtoChannelControl {
|
||||||
|
|
||||||
|
/* Channel index */
|
||||||
|
uint32 channel_index = 1;
|
||||||
|
|
||||||
|
/* Control parameters. Maximal number equals 4. This field is channel specific: */
|
||||||
|
/* IO_control channel: */
|
||||||
|
/* - control_params[0]: */
|
||||||
|
/* - Byte 0: On state configuration */
|
||||||
|
/* 0x01 - Low */
|
||||||
|
/* 0x02 - High */
|
||||||
|
/* 0x03 - High-Z (disconnected) */
|
||||||
|
/* - Byte 1: Off state configuration */
|
||||||
|
/* 0x01 - Low */
|
||||||
|
/* 0x02 - High */
|
||||||
|
/* 0x03 - High-Z (disconnected) */
|
||||||
|
/* - Byte 2: Power on channel state */
|
||||||
|
/* 0x01 - On */
|
||||||
|
/* 0x02 - Off */
|
||||||
|
repeated uint32 control_params = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Message containing request data for accesing calibration parameters */
|
||||||
|
message ProtoCalibrationParameters {
|
||||||
|
|
||||||
|
/* Request details. Bitmask: */
|
||||||
|
/* - calibration_request[0:2] - requested channel number. */
|
||||||
|
uint32 calibration_request = 1;
|
||||||
|
|
||||||
|
/* Assignment of a channel. */
|
||||||
|
uint32 channel_assignment = 2;
|
||||||
|
|
||||||
|
/* Table of calibration parameters. Max size = 8. */
|
||||||
|
repeated int32 parameters = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main message sent in the payload. Each field in this message is independent of the others - only parameters that should be */
|
||||||
|
/* changed need to be sent in the payload. */
|
||||||
|
/* If the value of a selected parameter shall not be changed, do not include it in the payload */
|
||||||
|
message ProtoConfig {
|
||||||
|
|
||||||
|
/* DEPRECATED - Used for backward compatibility with fw versions 5.x */
|
||||||
|
/* repeated Threshold thresholds = 1; */
|
||||||
|
|
||||||
|
/* 'Measurement_period_base' and 'measurement_period_factor' define how often the measurements are taken. */
|
||||||
|
/* Sensors of 'Continuous' type take measurement each Measurement_period_base * measurement_period_factor. */
|
||||||
|
/* Sensors of 'Binary' type take measurement each Measurement_period_base. */
|
||||||
|
/* For backward compatibility with versions 5.x in case of binary/mixed sensors, if the 'measurement_period_factor' is */
|
||||||
|
/* not sent (equal to 0), then the default value '14' shall be used for period calculation. */
|
||||||
|
/* For backward compatibility with versions 5.x in case of continues sensors, if the measurement_period_factor is */
|
||||||
|
/* not sent (equal to 0), then the default value '1' shall be used for period calculation. */
|
||||||
|
/* measurement period base in seconds */
|
||||||
|
/* Range [1:65535] - minimum value can vary depends on installed sensors */
|
||||||
|
uint32 measurement_period_base = 2;
|
||||||
|
|
||||||
|
/* Measurement period factor */
|
||||||
|
/* Range [1:65535] - minimum value can vary depends on installed sensors */
|
||||||
|
uint32 measurement_period_factor = 26;
|
||||||
|
|
||||||
|
/* Transmission interval in seconds. Range: [60:604800] */
|
||||||
|
uint32 transmission_interval = 3;
|
||||||
|
|
||||||
|
/* BLE turnoff time in seconds. Once receiving this setting, BLE will be switched off after the set number of seconds. */
|
||||||
|
/* If BLE is already switched off, it will switch on for the set number of seconds and switch off afterwards. */
|
||||||
|
/* Range [60:604800] and 0xFFFFFFFF */
|
||||||
|
/* 0xFFFFFFFF - always on */
|
||||||
|
uint32 ble_turnoff_time = 4;
|
||||||
|
|
||||||
|
/* ACK interval in seconds */
|
||||||
|
/* Range [180:2592000] and 0xFFFFFFFF */
|
||||||
|
/* 0xFFFFFFFF - always request ACK */
|
||||||
|
uint32 ack_interval = 5;
|
||||||
|
|
||||||
|
/* Specifies, if the additional device info is requested. If true, sensor will send a message to endpoint '/i' with the */
|
||||||
|
/* device info. This field is only sent by server */
|
||||||
|
bool request_device_info = 6;
|
||||||
|
|
||||||
|
/* Specifies, if software update is available. This field is only sent by server */
|
||||||
|
bool request_fw_update = 7;
|
||||||
|
|
||||||
|
/* Current time in seconds sine 1st of January 1970 (epoch time). */
|
||||||
|
uint32 current_time = 8;
|
||||||
|
|
||||||
|
/* NB-IoT transfer limit */
|
||||||
|
/* Range: [1:65535] */
|
||||||
|
/* 65535 - disable transfer limit function */
|
||||||
|
uint32 transfer_limit = 9;
|
||||||
|
|
||||||
|
/* NB-IoT transfer limit timer in seconds */
|
||||||
|
/* Range: [1:65535] */
|
||||||
|
/* 65535 - disable transfer limit function */
|
||||||
|
uint32 transfer_limit_timer = 10;
|
||||||
|
|
||||||
|
/* Data (measurements) server IP address */
|
||||||
|
/* IP of the data server as string in form x.x.x.x. For example: 18.184.24.239 */
|
||||||
|
string data_server_ip = 11;
|
||||||
|
|
||||||
|
/* Data (measurements) server port */
|
||||||
|
/* Range: [1:65535] */
|
||||||
|
uint32 data_server_port = 12;
|
||||||
|
|
||||||
|
/* Update server IP address */
|
||||||
|
/* IP of data server as string in form x.x.x.x. For example: 18.184.24.239 */
|
||||||
|
string update_server_ip = 13;
|
||||||
|
|
||||||
|
/* Update server port for UDP transmission */
|
||||||
|
/* Range: [1:65535] */
|
||||||
|
uint32 update_server_port_udp = 14;
|
||||||
|
|
||||||
|
/* Update server port for CoAP transmission */
|
||||||
|
/* Range: [1:65535] */
|
||||||
|
uint32 update_server_port_coap = 15;
|
||||||
|
|
||||||
|
/* APN as string. Max length 49 */
|
||||||
|
/* String with special character 0x7F (DEL) only indicates that automatic apn is turn on */
|
||||||
|
string apn = 16;
|
||||||
|
|
||||||
|
/* PLMN selection */
|
||||||
|
/* Range: [100:999999] */
|
||||||
|
/* 0xFFFFFFFF or 1000000 - automatic selection */
|
||||||
|
uint32 plmn_selection = 17;
|
||||||
|
|
||||||
|
/* Device will power off its cellular modem for requested number of seconds. Maximum number of seconds 604800 (7 days) */
|
||||||
|
/* This field is only sent by server */
|
||||||
|
uint32 disable_modem_request = 18;
|
||||||
|
|
||||||
|
/* If set, the device will send its configuration to the endpoint '/c' as a confirmable message */
|
||||||
|
/* This field is only sent by server */
|
||||||
|
bool request_configuration = 19;
|
||||||
|
|
||||||
|
/* Device's error codes. */
|
||||||
|
/* This field is only sent by device */
|
||||||
|
repeated uint32 errors = 20;
|
||||||
|
|
||||||
|
/* Identifier of current configuration - Every change of the configuration results in change of the value of this field */
|
||||||
|
/* This field is only sent by device */
|
||||||
|
uint32 hash = 21;
|
||||||
|
|
||||||
|
/* If true, the device will accept the configuration without functional testing (eg. network connection) */
|
||||||
|
bool accept_without_testing = 22;
|
||||||
|
|
||||||
|
/* Cloud token configuration: */
|
||||||
|
/* - 1: cloud token set to the value of cloud_token field */
|
||||||
|
/* - 2: cloud token set to IMEI of the cellular module */
|
||||||
|
/* - 255: do not send cloud_token field */
|
||||||
|
uint32 cloud_token_config = 23;
|
||||||
|
|
||||||
|
/* Cloud token that should be sent with each measurement frame */
|
||||||
|
string cloud_token = 24;
|
||||||
|
|
||||||
|
/* Serial number of the device */
|
||||||
|
/* This field is only sent by device */
|
||||||
|
bytes serial_number = 25;
|
||||||
|
|
||||||
|
/* Type of channel */
|
||||||
|
/* This field is only sent by device */
|
||||||
|
repeated MeasurementType channel_types = 27;
|
||||||
|
|
||||||
|
/* Edge logic rules set on the device. Up to 12 rules are supported */
|
||||||
|
repeated ProtoRule rules = 28;
|
||||||
|
|
||||||
|
/* Supervision period */
|
||||||
|
/* Range: [180:604800] */
|
||||||
|
/* 0xFFFFFFFF - Functionality disabled */
|
||||||
|
uint32 supervision_period = 29;
|
||||||
|
|
||||||
|
/* If true, sensor's measurement memory will be erased */
|
||||||
|
bool memory_reset_request = 30;
|
||||||
|
|
||||||
|
/* Bytes 0-4 - Band selection mask. Mask = 1 << position */
|
||||||
|
/* Band | 1 | 2 | 3 | 4 | 5 | 8 | 12 | 13 | 17 | 18 | 19 | 20 | 25 | 26 | 28 | 66 | 71 | 85 | */
|
||||||
|
/* Position: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | */
|
||||||
|
/* example: To enable band 3, 8 and 20 set to (1 << 2) + (1 << 5) + (1 << 11) = 2084 */
|
||||||
|
uint32 modem_bands_mask = 31;
|
||||||
|
|
||||||
|
/* Data endpoint (string - max length 16) */
|
||||||
|
string data_endpoint = 32;
|
||||||
|
|
||||||
|
/* Configuration endpoint (string - max length 16) */
|
||||||
|
string configuration_endpoint = 33;
|
||||||
|
|
||||||
|
/* Device info endpoint (string - max length 16) */
|
||||||
|
string device_info_endpoint = 34;
|
||||||
|
|
||||||
|
/* Time endpoint (string - max length 16) */
|
||||||
|
string time_endpoint = 35;
|
||||||
|
|
||||||
|
/* Bluetooth TX power level. Value is the index of the absolute value of TX power, that depends on the BLE module */
|
||||||
|
/* Range: [1:4] */
|
||||||
|
uint32 ble_tx_power_level = 36;
|
||||||
|
|
||||||
|
/* Deprecated field */
|
||||||
|
/* If true, the sensor's runtime errors will be cleared */
|
||||||
|
bool request_runtime_errors_clear = 37;
|
||||||
|
|
||||||
|
/* Timestamp when a new error code was reported */
|
||||||
|
uint32 error_timestamp = 38;
|
||||||
|
|
||||||
|
/* Timestamp when the new configuration was set */
|
||||||
|
uint32 hash_timestamp = 39;
|
||||||
|
|
||||||
|
/* Cloud token CoAP option ID: */
|
||||||
|
/* - [1:64999] - CoAP option ID containing cloud token */
|
||||||
|
/* - 65000 - cloud token sent in the payload */
|
||||||
|
uint32 cloud_token_coap_option = 40;
|
||||||
|
|
||||||
|
/* ECDSA payload signature CoAP option ID: */
|
||||||
|
/* - [1:64999] - CoAP option ID containing ECDSA payload signature */
|
||||||
|
/* - 65000 - no payload signature in CoAP option */
|
||||||
|
uint32 payload_signature_coap_option = 41;
|
||||||
|
|
||||||
|
/* DNS server IP address grouped in the array as four octets. Set 255.255.255.255 to use a network DNS server */
|
||||||
|
/* Note: when setting less than four octets the remaining will be filled with zeros. */
|
||||||
|
repeated uint32 dns_server_ip = 42;
|
||||||
|
|
||||||
|
/* DNS TTL configuration: */
|
||||||
|
/* - [1:864000] - custom TTL in seconds (additionally, the DNS request when communication has failed) */
|
||||||
|
/* - 864001 - accept TTL from the DNS server (additionally, the DNS request when communication has failed) */
|
||||||
|
/* - 864002 - DNS request is only after communication failed */
|
||||||
|
uint32 dns_ttl_config = 43;
|
||||||
|
|
||||||
|
/* Configuration payload split information. Information about dividing the payload into parts */
|
||||||
|
/* values < 0 - payload has been split, expect another part of the payload in the next message. */
|
||||||
|
/* The absolute value indicates an index of the current message. */
|
||||||
|
/* value = 0 - payload has not been splitted */
|
||||||
|
/* values > 0 - last part of the split payload, the value indicates the total number of the messages sent */
|
||||||
|
sint32 payload_split_info = 44;
|
||||||
|
|
||||||
|
/* Modem update request (string - max length 48) */
|
||||||
|
/* This field is only sent by server */
|
||||||
|
/* For BC66 module, this field is a DFOTA URL */
|
||||||
|
string modem_update_request = 45;
|
||||||
|
|
||||||
|
/* Cellular configuration parameters. */
|
||||||
|
/* 1st item - Number of used cellular parameters */
|
||||||
|
/* 2nd - 12th items - Cellular parameters */
|
||||||
|
repeated uint32 cellular_config_params = 46;
|
||||||
|
|
||||||
|
/* Calendar configuration. Up to 6 calendars are supported */
|
||||||
|
repeated ProtoCalendar calendars = 47;
|
||||||
|
|
||||||
|
/* Control parameters for channels. Maximal number of requests equals 6 */
|
||||||
|
/* This field is only sent by server */
|
||||||
|
repeated ProtoChannelControl channels_control_request = 48;
|
||||||
|
|
||||||
|
/* Set/get calibration parameters for single channel. */
|
||||||
|
ProtoCalibrationParameters calibration_parameters_request = 49;
|
||||||
|
|
||||||
|
/* LED behaviour configuration: */
|
||||||
|
/* Period of LEDs flashing (5-600 seconds in 5 seconds resolution): */
|
||||||
|
/* - led_config[0] - green LED */
|
||||||
|
/* - led_config[1] - red LED */
|
||||||
|
/* Time from entering the normal state, after which the LED indication is turned off */
|
||||||
|
/* (0-240 minutes in 1 minute resolution, or 255 for always turned on): */
|
||||||
|
/* - led_config[2] - flashing red led on communication problem */
|
||||||
|
/* - led_config[3] - flashing red led on a sensor problem */
|
||||||
|
/* - led_config[4] - flashing red led on a low power */
|
||||||
|
/* - led_config[5] - flashing green led on measurement */
|
||||||
|
/* - led_config[6] - flashing green led on transmission */
|
||||||
|
/* - led_config[7] - flashing green led to indicate sensor's proper operation */
|
||||||
|
/* - led_config[8] - Blink duration (20-1000ms in 5 ms resolution) */
|
||||||
|
repeated uint32 led_config = 50;
|
||||||
|
|
||||||
|
/* Network troubleshooting configuration, if bluetooth is turned off and communication with the server is faulty, */
|
||||||
|
/* bluetooth will be automatically turned on until the connection is stabilized */
|
||||||
|
/* - 1: network troubleshooting disabled */
|
||||||
|
/* - 2: network troubleshooting enabled */
|
||||||
|
uint32 network_troubleshooting = 51;
|
||||||
|
|
||||||
|
/* Reserved by gateway client */
|
||||||
|
reserved 52, 53;
|
||||||
|
|
||||||
|
/* Encryption key configuration. Sensor sends in this field two last bytes of SHA256 hash calculated from its current */
|
||||||
|
/* encryption_key configuration. */
|
||||||
|
/* Max length: 16 bytes. */
|
||||||
|
/* 0x7F - encryption key disabled. */
|
||||||
|
bytes encryption_key = 54;
|
||||||
|
|
||||||
|
/* User name as string. Max length 31 */
|
||||||
|
/* String with special character 0x7F (DEL) only indicates that automatic user name is turn on */
|
||||||
|
/* User name can only be set to custom value if apn has been configured (is not automatic) */
|
||||||
|
string apn_user_name = 55;
|
||||||
|
|
||||||
|
/* Password as string. Max length 31 */
|
||||||
|
/* String with special character 0x7F (DEL) only indicates that automatic password is turn on */
|
||||||
|
/* Password can only be set to custom value if apn_user_name has been configured (is not automatic) */
|
||||||
|
string apn_password = 56;
|
||||||
|
}
|
||||||
197
common/transport/coap/src/main/proto/proto_device_info.proto
Normal file
197
common/transport/coap/src/main/proto/proto_device_info.proto
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2023 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "org.thingsboard.server.gen.transport.coap";
|
||||||
|
option java_outer_classname = "DeviceInfoProtos";
|
||||||
|
|
||||||
|
enum ModemType
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Invalid value */
|
||||||
|
MODEM_TYPE_UNSPECIFIED = 0;
|
||||||
|
|
||||||
|
/* Quectel BC66 modem */
|
||||||
|
MODEM_TYPE_BC66 = 1;
|
||||||
|
|
||||||
|
/* Quectel BC66-NA modem */
|
||||||
|
MODEM_TYPE_BC66NA = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProtoRuntime
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Up-time in seconds (since reset) */
|
||||||
|
uint32 up_time = 1;
|
||||||
|
|
||||||
|
/* Message counters (since reset). There are 3 counters: */
|
||||||
|
/* message_counters[0] - Counter of confirmable messages attempts */
|
||||||
|
/* message_counters[1] - Counter of non-confirmable messages attempts */
|
||||||
|
/* message_counters[2] - Counter of succeeded messages */
|
||||||
|
repeated uint32 message_counters = 2;
|
||||||
|
|
||||||
|
/* MCU temperature in Celsius */
|
||||||
|
sint32 mcu_temperature = 3;
|
||||||
|
|
||||||
|
/* Minimum battery voltage in mV */
|
||||||
|
uint32 min_battery_voltage = 4;
|
||||||
|
|
||||||
|
/* MCU temperature in Celsius, while the minimum battery voltage was reached */
|
||||||
|
sint32 min_battery_mcu_temperature = 5;
|
||||||
|
|
||||||
|
/* Battery reset timestamp (Unix timestamp) */
|
||||||
|
uint32 battery_reset_timestamp = 6;
|
||||||
|
|
||||||
|
/* Max MCU temperature in Celsius */
|
||||||
|
sint32 max_mcu_temperature = 7;
|
||||||
|
|
||||||
|
/* Min MCU temperature in Celsius */
|
||||||
|
sint32 min_mcu_temperature = 8;
|
||||||
|
|
||||||
|
/* Table of runtime errors. Max length: 20 */
|
||||||
|
repeated uint32 runtime_errors = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProtoModem
|
||||||
|
{
|
||||||
|
|
||||||
|
ModemType type = 1;
|
||||||
|
|
||||||
|
/* Parameters for BC66 modem: */
|
||||||
|
/* parameters[0] - sc_EARFCN - Range: [0:262143]. Unknown value: -1 */
|
||||||
|
/* parameters[1] - sc_EARNFCN_offset - Range: [0:4] mapped to [-2, -1, -0.5, 0, 1]. Unknown value: -1 */
|
||||||
|
/* parameters[2] - sc_PCI - Range: [0:502]. Unknown value: -1 */
|
||||||
|
/* parameters[3] - sc_Cell id - Range: [1:268435456]. Unknown value: 0 */
|
||||||
|
/* parameters[4] - sc_RSRP - [dBm] - Range: [-140:-44]. Unknown value: 0 */
|
||||||
|
/* parameters[5] - sc_RSRQ - [dB] - Range: [-20:-3]. Unknown value: 0 */
|
||||||
|
/* parameters[6] - sc_RSSI - [dBm] - Range: [-110:-3] Unknown value: 0 */
|
||||||
|
/* parameters[7] - sc_SINR - [dB] - Range: [-10:30]. Unknown value: 31 */
|
||||||
|
/* parameters[8] - sc_Band - Range: [see module supported bands]. The current serving cell band. Unknown value: -1 */
|
||||||
|
/* parameters[9] - sc_TAC - Range: [0:65536]. Unknown value: -1 */
|
||||||
|
/* parameters[10] - sc_ECL - Range: [0:2]. Unknown value: -1 */
|
||||||
|
/* parameters[11] - sc_TX_PWR - [0.1cBm] - Range [-440:230]. Unknown value: -1000 */
|
||||||
|
/* parameters[12] - OP_MODE - Range: [0:3]. Unknown value: -1 */
|
||||||
|
/* parameters[13] - nc_EARFCN - Range: [0:262143]. Unknown value: -1 */
|
||||||
|
/* parameters[14] - nc_EARNFCN_offset - Range: [0:4] mapped to [-2, -1, -0.5, 0, 1]. Unknown value: -1 */
|
||||||
|
/* parameters[15] - nc_PCI - Range: [0:502]. Unknown value: -1 */
|
||||||
|
/* parameters[16] - nc_RSRP - [dBm] - Range: [-140:-44]. Unknown value: 0 */
|
||||||
|
/* parameters[17] - RLC_UL_BLER - Range: [0:100]. Unknown value: -1 */
|
||||||
|
/* parameters[18] - RLC_DL_BLER - Range: [0:100]. Unknown value: -1 */
|
||||||
|
/* parameters[19] - MAC_UL_BLER - Range: [0:100]. Unknown value: -1 */
|
||||||
|
/* parameters[20] - MAC_DL_BLER - Range: [0:100]. Unknown value: -1 */
|
||||||
|
/* parameters[21] - MAC_UL_TOTAL_BYTES - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[22] - MAC_DL_TOTAL_BYTES - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[23] - MAC_UL_total_HARQ_Tx - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[24] - MAC_DL_total_HARQ_Tx - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[25] - MAC_UL_HARQ_re_Tx - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[26] - MAC_DL_HARQ_re_Tx - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[27] - RLC_UL_tput - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[28] - RLC_DL_tput - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[29] - MAC_UL_tput - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[30] - MAC_DL_tput - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[31] - sleep_duration - [0.1s] - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[32] - Rx_time - [0.1s] - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
/* parameters[33] - Tx_time - [0.1s] - Range: [0:2147483647]. Unknown value: -1 */
|
||||||
|
repeated sint32 parameters = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProtoUpdateInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Timestamp of update (Unix timestamp) */
|
||||||
|
uint32 timestamp = 1;
|
||||||
|
|
||||||
|
/* Update status, possible values: */
|
||||||
|
/* - 0x1 - No update yet */
|
||||||
|
/* - 0x2 - No error */
|
||||||
|
/* - 0x3 - UDP socekt error */
|
||||||
|
/* - 0x4 - Hash error */
|
||||||
|
/* - 0x5 - Missing packet error */
|
||||||
|
/* - 0x6 - Invalid data error */
|
||||||
|
/* - 0x7 - Sending timeout error */
|
||||||
|
/* - 0x8 - No SW to update error */
|
||||||
|
/* - 0x9 - Sending unexpected error */
|
||||||
|
/* - 0x10 - Unexpected error */
|
||||||
|
uint32 status = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProtoDeviceInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Serial number of device */
|
||||||
|
bytes serial_num = 1;
|
||||||
|
|
||||||
|
/* Deprecated field */
|
||||||
|
reserved 2;
|
||||||
|
|
||||||
|
/* Software version e.g ver 06.10 -> 0x060A -> 1546 */
|
||||||
|
uint32 sw_version = 3;
|
||||||
|
|
||||||
|
/* Deprecated fields */
|
||||||
|
reserved 4,5,6,7,8,9,10,11,12;
|
||||||
|
|
||||||
|
/* Structure with battery and temperature information */
|
||||||
|
ProtoRuntime runtime_info = 13;
|
||||||
|
|
||||||
|
/* Structure with modem specific runtime information */
|
||||||
|
ProtoModem modem = 14;
|
||||||
|
|
||||||
|
/* String up to 7 bytes long. Software commit id e.g. "e0e8556" */
|
||||||
|
/* From version 06.07 the first two characters indicate the LTS version. */
|
||||||
|
/* For example: the value "0bdd23f" means LTS version 11 and the beginning of the commit ID "dd23f" */
|
||||||
|
string commit_id = 15;
|
||||||
|
|
||||||
|
/* Optional string up to 36 bytes long. Can be set to any user define value or hold device's IMEI */
|
||||||
|
string cloud_token = 16;
|
||||||
|
|
||||||
|
/* Memory statistics: */
|
||||||
|
/* memory_statistics[0] - Status of Nv storage: */
|
||||||
|
/* - 0 - Nv storage hasn't errors */
|
||||||
|
/* - 1 - Nv storage has some corrupted packet. Memory is read-only */
|
||||||
|
/* - 2 - Nv storage is corrupted. Memory is unavailable */
|
||||||
|
/* memory_statistics[1] - Timestamp of the end of collecting statistics. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[2] - Capacity of memory in bytes */
|
||||||
|
/* memory_statistics[3] - Used space in bytes */
|
||||||
|
/* memory_statistics[4] - Size of invalid (outdated) packets in bytes */
|
||||||
|
/* memory_statistics[5] - Size of corrupted packets in bytes */
|
||||||
|
/* memory_statistics[6] - Number of valid packets */
|
||||||
|
/* memory_statistics[7] - Number of invalid (outdated) packets */
|
||||||
|
/* memory_statistics[8] - Number of corrupted packets */
|
||||||
|
/* memory_statistics[9] - Number of all samples for channel 1 (valid packets) */
|
||||||
|
/* memory_statistics[10] - Number of all samples for channel 2 (valid packets) */
|
||||||
|
/* memory_statistics[11] - Number of all samples for channel 3 (valid packets) */
|
||||||
|
/* memory_statistics[12] - Number of all samples for channel 4 (valid packets) */
|
||||||
|
/* memory_statistics[13] - Number of all samples for channel 5 (valid packets) */
|
||||||
|
/* memory_statistics[14] - Number of all samples for channel 6 (valid packets) */
|
||||||
|
/* memory_statistics[15] - Timestamp of the first binary measurement. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[16] - Timestamp of the last binary measurement. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[17] - Timestamp of the last binary measurement, that marked as sent. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[18] - Timestamp of the first continuous measurement. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[19] - Timestamp of the last continuous measurement. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[20] - Timestamp of the last continuous measurement, that marked as sent. */
|
||||||
|
/* Value in seconds since UNIX EPOCH 01-01-1970. Undefined value: 4294967295 */
|
||||||
|
/* memory_statistics[21] - NVM write counter */
|
||||||
|
repeated uint32 memory_statistics = 17;
|
||||||
|
|
||||||
|
/* Information about last sensor SW update */
|
||||||
|
ProtoUpdateInfo last_update_info = 18;
|
||||||
|
}
|
||||||
267
common/transport/coap/src/main/proto/proto_rule.proto
Normal file
267
common/transport/coap/src/main/proto/proto_rule.proto
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2023 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "org.thingsboard.server.gen.transport.coap";
|
||||||
|
option java_outer_classname = "ProtoRuleProtos";
|
||||||
|
|
||||||
|
/* Encoding A: used to set absolute values in the Rules (e.g. upper and lower threshold values) */
|
||||||
|
/* - TEMPERATURE - [°C] - Celsius degree. Resolution 0.1°C. Range [-273.2:4000.0]. */
|
||||||
|
/* - HUMIDITY - [% RH] - Relative humidity. Resolution 1%. Range [0:100]. */
|
||||||
|
/* - ATMOSPHERIC_PRESSURE - [hPa] - Hectopascal (1hPa = 100Pa). Resolution 0.1hPa. Range: [1.0:2000.0]. */
|
||||||
|
/* - DIFERENTIAL_PRESSURE - [Pa] - Pascal. Resolution 1Pa. Range [-10000:10000] */
|
||||||
|
/* - OK/ALARM - Not applicable */
|
||||||
|
/* - IAQ - [IAQ] - IAQ index. Resolution 1IAQ. Range [0:500]. */
|
||||||
|
/* - FLOODING - Not applicable */
|
||||||
|
/* - PULSE_CNT - [NB] Number of pulses. Resolution 1 pulse. Range [0:8000000]. */
|
||||||
|
/* - ELECTRICITY_METER - [W] - Watt; Resolution 1W. Range [0:8000000]. Average power consumption in period */
|
||||||
|
/* - WATER_METER [l/min] - Liter per minute. Resolution 1l/min. Range [0:8000000]. Average water flow in period. */
|
||||||
|
/* - SOIL_MOISTURE - [kPa] - Kilopascal (1kPa = 1000Pa); Resolution 1kPa. Range [-1000:0]. Soil moisture (tension). */
|
||||||
|
/* - CO_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Carbon monoxide concentration. */
|
||||||
|
/* - NO2_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Nitrogen dioxide concentration. */
|
||||||
|
/* - H2S_GAS - [ppm] - Parts per million. Resolution 0.01ppm. Range [0.00:80000.00]. Hydrogen sulfide concentration. */
|
||||||
|
/* - AMBIENT_LIGHT -[lx] - Lux. Resolution 0.1lx. Range [0.0:100000.0]. Illuminance. */
|
||||||
|
/* - PM_1_0 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [0:1000]. */
|
||||||
|
/* - PM_2_5 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [0:1000]. */
|
||||||
|
/* - PM_10_0 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [0:1000]. */
|
||||||
|
/* - NOISE_LEVEL - [dB] - Decibels. Resolution 0.1 dB. Range: [0.0:200.0]. Noise level. */
|
||||||
|
/* - NH3_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Ammonia concentration. */
|
||||||
|
/* - CH4_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Methane concentration. */
|
||||||
|
/* - HIGH_PRESSURE - [kPa] - Kilopascal (1kPa = 1000Pa, 100kPa = 1bar). Resolution 1kPa. Range [0:200000]. Pressure. */
|
||||||
|
/* - DISTANCE_MM - [mm] - Millimeter. Resolution 1mm. Range [0:100000]. Distance. */
|
||||||
|
/* - WATER_METER_ACC_MINOR - [l] - Liter. Resolution 1l. Range [0:1000000]. Accumulative water meter (minor). */
|
||||||
|
/* - WATER_METER_ACC_MAJOR - [hl] - Hectoliter. Resolution 1hl. Range [0:1000000]. Accumulative water meter (major). */
|
||||||
|
/* - CO2_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Carbon dioxide concentration. */
|
||||||
|
/* - HUMIDITY ACCURATE - [% RH] - Relative humidity. Resolution 0.1%. Range [0.0:100.0]. */
|
||||||
|
/* - STATIC_IAQ - [sIAQ] - Static IAQ index. Resolution 1sIAQ. Range [0:10000]. */
|
||||||
|
/* - CO2_EQUIVALENT - [ppm] - Parts per million. Resolution 1ppm. Range [0:1000000]. Carbon dioxide equivalent. */
|
||||||
|
/* - BREATH_VOC - [ppm] - Parts per million. Resolution 1ppm. Range [0:100000]. Breath VOC estimate. */
|
||||||
|
/* - PERCENTAGE - [%] - Percentage. Resolution 0.01%. Range [0.00:100.00]. */
|
||||||
|
/* - PULSE_CNT_ACC_MINOR - [NB] - Number of pulses. Resolution 1 pulse. Range [0:1000000]. Accumulative pulse counter (minor). */
|
||||||
|
/* - PULSE_CNT_ACC_MAJOR - [kNB] - Number of kilopulses. Resolution 1 kilopulse. Range [0:1000000]. */
|
||||||
|
/* Accumulative pulse counter (major). */
|
||||||
|
/* - ELEC_METER_ACC_MINOR - [Wh] - Watt-hour. Resolution 1Wh. Range [0:1000000]. Accumulative electricity meter (minor). */
|
||||||
|
/* - ELEC_METER_ACC_MAJOR - [kWh] - Kilowatt-hour. Resolution 1kWh. Range [0:1000000]. Accumulative electricity meter (major). */
|
||||||
|
|
||||||
|
/* Encoding R: used to set relative values in the Rules (e.g. differential threshold and hysteresis) */
|
||||||
|
/* - TEMPERATURE - [°C] - Celsius degree. Resolution 0.1°C. Range [0.1:4273.2]. */
|
||||||
|
/* - HUMIDITY - [% RH] - Relative humidity. Resolution 1%. Range [1:100]. */
|
||||||
|
/* - ATMOSPHERIC_PRESSURE - [hPa] - Hectopascal (1hPa = 100Pa). Resolution 0.1hPa. Range: [0.1:1999.0]. */
|
||||||
|
/* - DIFERENTIAL_PRESSURE - [Pa] - Pascal. Resolution 1Pa. Range [1:20000] */
|
||||||
|
/* - OK/ALARM - Not applicable */
|
||||||
|
/* - VOC - [IAQ] - Iaq index. Resolution 1IAQ. Range [1:500]. */
|
||||||
|
/* - FLOODING - Not applicable */
|
||||||
|
/* - PULSE_CNT - [NB] Number of pulses. Resolution 1 pulse. Range [1:8000000]. */
|
||||||
|
/* - ELECTRICITY_METER - [W] - Watt; Resolution 1W. Range [1:8000000]. Average power consumption in period */
|
||||||
|
/* - WATER_METER [l/min] - Liter per minute. Resolution 1l/min. Range [1:8000000]. Average water flow in period. */
|
||||||
|
/* - SOIL_MOISTURE - [kPa] - Kilopascal (1kPa = 1000Pa); Resolution 1kPa. Range [1:1000]. Soil moisture (tension). */
|
||||||
|
/* - CO_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Carbon monoxide concentration. */
|
||||||
|
/* - NO2_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Nitrogen dioxide concentration. */
|
||||||
|
/* - H2S_GAS - [ppm] - Parts per million. Resolution 0.01ppm. Range [0.01:80000.00]. Hydrogen sulfide concentration. */
|
||||||
|
/* - AMBIENT_LIGHT -[lx] - Lux. Resolution 0.1lx. Range [0.1:100000.0]. Illuminance. */
|
||||||
|
/* - PM_1_0 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [1:1000]. */
|
||||||
|
/* - PM_2_5 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [1:1000]. */
|
||||||
|
/* - PM_10_0 - [µg/m^3] - Micro gram per cubic meter. Resolution 1µg/m^3 Range [1:1000]. */
|
||||||
|
/* - NOISE_LEVEL - [dB] - Decibels. Resolution 0.1 dB. Range: [0.1:200.0]. Noise level. */
|
||||||
|
/* - NH3_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Ammonia concentration. */
|
||||||
|
/* - CH4_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Methane concentration. */
|
||||||
|
/* - HIGH_PRESSURE - [kPa] - Kilopascal (1kPa = 1000Pa, 100kPa = 1bar). Resolution 1kPa. Range [1:200000]. Pressure. */
|
||||||
|
/* - DISTANCE_MM - [mm] - Millimeter. Resolution 1mm. Range [1:100000]. Distance. */
|
||||||
|
/* - WATER_METER_ACC_MINOR - [l] - Liter. Resolution 1l. Range [1:1000000]. Accumulative water meter (minor). */
|
||||||
|
/* - WATER_METER_ACC_MAJOR - [hl] - Hectoliter. Resolution 1hl. Range [1:1000000]. Accumulative water meter (major). */
|
||||||
|
/* - CO2_GAS - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Carbon dioxide concentration. */
|
||||||
|
/* - HUMIDITY ACCURATE - [% RH] - Relative humidity. Resolution 0.1%. Range [0.1:100.0]. */
|
||||||
|
/* - STATIC_IAQ - [sIAQ] - Static IAQ index. Resolution 1sIAQ. Range [1:10000]. */
|
||||||
|
/* - CO2_EQUIVALENT - [ppm] - Parts per million. Resolution 1ppm. Range [1:1000000]. Carbon dioxide equivalent. */
|
||||||
|
/* - BREATH_VOC - [ppm] - Parts per million. Resolution 1ppm. Range [1:100000]. Breath VOC estimate. */
|
||||||
|
/* - PERCENTAGE - [%] - Percentage. Resolution 0.01%. Range [0.01:100.00]. */
|
||||||
|
/* - PULSE_CNT_ACC_MINOR - [NB] - Number of pulses. Resolution 1 pulse. Range [1:1000000]. Accumulative pulse counter (minor). */
|
||||||
|
/* - PULSE_CNT_ACC_MAJOR - [kNB] - Number of kilopulses. Resolution 1 kilopulse. Range [1:1000000]. */
|
||||||
|
/* Accumulative pulse counter (major). */
|
||||||
|
/* - ELEC_METER_ACC_MINOR - [Wh] - Watt-hour. Resolution 1Wh. Range [1:1000000]. Accumulative electricity meter (minor). */
|
||||||
|
/* - ELEC_METER_ACC_MAJOR - [kWh] - Kilowatt-hour. Resolution 1kWh. Range [1:1000000]. Accumulative electricity meter (major). */
|
||||||
|
|
||||||
|
/* Condition to be checked by the device. If the condition is true, an action is triggered */
|
||||||
|
enum Condition {
|
||||||
|
|
||||||
|
/* Invalid value */
|
||||||
|
CONDITION_UNSPECIFIED = 0;
|
||||||
|
|
||||||
|
/* Threshold function for given rule_id is disabled */
|
||||||
|
CONDITION_DISABLED = 1;
|
||||||
|
|
||||||
|
/* Upper threshold. Continuous sensors only. If the measurement (or average from a few measurements) is over the threshold, */
|
||||||
|
/* an action is triggered. */
|
||||||
|
/* parameter[0] - Threshold value in "Encoding A" format. Must match channel type */
|
||||||
|
/* parameter[1] - Hysteresis value in "Encoding R" format. Must much channel type. Set to "0" to disable */
|
||||||
|
/* parameter[2] - Triggering mode: */
|
||||||
|
/* - 1 - moving average (a1=(n1+n2+n3)/3, a2=(n2+n3+n4)/3, etc.) */
|
||||||
|
/* - 2 - window average (a1=(n1+n2+n3)/3, a2=(n4+n5+n6)/3, etc.) */
|
||||||
|
/* - 3 - consecutive samples (number of consecutive samples above threshold) */
|
||||||
|
/* parameter[3] - Number of measurements for trigger determination. E.g parameter[3] equals 3, average value from three */
|
||||||
|
/* samples will be calculated and compared to the threshold value in average mode or the third consecutive */
|
||||||
|
/* sample above threshold will trigger action in consecutive mode. Range: [1:10]. */
|
||||||
|
/* parameter[4] - Type of measurement (as described in MeasurementType). */
|
||||||
|
CONDITION_HIGH_THRESHOLD = 2;
|
||||||
|
|
||||||
|
/* Lower threshold. Continuous sensors only. If the measurement (or average from a few measurements) is below the threshold, */
|
||||||
|
/* an action is triggered. */
|
||||||
|
/* parameter[0] - Threshold value in "Encoding A" format. Must match channel type */
|
||||||
|
/* parameter[1] - Hysteresis value in "Encoding R" format. Must much channel type. Set to "0" to disable */
|
||||||
|
/* parameter[2] - Triggering mode: */
|
||||||
|
/* - 1 - moving average (a1=(n1+n2+n3)/3, a2=(n2+n3+n4)/3, etc.) */
|
||||||
|
/* - 2 - window average (a1=(n1+n2+n3)/3, a2=(n4+n5+n6)/3, etc.) */
|
||||||
|
/* - 3 - consecutive samples (number of consecutive samples above threshold) */
|
||||||
|
/* parameter[3] - Number of measurements for trigger determination. E.g parameter[3] equals 3, average value from three */
|
||||||
|
/* samples will be calculated and compared to the threshold value in average mode or the third consecutive */
|
||||||
|
/* sample below threshold will trigger action in consecutive mode. Range: [1:10]. */
|
||||||
|
/* parameter[4] - Type of measurement (as described in MeasurementType). */
|
||||||
|
CONDITION_LOW_THRESHOLD = 3;
|
||||||
|
|
||||||
|
/* Differential threshold. Continuous sensors only. If the absolute value of the difference between the last value sent to */
|
||||||
|
/* the server and the measurement value (or average from a few measurements) is greater or equal to the value of */
|
||||||
|
/* the threshold set, an action is triggered. */
|
||||||
|
/* parameter[0] - Threshold value in "Encoding R" format. Must match channel type */
|
||||||
|
/* parameter[1] - Triggering mode: */
|
||||||
|
/* - 1 - moving average (a1=(n1+n2+n3)/3, a2=(n2+n3+n4)/3, etc.) */
|
||||||
|
/* - 2 - window average (a1=(n1+n2+n3)/3, a2=(n4+n5+n6)/3, etc.) */
|
||||||
|
/* - 3 - consecutive samples (number of consecutive samples above threshold) */
|
||||||
|
/* parameter[2] - Number of measurements for trigger determination. E.g parameter[3] equals 3, average value from three */
|
||||||
|
/* samples will be calculated and compared to the threshold value in average mode or the third consecutive */
|
||||||
|
/* sample exceeding threshold will trigger action in consecutive mode. Range: [1:10]. */
|
||||||
|
/* parameter[3] - Type of measurement (as described in MeasurementType). */
|
||||||
|
CONDITION_DIFF_THRESHOLD = 4;
|
||||||
|
|
||||||
|
/* Change of binary sensor's state. Binary sensors only. Each change of the binary's sensor state will trigger an action. */
|
||||||
|
CONDITION_BINARY_CHANGE_STATE = 5;
|
||||||
|
|
||||||
|
/* Logic operator. Used for combining multiple rules into more complex conditions. If the logic condition specified by */
|
||||||
|
/* parameters (logic operator and selected rules) is met, an action is triggered. */
|
||||||
|
/* parameter[0] - Logic operator (as described in LogicOperation). */
|
||||||
|
/* parameter[1] - Rule selector (bit mask). Specifies which rules should be taken into account while determining */
|
||||||
|
/* rules outcome. */
|
||||||
|
/* parameter[2] - Rule negation (bit mask). Specifies which of chosen in parameter[1] rules should be negated */
|
||||||
|
/* before determining rules outcome. */
|
||||||
|
/* parameter[3] - Rule action delay [s]. Specifies time delay between the rule activation and rule action being triggered. */
|
||||||
|
/* Range: [0:864000]. */
|
||||||
|
/* parameter[4] - Rule return delay [s]. Specifies time delay between the rule deactivation and rule action being triggered. */
|
||||||
|
/* Range: [0:864001]. Max parameter value disables action triggering on rule deactivation. */
|
||||||
|
CONDITION_LOGIC_OPERATOR = 6;
|
||||||
|
|
||||||
|
/* On measurement. Continous sensors only. The basic function is to trigger communication after measurement if at least 60s */
|
||||||
|
/* have passed since the last one. Transmission may occur every x measurement. Optionally dependency on the other rule can */
|
||||||
|
/* be configured, then, when all conditions are met, transmission is triggered. */
|
||||||
|
/* parameter[0] - Send every n measurement. This parameter specifies every which measurement transmission will be triggered */
|
||||||
|
/* if all other conditions are met. Range: [1:500]. If parameter[0] equals 1, transmission will occur after */
|
||||||
|
/* every measurement. */
|
||||||
|
/* parameter[1] - Optional. Rule selector (bit mask). Specifies which rule should be taken into account while determining */
|
||||||
|
/* the measurement rule outcome. */
|
||||||
|
/* parameter[2] - Optional. Rule negation (bit mask). Specifies which of chosen in parameter[1] rule should be negated */
|
||||||
|
/* before determining the measurement rule outcome. */
|
||||||
|
CONDITION_ON_MEASUREMENT = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Logic operators to be used for determining the outcome of rules with logic operator condition. */
|
||||||
|
enum LogicOperator {
|
||||||
|
|
||||||
|
/* Invalid use */
|
||||||
|
LOGIC_OPERATOR_UNSPECIFIED = 0;
|
||||||
|
|
||||||
|
/* Logic AND */
|
||||||
|
LOGIC_OPERATOR_AND = 1;
|
||||||
|
|
||||||
|
/* Logic OR */
|
||||||
|
LOGIC_OPERATOR_OR = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action to be triggered. Currently the only possible action is to trigger the transmission. */
|
||||||
|
/* Other actions will be available in next SW releases. */
|
||||||
|
enum Action {
|
||||||
|
|
||||||
|
/* Invalid value */
|
||||||
|
ACTION_UNSPECIFIED = 0;
|
||||||
|
|
||||||
|
/* To trigger the transmission */
|
||||||
|
ACTION_TRIGGER_TRANSMISSION = 1;
|
||||||
|
|
||||||
|
/* To take no action. Possible for logic operator components */
|
||||||
|
ACTION_NO_ACTION = 2;
|
||||||
|
|
||||||
|
/* To trigger the transmission with ACK */
|
||||||
|
ACTION_TRIGGER_TRANSMISSION_WITH_ACK = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Type of a rule calendars. */
|
||||||
|
enum CalendarType {
|
||||||
|
|
||||||
|
/* Invalid value */
|
||||||
|
CALENDAR_TYPE_UNSPECIFIED = 0;
|
||||||
|
|
||||||
|
/* Type for inactive calendars */
|
||||||
|
CALENDAR_TYPE_DISABLED = 1;
|
||||||
|
|
||||||
|
/* Week type. Enables selcted rules on specified days of the week in specified time periods. */
|
||||||
|
/* parameter[0] - Week day mask. Bitmask of days when selected rules are enabled */
|
||||||
|
/* - Bit 0 - Sunday */
|
||||||
|
/* - Bit 1 - Monday */
|
||||||
|
/* ... */
|
||||||
|
/* - Bit 6 - Saturday */
|
||||||
|
/* parameter[1] - 'From time' - point in time from which selected rules will be enabled (in minutes from midnight). */
|
||||||
|
/* parameter[2] - 'To time' - point in time from which selected rules will be disabled (in minutes from midnight). */
|
||||||
|
/* Note: if 'From time' is bigger than 'To time' there are two periods when rules are enabled - from 00:00 to 'To time' */
|
||||||
|
/* and from 'From time' to 23:59. */
|
||||||
|
/* parameter[3] - Timezone - desired timezone for date comparison. Encoded as number (N) of 15 minutes offsets */
|
||||||
|
/* - example - if N = 4, then offset = 4 * 15min = 1h. I.e. timezone is UTC+1. */
|
||||||
|
CALENDAR_TYPE_WEEK = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rules calendars. Used for enabling/disabling rules based on date/time. */
|
||||||
|
/* It is possible to configure up to 6 calendars. Each of them can affect any number of rules. */
|
||||||
|
message ProtoCalendar {
|
||||||
|
|
||||||
|
/* Bit mask of selected rules. Mask on bits [0:11] */
|
||||||
|
/* - Bit 0 - Rule ID 0 */
|
||||||
|
/* - Bit 1 - Rule ID 1 */
|
||||||
|
/* ... */
|
||||||
|
/* - Bit 11 - Rule ID 11 */
|
||||||
|
uint32 rule_mask = 1;
|
||||||
|
|
||||||
|
/* Calendars's parameters. Described in Type. */
|
||||||
|
repeated sint32 parameters = 2;
|
||||||
|
|
||||||
|
/* Calendar's type. Described in Type. */
|
||||||
|
CalendarType type = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rules used to define edge logic on the device. Rules are defined by conditions and actions: */
|
||||||
|
/* If Condition is true, trigger Action. It is possible to configure up to 12 rules and assign them to different channels. */
|
||||||
|
/* One rule can be assigned to any number of channels. For instance rule "If temperature is over 10 C, trigger the transmission"*/
|
||||||
|
/* can be assigned to channels 1 and 2. No matter to how many channels a rule is assigned, it's still counted as one rule. */
|
||||||
|
message ProtoRule {
|
||||||
|
|
||||||
|
/* Channels to which the rule is assigned. One rule can be assigned to multiple channels as long as those are of the same type*/
|
||||||
|
/* Bit mask on bits [0:5]. E.g. To assign the rule for channel 1: "000001", to assign rule to channels 2 and 4: "001010" */
|
||||||
|
uint32 channel_mask = 1;
|
||||||
|
|
||||||
|
/* Rule's condition (as described in Condition). */
|
||||||
|
Condition condition = 2;
|
||||||
|
|
||||||
|
/* Condition's parameters (as described in Condition). For binary sensors there are no parameters */
|
||||||
|
repeated sint32 parameters = 3;
|
||||||
|
|
||||||
|
/* Action to be triggered. */
|
||||||
|
Action action = 4;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user