-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add some more simple commands and refactor deserialization
- Loading branch information
Showing
8 changed files
with
111 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { SynchronousCode } from '../codes' | ||
import { ResponseMessage, NamedMessage } from '../message' | ||
import { AbstractCommandBase } from './abstractCommand' | ||
|
||
export interface DeviceInfoCommandResponse { | ||
ProtocolVersion: number | ||
Model: string | ||
UniqueId: string | ||
} | ||
|
||
export class DeviceInfoCommand extends AbstractCommandBase<DeviceInfoCommandResponse> { | ||
expectedResponseCode = SynchronousCode.Notify | ||
|
||
deserialize (msg: ResponseMessage) { | ||
const res: DeviceInfoCommandResponse = { | ||
ProtocolVersion: parseFloat(msg.Params['protocol version']), | ||
Model: msg.Params['model'], | ||
UniqueId: msg.Params['unique id'], | ||
} | ||
return res | ||
} | ||
serialize () { | ||
const res: NamedMessage = { | ||
Name: 'device info', | ||
Params: {} | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export { AbstractCommand, ErrorResponse } from './abstractCommand' | ||
|
||
export * from './notify' | ||
export { ConnectionInfoResponse } from './connect' | ||
export * from './deviceInfo' | ||
export * from './notify' | ||
export * from './record' | ||
export * from './stop' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NamedMessage } from '../message' | ||
import { AbstractCommandBaseNoResponse } from './abstractCommand' | ||
|
||
export class RecordCommand extends AbstractCommandBaseNoResponse { | ||
Filename: string | undefined | ||
|
||
serialize () { | ||
const res: NamedMessage = { | ||
Name: 'record', | ||
Params: {} | ||
} | ||
|
||
if (this.Filename) res.Params.Name = this.Filename | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NamedMessage } from '../message' | ||
import { AbstractCommandBaseNoResponse } from './abstractCommand' | ||
|
||
export class StopCommand extends AbstractCommandBaseNoResponse { | ||
serialize () { | ||
const res: NamedMessage = { | ||
Name: 'stop', | ||
Params: {} | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters