File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,8 @@ import { AutodartsBoard } from 'autodarts-board'
88 board . onMessage ( ( msg ) => {
99 if ( msg . type == 'motion_state' ) console . log ( msg . data )
1010 } )
11+
12+ // board.start()
13+ // board.stop()
14+ // board.reset()
1115} ) ( )
Original file line number Diff line number Diff line change @@ -74,4 +74,38 @@ export class AutodartsBoard {
7474 onMessage ( listener : ( data : AutodartsWsMessage ) => void ) {
7575 this . eventEmitter . on ( 'message' , listener )
7676 }
77+
78+ private async fetch ( path : string , init : RequestInit ) {
79+ return await fetch ( `http://${ this . host } :${ this . port } ${ path } ` , init )
80+ }
81+
82+ /**
83+ * Start the cameras
84+ */
85+ async start ( ) {
86+ const res = await this . fetch ( '/api/start' , {
87+ method : 'PUT' ,
88+ } )
89+ return res . status == 200
90+ }
91+
92+ /**
93+ * Stop the cameras
94+ */
95+ async stop ( ) {
96+ const res = await this . fetch ( '/api/stop' , {
97+ method : 'PUT' ,
98+ } )
99+ return res . status == 200
100+ }
101+
102+ /**
103+ * Reset the board
104+ */
105+ async reset ( ) {
106+ const res = await this . fetch ( '/api/reset' , {
107+ method : 'POST' ,
108+ } )
109+ return res . status == 200
110+ }
77111}
You can’t perform that action at this time.
0 commit comments