Add device-profile option to configure region configuration.

By selecting a region configuration, devices using the device-profile
will only stick to the selected region configuration, rather than the
configurations provided by the selected region common-name.

This change also renames the region 'name' option to 'id' in the region
configuration, as well it adds a 'description' to provide a human
readable description, which is used in the drop-down in the UI.

This also fixes the JS API generation. In a previous commit the the
protobuf package was updated, but the latest protobuf compiler no longer
supports generating JS code (this now requires an external plugin). This
has been fixed.

Please note that if you have implemented custom ADR algorithms that are
referring to the 'regionName' key, that you must change this to
'regionConfigId' (see the ADR code example).
This commit is contained in:
Orne Brocaar
2023-01-09 12:04:10 +00:00
parent 6016159c86
commit 103e4298fb
179 changed files with 6247 additions and 3783 deletions

View File

@ -90,6 +90,9 @@ export class DeviceProfile extends jspb.Message {
getAutoDetectMeasurements(): boolean;
setAutoDetectMeasurements(value: boolean): void;
getRegionConfigId(): string;
setRegionConfigId(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): DeviceProfile.AsObject;
static toObject(includeInstance: boolean, msg: DeviceProfile): DeviceProfile.AsObject;
@ -130,6 +133,7 @@ export namespace DeviceProfile {
tagsMap: Array<[string, string]>,
measurementsMap: Array<[string, Measurement.AsObject]>,
autoDetectMeasurements: boolean,
regionConfigId: string,
}
}

View File

@ -367,7 +367,8 @@ proto.api.DeviceProfile.toObject = function(includeInstance, msg) {
abpRx2Freq: jspb.Message.getFieldWithDefault(msg, 24, 0),
tagsMap: (f = msg.getTagsMap()) ? f.toObject(includeInstance, undefined) : [],
measurementsMap: (f = msg.getMeasurementsMap()) ? f.toObject(includeInstance, proto.api.Measurement.toObject) : [],
autoDetectMeasurements: jspb.Message.getBooleanFieldWithDefault(msg, 28, false)
autoDetectMeasurements: jspb.Message.getBooleanFieldWithDefault(msg, 28, false),
regionConfigId: jspb.Message.getFieldWithDefault(msg, 29, "")
};
if (includeInstance) {
@ -520,6 +521,10 @@ proto.api.DeviceProfile.deserializeBinaryFromReader = function(msg, reader) {
var value = /** @type {boolean} */ (reader.readBool());
msg.setAutoDetectMeasurements(value);
break;
case 29:
var value = /** @type {string} */ (reader.readString());
msg.setRegionConfigId(value);
break;
default:
reader.skipField();
break;
@ -739,6 +744,13 @@ proto.api.DeviceProfile.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getRegionConfigId();
if (f.length > 0) {
writer.writeString(
29,
f
);
}
};
@ -1254,6 +1266,24 @@ proto.api.DeviceProfile.prototype.setAutoDetectMeasurements = function(value) {
};
/**
* optional string region_config_id = 29;
* @return {string}
*/
proto.api.DeviceProfile.prototype.getRegionConfigId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 29, ""));
};
/**
* @param {string} value
* @return {!proto.api.DeviceProfile} returns this
*/
proto.api.DeviceProfile.prototype.setRegionConfigId = function(value) {
return jspb.Message.setProto3StringField(this, 29, value);
};

View File

