Skip to content

Commit 78b0de6

Browse files
authored
Use V2 schemas (#313)
* Implement missing command handlers * Don't generate deprecated schemas * Fix CI issue * Fix empty version in CI * Use V2 endpoint
1 parent b6e5cea commit 78b0de6

File tree

66 files changed

+1747
-899
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1747
-899
lines changed

.github/workflows/cpp-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- uses: ./.github/actions/build-compilationdb
2929
with:
30-
board: OpenShock-Core-V2 # Doesn't matter, just need the compilation database
30+
version: 0.0.0-test+build # Doesn't matter, just need the compilation database
3131
skip-checkout: true
3232

3333
- uses: cpp-linter/cpp-linter-action@v2

frontend/src/lib/_fbs/open-shock/serialization/configuration/estop-config.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ gpioPin():number {
3535
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
3636
}
3737

38+
/**
39+
* Persistent state of the E-Stop button
40+
*/
41+
active():boolean {
42+
const offset = this.bb!.__offset(this.bb_pos, 8);
43+
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
44+
}
45+
3846
static startEStopConfig(builder:flatbuffers.Builder) {
39-
builder.startObject(2);
47+
builder.startObject(3);
4048
}
4149

4250
static addEnabled(builder:flatbuffers.Builder, enabled:boolean) {
@@ -47,15 +55,20 @@ static addGpioPin(builder:flatbuffers.Builder, gpioPin:number) {
4755
builder.addFieldInt8(1, gpioPin, 0);
4856
}
4957

58+
static addActive(builder:flatbuffers.Builder, active:boolean) {
59+
builder.addFieldInt8(2, +active, +false);
60+
}
61+
5062
static endEStopConfig(builder:flatbuffers.Builder):flatbuffers.Offset {
5163
const offset = builder.endObject();
5264
return offset;
5365
}
5466

55-
static createEStopConfig(builder:flatbuffers.Builder, enabled:boolean, gpioPin:number):flatbuffers.Offset {
67+
static createEStopConfig(builder:flatbuffers.Builder, enabled:boolean, gpioPin:number, active:boolean):flatbuffers.Offset {
5668
EStopConfig.startEStopConfig(builder);
5769
EStopConfig.addEnabled(builder, enabled);
5870
EStopConfig.addGpioPin(builder, gpioPin);
71+
EStopConfig.addActive(builder, active);
5972
return EStopConfig.endEStopConfig(builder);
6073
}
6174
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// automatically generated by the FlatBuffers compiler, do not modify
2-
3-
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4-
5-
export { BootStatus } from './gateway/boot-status';
6-
export { HubToGatewayMessage } from './gateway/hub-to-gateway-message';
7-
export { HubToGatewayMessagePayload } from './gateway/hub-to-gateway-message-payload';
8-
export { KeepAlive } from './gateway/keep-alive';
9-
export { OtaInstallFailed } from './gateway/ota-install-failed';
10-
export { OtaInstallProgress } from './gateway/ota-install-progress';
11-
export { OtaInstallProgressTask } from './gateway/ota-install-progress-task';
12-
export { OtaInstallStarted } from './gateway/ota-install-started';
1+
// automatically generated by the FlatBuffers compiler, do not modify
2+
3+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4+
5+
export { BootStatus } from './gateway/boot-status';
6+
export { HubToGatewayMessage } from './gateway/hub-to-gateway-message';
7+
export { HubToGatewayMessagePayload } from './gateway/hub-to-gateway-message-payload';
8+
export { OtaUpdateFailed } from './gateway/ota-update-failed';
9+
export { OtaUpdateProgress } from './gateway/ota-update-progress';
10+
export { OtaUpdateStarted } from './gateway/ota-update-started';
11+
export { Pong } from './gateway/pong';

frontend/src/lib/_fbs/open-shock/serialization/gateway/boot-status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static addOtaUpdateId(builder:flatbuffers.Builder, otaUpdateId:number) {
5959

6060
static endBootStatus(builder:flatbuffers.Builder):flatbuffers.Offset {
6161
const offset = builder.endObject();
62+
builder.requiredField(offset, 6) // firmware_version
6263
return offset;
6364
}
6465

frontend/src/lib/_fbs/open-shock/serialization/gateway/captive-portal-config.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-hub-message-payload.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,61 @@
22

33
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
44

5-
import { CaptivePortalConfig } from '../../../open-shock/serialization/gateway/captive-portal-config';
6-
import { OtaInstall } from '../../../open-shock/serialization/gateway/ota-install';
5+
import { OtaUpdateRequest } from '../../../open-shock/serialization/gateway/ota-update-request';
6+
import { Ping } from '../../../open-shock/serialization/gateway/ping';
77
import { ShockerCommandList } from '../../../open-shock/serialization/gateway/shocker-command-list';
8+
import { Trigger } from '../../../open-shock/serialization/gateway/trigger';
89

910

1011
export enum GatewayToHubMessagePayload {
1112
NONE = 0,
12-
ShockerCommandList = 1,
13-
CaptivePortalConfig = 2,
14-
OtaInstall = 3
13+
14+
/**
15+
* Ping message, should immediately be responded to with a pong
16+
*/
17+
Ping = 1,
18+
19+
/**
20+
* Trigger a specific action on the hub
21+
*/
22+
Trigger = 2,
23+
24+
/**
25+
* Send a list of shocker commands to the hub
26+
*/
27+
ShockerCommandList = 3,
28+
29+
/**
30+
* Request an OTA update to be performed
31+
*/
32+
OtaUpdateRequest = 4
1533
}
1634

1735
export function unionToGatewayToHubMessagePayload(
1836
type: GatewayToHubMessagePayload,
19-
accessor: (obj:CaptivePortalConfig|OtaInstall|ShockerCommandList) => CaptivePortalConfig|OtaInstall|ShockerCommandList|null
20-
): CaptivePortalConfig|OtaInstall|ShockerCommandList|null {
37+
accessor: (obj:OtaUpdateRequest|Ping|ShockerCommandList|Trigger) => OtaUpdateRequest|Ping|ShockerCommandList|Trigger|null
38+
): OtaUpdateRequest|Ping|ShockerCommandList|Trigger|null {
2139
switch(GatewayToHubMessagePayload[type]) {
2240
case 'NONE': return null;
41+
case 'Ping': return accessor(new Ping())! as Ping;
42+
case 'Trigger': return accessor(new Trigger())! as Trigger;
2343
case 'ShockerCommandList': return accessor(new ShockerCommandList())! as ShockerCommandList;
24-
case 'CaptivePortalConfig': return accessor(new CaptivePortalConfig())! as CaptivePortalConfig;
25-
case 'OtaInstall': return accessor(new OtaInstall())! as OtaInstall;
44+
case 'OtaUpdateRequest': return accessor(new OtaUpdateRequest())! as OtaUpdateRequest;
2645
default: return null;
2746
}
2847
}
2948

3049
export function unionListToGatewayToHubMessagePayload(
3150
type: GatewayToHubMessagePayload,
32-
accessor: (index: number, obj:CaptivePortalConfig|OtaInstall|ShockerCommandList) => CaptivePortalConfig|OtaInstall|ShockerCommandList|null,
51+
accessor: (index: number, obj:OtaUpdateRequest|Ping|ShockerCommandList|Trigger) => OtaUpdateRequest|Ping|ShockerCommandList|Trigger|null,
3352
index: number
34-
): CaptivePortalConfig|OtaInstall|ShockerCommandList|null {
53+
): OtaUpdateRequest|Ping|ShockerCommandList|Trigger|null {
3554
switch(GatewayToHubMessagePayload[type]) {
3655
case 'NONE': return null;
56+
case 'Ping': return accessor(index, new Ping())! as Ping;
57+
case 'Trigger': return accessor(index, new Trigger())! as Trigger;
3758
case 'ShockerCommandList': return accessor(index, new ShockerCommandList())! as ShockerCommandList;
38-
case 'CaptivePortalConfig': return accessor(index, new CaptivePortalConfig())! as CaptivePortalConfig;
39-
case 'OtaInstall': return accessor(index, new OtaInstall())! as OtaInstall;
59+
case 'OtaUpdateRequest': return accessor(index, new OtaUpdateRequest())! as OtaUpdateRequest;
4060
default: return null;
4161
}
4262
}

frontend/src/lib/_fbs/open-shock/serialization/gateway/gateway-to-hub-message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset)
4949

5050
static endGatewayToHubMessage(builder:flatbuffers.Builder):flatbuffers.Offset {
5151
const offset = builder.endObject();
52+
builder.requiredField(offset, 6) // payload
5253
return offset;
5354
}
5455

frontend/src/lib/_fbs/open-shock/serialization/gateway/hub-to-gateway-message-payload.ts

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,68 @@
33
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
44

55
import { BootStatus } from '../../../open-shock/serialization/gateway/boot-status';
6-
import { KeepAlive } from '../../../open-shock/serialization/gateway/keep-alive';
7-
import { OtaInstallFailed } from '../../../open-shock/serialization/gateway/ota-install-failed';
8-
import { OtaInstallProgress } from '../../../open-shock/serialization/gateway/ota-install-progress';
9-
import { OtaInstallStarted } from '../../../open-shock/serialization/gateway/ota-install-started';
6+
import { OtaUpdateFailed } from '../../../open-shock/serialization/gateway/ota-update-failed';
7+
import { OtaUpdateProgress } from '../../../open-shock/serialization/gateway/ota-update-progress';
8+
import { OtaUpdateStarted } from '../../../open-shock/serialization/gateway/ota-update-started';
9+
import { Pong } from '../../../open-shock/serialization/gateway/pong';
1010

1111

1212
export enum HubToGatewayMessagePayload {
1313
NONE = 0,
14-
KeepAlive = 1,
14+
15+
/**
16+
* Respond to a ping message
17+
*/
18+
Pong = 1,
19+
20+
/**
21+
* Report the current boot status, used to report firmware version and OTA update results
22+
*/
1523
BootStatus = 2,
16-
OtaInstallStarted = 3,
17-
OtaInstallProgress = 4,
18-
OtaInstallFailed = 5
24+
25+
/**
26+
* Report that an OTA update has started
27+
*/
28+
OtaUpdateStarted = 3,
29+
30+
/**
31+
* Report the progress of an OTA update
32+
*/
33+
OtaUpdateProgress = 4,
34+
35+
/**
36+
* Report that an OTA update has failed
37+
*/
38+
OtaUpdateFailed = 5
1939
}
2040

2141
export function unionToHubToGatewayMessagePayload(
2242
type: HubToGatewayMessagePayload,
23-
accessor: (obj:BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted) => BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null
24-
): BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null {
43+
accessor: (obj:BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong) => BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong|null
44+
): BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong|null {
2545
switch(HubToGatewayMessagePayload[type]) {
2646
case 'NONE': return null;
27-
case 'KeepAlive': return accessor(new KeepAlive())! as KeepAlive;
47+
case 'Pong': return accessor(new Pong())! as Pong;
2848
case 'BootStatus': return accessor(new BootStatus())! as BootStatus;
29-
case 'OtaInstallStarted': return accessor(new OtaInstallStarted())! as OtaInstallStarted;
30-
case 'OtaInstallProgress': return accessor(new OtaInstallProgress())! as OtaInstallProgress;
31-
case 'OtaInstallFailed': return accessor(new OtaInstallFailed())! as OtaInstallFailed;
49+
case 'OtaUpdateStarted': return accessor(new OtaUpdateStarted())! as OtaUpdateStarted;
50+
case 'OtaUpdateProgress': return accessor(new OtaUpdateProgress())! as OtaUpdateProgress;
51+
case 'OtaUpdateFailed': return accessor(new OtaUpdateFailed())! as OtaUpdateFailed;
3252
default: return null;
3353
}
3454
}
3555

3656
export function unionListToHubToGatewayMessagePayload(
3757
type: HubToGatewayMessagePayload,
38-
accessor: (index: number, obj:BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted) => BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null,
58+
accessor: (index: number, obj:BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong) => BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong|null,
3959
index: number
40-
): BootStatus|KeepAlive|OtaInstallFailed|OtaInstallProgress|OtaInstallStarted|null {
60+
): BootStatus|OtaUpdateFailed|OtaUpdateProgress|OtaUpdateStarted|Pong|null {
4161
switch(HubToGatewayMessagePayload[type]) {
4262
case 'NONE': return null;
43-
case 'KeepAlive': return accessor(index, new KeepAlive())! as KeepAlive;
63+
case 'Pong': return accessor(index, new Pong())! as Pong;
4464
case 'BootStatus': return accessor(index, new BootStatus())! as BootStatus;
45-
case 'OtaInstallStarted': return accessor(index, new OtaInstallStarted())! as OtaInstallStarted;
46-
case 'OtaInstallProgress': return accessor(index, new OtaInstallProgress())! as OtaInstallProgress;
47-
case 'OtaInstallFailed': return accessor(index, new OtaInstallFailed())! as OtaInstallFailed;
65+
case 'OtaUpdateStarted': return accessor(index, new OtaUpdateStarted())! as OtaUpdateStarted;
66+
case 'OtaUpdateProgress': return accessor(index, new OtaUpdateProgress())! as OtaUpdateProgress;
67+
case 'OtaUpdateFailed': return accessor(index, new OtaUpdateFailed())! as OtaUpdateFailed;
4868
default: return null;
4969
}
5070
}

frontend/src/lib/_fbs/open-shock/serialization/gateway/hub-to-gateway-message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static addPayload(builder:flatbuffers.Builder, payloadOffset:flatbuffers.Offset)
4949

5050
static endHubToGatewayMessage(builder:flatbuffers.Builder):flatbuffers.Offset {
5151
const offset = builder.endObject();
52+
builder.requiredField(offset, 6) // payload
5253
return offset;
5354
}
5455

frontend/src/lib/_fbs/open-shock/serialization/gateway/keep-alive.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)