Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
143b30e
Upgraded gateway to Chirpstack V4. Need to add tags.
AugustHA-Iterator Nov 17, 2023
9276f80
Chirpstack updates.
AugustHA-Iterator Nov 29, 2023
a550178
changed the metadataheader to using apikey.
AugustHA-Iterator Nov 30, 2023
cd698e9
cleanup
AugustHA-Iterator Nov 30, 2023
253cc86
Merge branch 'stage' into feature/IOT-1436_ChirpstackUpgrade
AugustHA-Iterator Dec 8, 2023
27fbde0
everything but gateways work
AugustHA-Iterator Dec 8, 2023
3130d82
Made chirpstack work with gateways aswell after merge
AugustHA-Iterator Dec 10, 2023
7654a29
minor fixes in application
AugustHA-Iterator Dec 10, 2023
49b4567
Check for devices using deviceprofile before deleting.
AugustHA-Iterator Dec 11, 2023
c689c4d
change default port to 8080
AugustHA-Iterator Dec 11, 2023
2518755
minor cleanup and addition of chirpstackId in application if not set …
AugustHA-Iterator Dec 12, 2023
b34d1d6
bumped grpc package
AugustHA-Iterator Dec 12, 2023
51abe4b
updated package-lock, using node v 16 as github does.
AugustHA-Iterator Dec 12, 2023
25c83f5
formatting and bumped chirpstack-api
AugustHA-Iterator Dec 12, 2023
0415c78
Packagelock fix
AugustHA-Iterator Dec 12, 2023
193ae00
PR changes
AugustHA-Iterator Dec 14, 2023
d2cecdb
cleanup
AugustHA-Iterator Dec 14, 2023
b2f62c4
added bluebird
AugustHA-Iterator Dec 14, 2023
183dbb1
PR updates.
AugustHA-Iterator Dec 14, 2023
ca24ae0
minor cleanup and update to application so the names in chirpstack is…
AugustHA-Iterator Dec 14, 2023
e5ed65d
removed unused jwt token
AugustHA-Iterator Dec 14, 2023
efad399
Fixed small formatting oversight
fcv-iteratorIt Dec 15, 2023
ec076c7
Small name and format changes
fcv-iteratorIt Dec 15, 2023
0d80d0b
PR changes
AugustHA-Iterator Dec 15, 2023
f53574c
Changed error message
AugustHA-Iterator Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,266 changes: 929 additions & 337 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
},
"dependencies": {
"@nestjs/axios": "^3.0.0",
"@chirpstack/chirpstack-api": "4.6.0",
"@grpc/grpc-js": "^1.9.12",
"@nestjs/common": "^9.1.2",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.1.2",
Expand Down
18 changes: 11 additions & 7 deletions resources/chirpstack-state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package gw;

// ConnState contains the connection state of a gateway.
message ConnState {
// Gateway ID.
bytes gateway_id = 1 [json_name = "gatewayID"];
// Gateway ID.
// Deprecated: use gateway_id.
bytes gateway_id_legacy = 1;

enum State {
OFFLINE = 0;
ONLINE = 1;
}
// Gateway ID.
string gateway_id = 3;

State state = 2;
enum State {
OFFLINE = 0;
ONLINE = 1;
}

State state = 2;
}
22 changes: 7 additions & 15 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,21 @@ export default (): any => {
expiresIn: process.env.JWT_EXPIRESIN || "9h",
},
backend: {
baseurl:
process.env.BACKEND_BASEURL || "https://test-os2iot-backend.os2iot.dk",
deviceStatsIntervalInDays:
parseInt(process.env.DEVICE_STATS_INTERVAL_IN_DAYS, 10) || 29,
baseurl: process.env.BACKEND_BASEURL || "https://localhost:3000",
deviceStatsIntervalInDays: parseInt(process.env.DEVICE_STATS_INTERVAL_IN_DAYS, 10) || 29,
},
kombit: {
entryPoint:
process.env.KOMBIT_ENTRYPOINT ||
"https://adgangsstyring.eksterntest-stoettesystemerne.dk/runtime/saml2/issue.idp",
"https://adgangsstyring.eksterntest-stoettesystemerne.dk/runtime/saml2/issue.idp",
certificatePublicKey: process.env.KOMBIT_CERTIFICATEPUBLICKEY || "INSERT_KOMBIT_CERT", // Public certificate from Kombit Test server
certificatePrivateKey: process.env.KOMBIT_CERTIFICATEPRIVATEKEY || null,
roleUri:
process.env.KOMBIT_ROLE_NAME ||
"http://os2iot.dk/roles/usersystemrole/adgang/",
roleUri: process.env.KOMBIT_ROLE_NAME || "http://os2iot.dk/roles/usersystemrole/adgang/",
},
chirpstack: {
jwtsecret: process.env.CHIRPSTACK_JWTSECRET || "verysecret",
apikey: process.env.CHIRPSTACK_API_KEY || "apikey",
},
logLevels: process.env.LOG_LEVEL
? GetLogLevels(process.env.LOG_LEVEL)
: GetLogLevels("debug"),
logLevels: process.env.LOG_LEVEL ? GetLogLevels(process.env.LOG_LEVEL) : GetLogLevels("debug"),
email: {
host: process.env.EMAIL_HOST || "smtp.ethereal.email",
port: process.env.EMAIL_PORT || 587,
Expand All @@ -45,9 +39,7 @@ export default (): any => {
* Can be formatted to show a user-friendly name before the e-mail.
* E.g. "OS2iot <[email protected]>"
*/
from: process.env.EMAIL_FROM
? formatEmail(process.env.EMAIL_FROM)
: "OS2iot [email protected]",
from: process.env.EMAIL_FROM ? formatEmail(process.env.EMAIL_FROM) : "OS2iot [email protected]",
},
frontend: {
baseurl: process.env.FRONTEND_BASEURL || "http://localhost:8081",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {

import { Read, ApplicationAdmin } from "@auth/roles.decorator";
import { RolesGuard } from "@auth/roles.guard";
import { CreateChirpstackProfileResponseDto } from "@dto/chirpstack/create-chirpstack-profile-response.dto";
import { CreateDeviceProfileDto } from "@dto/chirpstack/create-device-profile.dto";
import { ListAllDeviceProfilesResponseDto } from "@dto/chirpstack/list-all-device-profiles-response.dto";
import { UpdateDeviceProfileDto } from "@dto/chirpstack/update-device-profile.dto";
Expand All @@ -38,6 +37,8 @@ import { checkIfUserHasAccessToOrganization, OrganizationAccessScope } from "@he
import { AuditLog } from "@services/audit-log.service";
import { ActionType } from "@entities/audit-log-entry";
import { ComposeAuthGuard } from "@auth/compose-auth.guard";
import { ListAllAdrAlgorithmsResponseDto } from "@dto/chirpstack/list-all-adr-algorithms-response.dto";
import { IdResponse } from "@interfaces/chirpstack-id-response.interface";

@ApiTags("Chirpstack")
@Controller("chirpstack/device-profiles")
Expand All @@ -55,27 +56,25 @@ export class DeviceProfileController {
@ApiOperation({ summary: "Create a new DeviceProfile" })
@ApiBadRequestResponse()
@ApplicationAdmin()
async create(
@Req() req: AuthenticatedRequest,
@Body() createDto: CreateDeviceProfileDto
): Promise<CreateChirpstackProfileResponseDto> {
checkIfUserHasAccessToOrganization(req, createDto.internalOrganizationId, OrganizationAccessScope.ApplicationWrite);
async create(@Req() req: AuthenticatedRequest, @Body() createDto: CreateDeviceProfileDto): Promise<IdResponse> {
checkIfUserHasAccessToOrganization(
req,
createDto.internalOrganizationId,
OrganizationAccessScope.ApplicationWrite
);

try {
const result = await this.deviceProfileService.createDeviceProfile(
createDto,
req.user.userId
);
const result = await this.deviceProfileService.createDeviceProfile(createDto, req.user.userId);

AuditLog.success(
ActionType.CREATE,
"ChirpstackDeviceProfile",
req.user.userId,
result.data.id,
result.id,
createDto.deviceProfile.name
);

return result.data;
return result;
} catch (err) {
AuditLog.fail(
ActionType.CREATE,
Expand Down Expand Up @@ -130,6 +129,14 @@ export class DeviceProfileController {
}
}

@Get("adr-algorithms")
@ApiProduces("application/json")
@ApiOperation({ summary: "Find all ADR algorithms for the default network server" })
@Read()
async getAllAdrAlgorithms(): Promise<ListAllAdrAlgorithmsResponseDto> {
return await this.deviceProfileService.getAdrAlgorithmsForChirpstack();
}

@Get(":id")
@ApiProduces("application/json")
@ApiOperation({ summary: "Find one DeviceProfile by id" })
Expand Down Expand Up @@ -160,14 +167,9 @@ export class DeviceProfileController {
let result = undefined;
try {
this.logger.debug(`Limit: '${limit}' Offset:'${offset}'`);
result = await this.deviceProfileService.findAllDeviceProfiles(
limit || 50,
offset || 0
);
result = await this.deviceProfileService.findAllDeviceProfiles(limit || 50, offset || 0);
} catch (err) {
this.logger.error(
`Error occured during Find all: '${JSON.stringify(err?.response?.data)}'`
);
this.logger.error(`Error occured during Find all: '${JSON.stringify(err?.response?.data)}'`);
}
return result;
}
Expand All @@ -176,30 +178,13 @@ export class DeviceProfileController {
@ApiOperation({ summary: "Delete one DeviceProfile by id" })
@ApiNotFoundResponse()
@ApplicationAdmin()
async deleteOne(
@Req() req: AuthenticatedRequest,
@Param("id") id: string
): Promise<DeleteResponseDto> {
async deleteOne(@Req() req: AuthenticatedRequest, @Param("id") id: string): Promise<DeleteResponseDto> {
try {
const result = await this.deviceProfileService.deleteDeviceProfile(id, req);

if (!result) {
throw new NotFoundException(ErrorCodes.IdDoesNotExists);
}
AuditLog.success(
ActionType.DELETE,
"ChirpstackDeviceProfile",
req.user.userId,
id
);
await this.deviceProfileService.deleteDeviceProfile(id, req);
AuditLog.success(ActionType.DELETE, "ChirpstackDeviceProfile", req.user.userId, id);
return new DeleteResponseDto(1);
} catch (err) {
AuditLog.fail(
ActionType.DELETE,
"ChirpstackDeviceProfile",
req.user.userId,
id
);
AuditLog.fail(ActionType.DELETE, "ChirpstackDeviceProfile", req.user.userId, id);
if (err?.message == this.CHIRPSTACK_IN_USE_ERROR) {
throw new BadRequestException(ErrorCodes.IsUsed);
}
Expand Down

This file was deleted.

Loading