@ -702,12 +702,15 @@ export namespace ListRegionsResponse {
}
export class RegionListItem extends jspb.Message {
getName(): string;
setName(value: string): void;
getId(): string;
setId(value: string): void;
getRegion(): common_common_pb.RegionMap[keyof common_common_pb.RegionMap];
setRegion(value: common_common_pb.RegionMap[keyof common_common_pb.RegionMap]): void;
getDescription(): string;
setDescription(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): RegionListItem.AsObject;
static toObject(includeInstance: boolean, msg: RegionListItem): RegionListItem.AsObject;
@ -720,14 +723,15 @@ export class RegionListItem extends jspb.Message {
export namespace RegionListItem {
export type AsObject = {
name: string,
id: string,
region: common_common_pb.RegionMap[keyof common_common_pb.RegionMap],
description: string,
}
}
export class GetRegionRequest extends jspb.Message {
getName(): string;
setName(value: string): void;
getId(): string;
setId(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetRegionRequest.AsObject;
@ -741,13 +745,13 @@ export class GetRegionRequest extends jspb.Message {
export namespace GetRegionRequest {
export type AsObject = {
name: string,
id: string,
}
}
export class GetRegionResponse extends jspb.Message {
getName(): string;
setName(value: string): void;
getId(): string;
setId(value: string): void;
getRegion(): common_common_pb.RegionMap[keyof common_common_pb.RegionMap];
setRegion(value: common_common_pb.RegionMap[keyof common_common_pb.RegionMap]): void;
@ -778,6 +782,9 @@ export class GetRegionResponse extends jspb.Message {
getClassBPingSlotFrequency(): number;
setClassBPingSlotFrequency(value: number): void;
getDescription(): string;
setDescription(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetRegionResponse.AsObject;
static toObject(includeInstance: boolean, msg: GetRegionResponse): GetRegionResponse.AsObject;
@ -790,7 +797,7 @@ export class GetRegionResponse extends jspb.Message {
export namespace GetRegionResponse {
export type AsObject = {
name: string,
id: string,
region: common_common_pb.RegionMap[keyof common_common_pb.RegionMap],
userInfo: string,
uplinkChannelsList: Array<RegionChannel.AsObject>,
@ -800,6 +807,7 @@ export namespace GetRegionResponse {
rx2Frequency: number,
classBPingSlotDr: number,
classBPingSlotFrequency: number,
description: string,
}
}

View File

@ -5514,8 +5514,9 @@ proto.api.RegionListItem.prototype.toObject = function(opt_includeInstance) {
*/
proto.api.RegionListItem.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
region: jspb.Message.getFieldWithDefault(msg, 2, 0)
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
region: jspb.Message.getFieldWithDefault(msg, 2, 0),
description: jspb.Message.getFieldWithDefault(msg, 3, "")
};
if (includeInstance) {
@ -5554,12 +5555,16 @@ proto.api.RegionListItem.deserializeBinaryFromReader = function(msg, reader) {
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
msg.setId(value);
break;
case 2:
var value = /** @type {!proto.common.Region} */ (reader.readEnum());
msg.setRegion(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setDescription(value);
break;
default:
reader.skipField();
break;
@ -5589,7 +5594,7 @@ proto.api.RegionListItem.prototype.serializeBinary = function() {
*/
proto.api.RegionListItem.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
f = message.getId();
if (f.length > 0) {
writer.writeString(
1,
@ -5603,14 +5608,21 @@ proto.api.RegionListItem.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getDescription();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional string name = 1;
* optional string id = 1;
* @return {string}
*/
proto.api.RegionListItem.prototype.getName = function() {
proto.api.RegionListItem.prototype.getId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
@ -5619,7 +5631,7 @@ proto.api.RegionListItem.prototype.getName = function() {
* @param {string} value
* @return {!proto.api.RegionListItem} returns this
*/
proto.api.RegionListItem.prototype.setName = function(value) {
proto.api.RegionListItem.prototype.setId = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
@ -5642,6 +5654,24 @@ proto.api.RegionListItem.prototype.setRegion = function(value) {
};
/**
* optional string description = 3;
* @return {string}
*/
proto.api.RegionListItem.prototype.getDescription = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/**
* @param {string} value
* @return {!proto.api.RegionListItem} returns this
*/
proto.api.RegionListItem.prototype.setDescription = function(value) {
return jspb.Message.setProto3StringField(this, 3, value);
};
@ -5674,7 +5704,7 @@ proto.api.GetRegionRequest.prototype.toObject = function(opt_includeInstance) {
*/
proto.api.GetRegionRequest.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, "")
id: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
@ -5713,7 +5743,7 @@ proto.api.GetRegionRequest.deserializeBinaryFromReader = function(msg, reader) {
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
msg.setId(value);
break;
default:
reader.skipField();
@ -5744,7 +5774,7 @@ proto.api.GetRegionRequest.prototype.serializeBinary = function() {
*/
proto.api.GetRegionRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
f = message.getId();
if (f.length > 0) {
writer.writeString(
1,
@ -5755,10 +5785,10 @@ proto.api.GetRegionRequest.serializeBinaryToWriter = function(message, writer) {
/**
* optional string name = 1;
* optional string id = 1;
* @return {string}
*/
proto.api.GetRegionRequest.prototype.getName = function() {
proto.api.GetRegionRequest.prototype.getId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
@ -5767,7 +5797,7 @@ proto.api.GetRegionRequest.prototype.getName = function() {
* @param {string} value
* @return {!proto.api.GetRegionRequest} returns this
*/
proto.api.GetRegionRequest.prototype.setName = function(value) {
proto.api.GetRegionRequest.prototype.setId = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
@ -5811,7 +5841,7 @@ proto.api.GetRegionResponse.prototype.toObject = function(opt_includeInstance) {
*/
proto.api.GetRegionResponse.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
region: jspb.Message.getFieldWithDefault(msg, 2, 0),
userInfo: jspb.Message.getFieldWithDefault(msg, 3, ""),
uplinkChannelsList: jspb.Message.toObjectList(msg.getUplinkChannelsList(),
@ -5821,7 +5851,8 @@ proto.api.GetRegionResponse.toObject = function(includeInstance, msg) {
rx2Dr: jspb.Message.getFieldWithDefault(msg, 7, 0),
rx2Frequency: jspb.Message.getFieldWithDefault(msg, 8, 0),
classBPingSlotDr: jspb.Message.getFieldWithDefault(msg, 9, 0),
classBPingSlotFrequency: jspb.Message.getFieldWithDefault(msg, 10, 0)
classBPingSlotFrequency: jspb.Message.getFieldWithDefault(msg, 10, 0),
description: jspb.Message.getFieldWithDefault(msg, 11, "")
};
if (includeInstance) {
@ -5860,7 +5891,7 @@ proto.api.GetRegionResponse.deserializeBinaryFromReader = function(msg, reader)
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
msg.setId(value);
break;
case 2:
var value = /** @type {!proto.common.Region} */ (reader.readEnum());
@ -5899,6 +5930,10 @@ proto.api.GetRegionResponse.deserializeBinaryFromReader = function(msg, reader)
var value = /** @type {number} */ (reader.readUint32());
msg.setClassBPingSlotFrequency(value);
break;
case 11:
var value = /** @type {string} */ (reader.readString());
msg.setDescription(value);
break;
default:
reader.skipField();
break;
@ -5928,7 +5963,7 @@ proto.api.GetRegionResponse.prototype.serializeBinary = function() {
*/
proto.api.GetRegionResponse.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
f = message.getId();
if (f.length > 0) {
writer.writeString(
1,
@ -5999,14 +6034,21 @@ proto.api.GetRegionResponse.serializeBinaryToWriter = function(message, writer)
f
);
}
f = message.getDescription();
if (f.length > 0) {
writer.writeString(
11,
f
);
}
};
/**
* optional string name = 1;
* optional string id = 1;
* @return {string}
*/
proto.api.GetRegionResponse.prototype.getName = function() {
proto.api.GetRegionResponse.prototype.getId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
@ -6015,7 +6057,7 @@ proto.api.GetRegionResponse.prototype.getName = function() {
* @param {string} value
* @return {!proto.api.GetRegionResponse} returns this
*/
proto.api.GetRegionResponse.prototype.setName = function(value) {
proto.api.GetRegionResponse.prototype.setId = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
@ -6202,6 +6244,24 @@ proto.api.GetRegionResponse.prototype.setClassBPingSlotFrequency = function(valu
};
/**
* optional string description = 11;
* @return {string}
*/
proto.api.GetRegionResponse.prototype.getDescription = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 11, ""));
};
/**
* @param {string} value
* @return {!proto.api.GetRegionResponse} returns this
*/
proto.api.GetRegionResponse.prototype.setDescription = function(value) {
return jspb.Message.setProto3StringField(this, 11, value);
};