-
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.
- Loading branch information
Showing
4 changed files
with
103 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import { AsynchronousCode } from '../codes' | ||
import { ResponseMessage } from '../message' | ||
import { AbstractCommandBase } from './abstractCommand' | ||
|
||
export interface ConnectionInfoResponse { | ||
ProtocolVersion: number | ||
Model: string | ||
} | ||
|
||
// Purpose of this is to emit the connect event with the connectionInfo | ||
export class DummyConnectCommand extends AbstractCommandBase<ConnectionInfoResponse> { | ||
expectedResponseCode = AsynchronousCode.ConnectionInfo | ||
|
||
deserialize (msg: ResponseMessage) { | ||
const res: ConnectionInfoResponse = { | ||
ProtocolVersion: parseFloat(msg.Params['protocol version']), | ||
Model: msg.Params['model'] | ||
} | ||
return res | ||
} | ||
serialize () { | ||
// Nothing to send | ||
return null | ||
} | ||
} |
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,52 @@ | ||
import { AsynchronousCode } from '../codes' | ||
import { ResponseMessage, NamedMessage } from '../message' | ||
import { AbstractCommandBase, AbstractCommandBaseNoResponse } from './abstractCommand' | ||
import { ConnectionInfoResponse } from './connect' | ||
|
||
// Purpose of this is to emit the connect event with the connectionInfo | ||
export class DummyConnectCommand extends AbstractCommandBase<ConnectionInfoResponse> { | ||
expectedResponseCode = AsynchronousCode.ConnectionInfo | ||
|
||
deserialize (msg: ResponseMessage) { | ||
const res: ConnectionInfoResponse = { | ||
ProtocolVersion: parseFloat(msg.Params['protocol version']), | ||
Model: msg.Params['model'] | ||
} | ||
return res | ||
} | ||
serialize () { | ||
// Nothing to send | ||
return null | ||
} | ||
} | ||
|
||
export class WatchdogPeriodCommand extends AbstractCommandBaseNoResponse { | ||
readonly Period: number | ||
|
||
constructor(period: number){ | ||
super() | ||
this.Period = period | ||
} | ||
|
||
serialize () { | ||
const res: NamedMessage = { | ||
Name: 'watchdog', | ||
Params: { | ||
period: this.Period + '' | ||
} | ||
} | ||
|
||
return res | ||
} | ||
} | ||
|
||
export class PingCommand extends AbstractCommandBaseNoResponse { | ||
serialize () { | ||
const res: NamedMessage = { | ||
Name: 'ping', | ||
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