Skip to content

Commit

Permalink
pod controls send state transition requests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeechey committed Jul 1, 2024
1 parent f4f6429 commit dfc2393
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable, LoggerService, Inject } from '@nestjs/common';
import { MqttService } from 'nest-mqtt';
import { Logger } from '@/modules/logger/Logger.decorator';
import { ALL_POD_STATES } from '@hyped/telemetry-constants';

@Injectable()
export class PodControlsService {
Expand All @@ -19,18 +20,19 @@ export class PodControlsService {
async sendControlMessage(control: string, podId: string) {
switch (control) {
case 'start':
// TODO: replace with state machine transition message to accelerating state
await this.mqttService.publish(
`hyped/${podId}/controls/${control}`,
control,
);
await this.mqttService.publish(`hyped/${podId}/state/state_request`, {
state: ALL_POD_STATES.ACCELERATE,
});
break;
case 'stop':
// TODO: replace with state machine transition message to braking state
await this.mqttService.publish(
`hyped/${podId}/controls/${control}`,
control,
);
await this.mqttService.publish(`hyped/${podId}/state/state_request`, {
state: ALL_POD_STATES.LIM_BRAKE,
});
break;
case 'levitate':
await this.mqttService.publish(`hyped/${podId}/state/state_request`, {
state: ALL_POD_STATES.BEGIN_LEVITATION,
});
break;
default:
await this.mqttService.publish(
Expand Down
2 changes: 1 addition & 1 deletion telemetry/packages/ui/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit dfc2393

Please sign in to comment.